Skip to content

Commit

Permalink
Drop Proc#bind
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Earlopain committed Sep 13, 2024
1 parent ddbc2db commit 3f7081b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 33 deletions.
1 change: 0 additions & 1 deletion lib/shoulda/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
require "shoulda/context/configuration"
require "shoulda/context/context"
require "shoulda/context/dsl"
require "shoulda/context/proc_extensions"
require "shoulda/context/test_framework_detection"
require "shoulda/context/version"
require "shoulda/context/world"
Expand Down
21 changes: 3 additions & 18 deletions lib/shoulda/context/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@ def initialize(name, parent, &blk)
end

def merge_block(&blk)
if self.respond_to?(:instance_exec)
self.instance_exec(&blk)
else
# deprecated in Rails 4.x
blk.bind(self).call
end
self.instance_exec(&blk)
end

def context(name, &blk)
Expand Down Expand Up @@ -170,23 +165,13 @@ def run_parent_setup_blocks(binding)

def run_current_setup_blocks(binding)
setup_blocks.each do |setup_block|
if binding.respond_to?(:instance_exec)
binding.instance_exec(&setup_block)
else
# deprecated in Rails 4.x
setup_block.bind(binding).call
end
binding.instance_exec(&setup_block)
end
end

def run_all_teardown_blocks(binding)
teardown_blocks.reverse.each do |teardown_block|
if binding.respond_to?(:instance_exec)
binding.instance_exec(&teardown_block)
else
# deprecated in Rails 4.x
teardown_block.bind(binding).call
end
binding.instance_exec(&teardown_block)
end
self.parent.run_all_teardown_blocks(binding) if am_subcontext?
end
Expand Down
14 changes: 0 additions & 14 deletions lib/shoulda/context/proc_extensions.rb

This file was deleted.

0 comments on commit 3f7081b

Please sign in to comment.