Skip to content

Instantly share code, notes, and snippets.

@mattwynne
Created June 7, 2010 16:13
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 mattwynne/428867 to your computer and use it in GitHub Desktop.
Save mattwynne/428867 to your computer and use it in GitHub Desktop.
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