[rspec-users] passing a block to a stub method

David Chelimsky dchelimsky at gmail.com
Mon Sep 13 22:31:56 EDT 2010


On Sep 13, 2010, at 5:32 PM, nicolas wrote:

> It seems that rspec doesn't support passing a block to a stub method.
> This code fails:
> 
> def call_build_with_block(o)
>  o.build do
>    puts "hello"
>  end
> end
> 
> 
> describe "call_build_with_block" do
>  it "should call build with block" do
>    o = double("object")
>    o.should_receive(:build) do |&b|
>      b.should_not be_nil
>      block_given?.should == true
>    end
> 
>    call_build_with_block(o)
>  end
> end
> 
> Anybody?

Bug. Please file a bug report at http://github.com/rspec/rspec-mocks/issues.

Thx,
David



More information about the rspec-users mailing list