[rspec-users] Controller specs erroneously loading views in edge rails?

John Reilly john.j.reilly at gmail.com
Fri Aug 22 18:30:18 EDT 2008


I think I may have found a bug between rspec and edge rails... But I'm
new to this so I'm hoping someone else can confirm before I go filing
bug reports.

Basically, I'm seeing what "appears" to be my controller specs
deciding to load the views, even though I haven't called
integrate_views.  When I generate a default rspec_scaffold, the specs
fail with an ActionView::TemplateError:

>  % script/generate rspec_scaffold Bike name:string sku:string
>  ...
>  rake spec
>  ...
>  Mock 'Bike_1017' received unexpected message :name with (no args)
>  On line #11 of app/views/index.html.erb

If I modify the generated index spec like this, the spec passes:

> it "should expose all bikes as @bikes" do
>   Bike.should_receive(:find).with(:all).and_return([mock_bike])
>   # adding these lines cause the spec to pass...
>   mock_bike.should_receive(:name)
>   mock_bike.should_receive(:sku)
>   get :index
>   assigns[:bikes].should == [mock_bike]
> end

While this "fixes" the failures, it's no longer an isolated test of
the controller.

After spending some time with git-bisect, it looks like this problem
was introduced in a commit to edge rails:

The default rspec_scaffold tests pass before this commit, and fail
after this commit.

More details here:

Am I insane? Or does this happen for anyone else? :-)

-- John Reilly

More information about the rspec-users mailing list