Skip to content

Commit ee5ceed

Browse files
committed
Drop Proc#bind
Proc responds to `instance_exec` since forever ago Official Ruby docs only go back to 2.0, so I added that as the minimum version, if someone should for some reason still use rubies before that. https://docs.ruby-lang.org/en/2.0.0/BasicObject.html#method-i-instance_exec
1 parent ddbc2db commit ee5ceed

File tree

5 files changed

+5
-42
lines changed

5 files changed

+5
-42
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,6 @@ Rails/RefuteMethods:
196196
Exclude:
197197
- 'test/shoulda/helpers_test.rb'
198198

199-
# Offense count: 1
200-
# Cop supports --auto-correct.
201-
# Configuration parameters: EnforcedStyle.
202-
# SupportedStyles: strict, flexible
203-
Rails/TimeZone:
204-
Exclude:
205-
- 'lib/shoulda/context/proc_extensions.rb'
206-
207199
# Offense count: 2
208200
# Cop supports --auto-correct.
209201
# Configuration parameters: EnforcedStyle.
@@ -267,7 +259,6 @@ Style/MutableConstant:
267259
# Cop supports --auto-correct.
268260
Style/ParallelAssignment:
269261
Exclude:
270-
- 'lib/shoulda/context/proc_extensions.rb'
271262
- 'test/shoulda/should_test.rb'
272263

273264
# Offense count: 1

lib/shoulda/context.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
require "shoulda/context/configuration"
33
require "shoulda/context/context"
44
require "shoulda/context/dsl"
5-
require "shoulda/context/proc_extensions"
65
require "shoulda/context/test_framework_detection"
76
require "shoulda/context/version"
87
require "shoulda/context/world"

lib/shoulda/context/context.rb

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,7 @@ def initialize(name, parent, &blk)
3636
end
3737

3838
def merge_block(&blk)
39-
if self.respond_to?(:instance_exec)
40-
self.instance_exec(&blk)
41-
else
42-
# deprecated in Rails 4.x
43-
blk.bind(self).call
44-
end
39+
self.instance_exec(&blk)
4540
end
4641

4742
def context(name, &blk)
@@ -170,23 +165,13 @@ def run_parent_setup_blocks(binding)
170165

171166
def run_current_setup_blocks(binding)
172167
setup_blocks.each do |setup_block|
173-
if binding.respond_to?(:instance_exec)
174-
binding.instance_exec(&setup_block)
175-
else
176-
# deprecated in Rails 4.x
177-
setup_block.bind(binding).call
178-
end
168+
binding.instance_exec(&setup_block)
179169
end
180170
end
181171

182172
def run_all_teardown_blocks(binding)
183173
teardown_blocks.reverse.each do |teardown_block|
184-
if binding.respond_to?(:instance_exec)
185-
binding.instance_exec(&teardown_block)
186-
else
187-
# deprecated in Rails 4.x
188-
teardown_block.bind(binding).call
189-
end
174+
binding.instance_exec(&teardown_block)
190175
end
191176
self.parent.run_all_teardown_blocks(binding) if am_subcontext?
192177
end

lib/shoulda/context/proc_extensions.rb

Lines changed: 0 additions & 14 deletions
This file was deleted.

shoulda-context.gemspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ Gem::Specification.new do |s|
1515
s.description = "Context framework extracted from Shoulda"
1616
s.license = "MIT"
1717

18+
s.required_ruby_version = ">= 2.0.0"
19+
1820
s.files = `git ls-files`.split("\n")
1921
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
2022
s.executables = `git ls-files -- exe/*`.split("\n").map { |f| File.basename(f) }

0 commit comments

Comments
 (0)