Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'rubygems'
require 'spec'
class Baz
def call_foo_on(subject)
block = lambda { |a| a * 2 }
subject.foo(&block)
end
end
describe Baz do
class FakeCollaborator
def foo(&block)
@block = block
end
def block_ok?
@block.call(2) == 4
end
end
it "passes a block to the collaborator which doubles numbers" do
collaborator = FakeCollaborator.new
Baz.new.call_foo_on(collaborator)
collaborator.block_ok?.should be_true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment