[rspec-users] should_receive working in before(:each) but not in example
tmhaines at gmail.com
Wed Sep 17 23:30:05 EDT 2008
Lol. I need another coffee. The should's needed to be above the post.
On Thu, Sep 18, 2008 at 3:23 PM, Tim Haines <tmhaines at gmail.com> wrote:
> Hi there,
> 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:
> before(:each) do
> @video_file = ActionController::TestUploadedFile.new(RAILS_ROOT +
> "/spec/fixtures/files/video.mpg", 'video/mp4')
> @thumb = "thumb"
> @original = "original"
> @vid = mock_video(:original_thumbnail => @thumb, :convert_path =>
> "convert_path", :still_path => "still_path", :original => @original)
> # @vid.stub!(:original=)
> # @vid.stub!(:save!)
> @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