[rspec-users] should_receive working in before(:each) but not in example

Mark Wilden mark at mwilden.com
Wed Sep 17 23:44:58 EDT 2008


On Wed, Sep 17, 2008 at 8:23 PM, Tim Haines <tmhaines at gmail.com> wrote:


>       it "should update the original video and save the video" do
>         post :upload_video, :video_id => 'hi', :Filedata => @video_file
>         @vid.should_receive(:original=)
>         @vid.should_receive(:save!)
>       end
>
> This fails saying that @vid didn't receive original=.  However, if I move
> the two should's up into the before block, then the example passes.
>

Right. should_receive specifies what should happen in the future, not what
has happened in the past.

///ark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20080917/ffdddf9f/attachment-0001.html>


More information about the rspec-users mailing list