Created
March 28, 2011 04:59
-
-
Save niku/890024 to your computer and use it in GitHub Desktop.
how do I test block given parameter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rspec' | |
class Foo | |
def bar | |
if block_given? | |
yield(1) | |
yield(2) | |
end | |
end | |
end | |
describe Foo do | |
describe '#bar' do | |
it 'should call by 1' do | |
foo = Foo.new | |
c = 0 | |
foo.bar do |a| | |
a.should satisfy do |b| | |
c += 1 | |
b == c | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment