[rspec-users] should_receive with block or proc?

David Chelimsky dchelimsky at gmail.com
Sun Aug 5 07:28:56 UTC 2012

On Sat, Aug 4, 2012 at 1:46 PM, Alexander Baronec <abonec at gmail.com> wrote:
> Hello.
> How can I test object to receive message and compare arguments of this
> message with value evaluated at present time? It is possible?
> For example:
> should_receive(:api_send).with( -> { players.count } ) And players.count
> will be called and evaluated only when api_send is received.

Look at Fake Implementation on
You can do the same thing w/ should_receive, e.g.

foo.should_receive(:api_send) do |player_count|
  player_count.should eq players.count


More information about the rspec-users mailing list