diff --git a/lib/shoulda/context/context.rb b/lib/shoulda/context/context.rb index be2232cc..cff68603 100644 --- a/lib/shoulda/context/context.rb +++ b/lib/shoulda/context/context.rb @@ -396,9 +396,10 @@ def create_test_from_should_hash(should) end test_methods[test_unit_class][test_name.to_s] = true - + file, line_no = should[:block].source_location context = self - test_unit_class.send(:define_method, test_name) do + test_unit_class.class_eval <<-end_eval, file, line_no + define_method test_name do @shoulda_context = context begin context.run_parent_setup_blocks(self) @@ -406,7 +407,6 @@ def create_test_from_should_hash(should) if self.respond_to?(:instance_exec) self.instance_exec(&should[:before]) else - # deprecated in Rails 4.x should[:before].bind(self).call end end @@ -414,13 +414,13 @@ def create_test_from_should_hash(should) if self.respond_to?(:instance_exec) self.instance_exec(&should[:block]) else - # deprecated in Rails 4.x should[:block].bind(self).call end ensure context.run_all_teardown_blocks(self) end - end + end + end_eval end def run_all_setup_blocks(binding) diff --git a/shoulda-context.gemspec b/shoulda-context.gemspec index dd46d977..7c0cd5ee 100644 --- a/shoulda-context.gemspec +++ b/shoulda-context.gemspec @@ -24,4 +24,7 @@ Gem::Specification.new do |s| s.add_development_dependency("mocha", "~> 0.9.10") s.add_development_dependency("rake") s.add_development_dependency("test-unit", "~> 2.1.0") + s.add_development_dependency("pry") + s.add_development_dependency("byebug") + s.add_development_dependency("pry-byebug") end