Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/shoulda/context/context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -396,31 +396,31 @@ 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)
if should[:before]
if self.respond_to?(:instance_exec)
self.instance_exec(&should[:before])
else
# deprecated in Rails 4.x
should[:before].bind(self).call
end
end
context.run_current_setup_blocks(self)
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)
Expand Down
3 changes: 3 additions & 0 deletions shoulda-context.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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