Skip to content

Commit

Permalink
Merge pull request #22 from godfat/pass-the-block
Browse files Browse the repository at this point in the history
The methods in describe should also pass the block
  • Loading branch information
leahneukirchen committed Aug 11, 2015
2 parents b376384 + 678ed4d commit 775579a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/bacon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ def run_requirement(description, spec)
def describe(*args, &block)
context = Bacon::Context.new(args.join(' '), &block)
(parent_context = self).methods(false).each {|e|
(class << context; self; end).send(:define_method, e) { |*args2|
parent_context.send(e, *args2)
(class << context; self; end).send(:define_method, e) { |*args2, &block2|
parent_context.send(e, *args2, &block2)
}
}
@before.each { |b| context.before(&b) }
Expand Down
10 changes: 10 additions & 0 deletions test/spec_bacon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,10 @@ def the_meaning_of_life
42
end

def the_towels
yield "DON'T PANIC"
end

it "should be accessible in a test" do
the_meaning_of_life.should == 42
end
Expand All @@ -383,6 +387,12 @@ def the_meaning_of_life
it "should be accessible in a test" do
the_meaning_of_life.should == 42
end

it "should pass the block" do
the_towels do |label|
label.should == "DON'T PANIC"
end.should == true
end
end
end

Expand Down

0 comments on commit 775579a

Please sign in to comment.