[rspec-users] should_receive working in before(:each) but not in example
tmhaines at gmail.com
Wed Sep 17 23:23:40 EDT 2008
I'm striking a wee problem - and haven't been able to figure it out. In my
before statement I'm setting up a mock video. I'd like one of my examples
to check that original= and save! are being called on the mock video, so I
have an example that looks like this:
it "should update the original video and save the video" do
post :upload_video, :video_id => 'hi', :Filedata => @video_file
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. I
thought @vid might be getting reassigned somewhere before the example code
is run, but I can't spot it. (@video is used in the action - not @vid).
Can anyone spot something obvious I'm doing wrong here? I'm happy for any
other feedback on this too - it's pretty ugly. Here's the whole before
block with the should's included in a location that let the example(s) pass:
@video_file = ActionController::TestUploadedFile.new(RAILS_ROOT +
@thumb = "thumb"
@original = "original"
@vid = mock_video(:original_thumbnail => @thumb, :convert_path =>
"convert_path", :still_path => "still_path", :original => @original)
@videos = 
@current_user = mock_model(User, :id => 1, :videos => @videos)
I'm betting it's something really obvious somewhere. ;-)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rspec-users