Skip to content

Instantly share code, notes, and snippets.

@niku
Created March 28, 2011 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niku/890024 to your computer and use it in GitHub Desktop.
Save niku/890024 to your computer and use it in GitHub Desktop.
how do I test block given parameter
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