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 ee5ceed
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 42 deletions.
9 changes: 0 additions & 9 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,6 @@ Rails/RefuteMethods:
Exclude:
- 'test/shoulda/helpers_test.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: strict, flexible
Rails/TimeZone:
Exclude:
- 'lib/shoulda/context/proc_extensions.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
Expand Down Expand Up @@ -267,7 +259,6 @@ Style/MutableConstant:
# Cop supports --auto-correct.
Style/ParallelAssignment:
Exclude:
- 'lib/shoulda/context/proc_extensions.rb'
- 'test/shoulda/should_test.rb'

# Offense count: 1
Expand Down
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.

2 changes: 2 additions & 0 deletions shoulda-context.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Gem::Specification.new do |s|
s.description = "Context framework extracted from Shoulda"
s.license = "MIT"

s.required_ruby_version = ">= 2.0.0"

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- exe/*`.split("\n").map { |f| File.basename(f) }
Expand Down

0 comments on commit ee5ceed

Please sign in to comment.