I want to verify that this method passes a block to a collaborator:

module Bar
  def self.baz_wrapper(&block)
    Foo.baz(&block)
  end
end

Something like this would be nice:

it "passes the given block to Foo" do
  my_block = lambda {}

  expect(Foo).to receive(:baz).with(&my_block)

  Bar.baz_wrapper(&my_block)
end

However, the best I could come up with is this:


it "passes the given block to Foo" do
  my_block = lambda {}

  expect(Foo).to receive(:baz) do |&block|
    expect(block).to eq(my_block)
  end

  Bar.baz_wrapper(&my_block)
end

Questions.

1. Is there a better way to do this?

2. If not, would you be open to a discussion on making `expect(Foo).to 
receive(:baz).with(&my_block)` work?


Thank you,

Nathan



-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/3bfa0a8a-4f55-4e24-8527-3f2f4eb693ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to