[rspec-users] How can I spec this? The method gets passed a block...
Louis J Scoras
louis.j.scoras at gmail.com
Fri Feb 23 17:16:22 EST 2007
On 2/23/07, Pat Maddox <pergesu at gmail.com> wrote:
> but I can't do anything else. Setting an expectation for :id, :views,
> and :date all fail. It's obvious to me why it does...the stubbed
> :video method doesn't know to execute the stuff in the block. So
> what's the best way to spec this?
Pat;
You can stub the view method in the mock and have it yield so that the
block runs:
specify "should create a video tag" do
@mock_builder.stub!(:video).and_yield
@mock_builder.should_receive(:id)
do_report
end
Not really the cleanest solution for this spec since you really
shouldn't care that view was called. That's why I stubbed it, rather
than using should_receive. Not sure how else you could get around it
though.
--
Lou.
More information about the rspec-users
mailing list