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

Sven Fuchs svenfuchs at artweb-design.de
Sat Aug 23 07:12:34 EDT 2008


Trying to port an existing app to current Rails edge I've seen similar  
things yesterday. I've also updated RSpec/Rails to recent edge.

Here are two workarounds I've come up with for two of the problems.  
I'm not sure if they cause other problems themselves, but maybe  
they're still useful as a hint.

http://pastie.org/private/5ueehxiqhdgok0d8udksa

I don't feel familiar enough with RSpec's guts to provide a patch.

#render_partial on ActionView::Base seems to break because the method  
signature has changed.
#render on ControllerExampleGroup seems to break because #render_file  
apparently has been removed.



On 23.08.2008, at 00:30, John Reilly wrote:

> Hello,
>
> 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:
>
> ...snip...
>> 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
> ...snip...
>
> 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:
> http://github.com/rails/rails/commit/1129a24caff9f1804c2bff6569c0cbd8598dfa86
>
> The default rspec_scaffold tests pass before this commit, and fail
> after this commit.
>
> More details here:
> http://johnreilly.tumblr.com/post/47016047/rspec-is-mocking-me
>
> Am I insane? Or does this happen for anyone else? :-)
>
> Thanks,
> -- John Reilly
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

--
sven fuchs		svenfuchs at artweb-design.de
artweb design		http://www.artweb-design.de
grünberger 65		+ 49 (0) 30 - 47 98 69 96 (phone)
d-10245 berlin		+ 49 (0) 171 - 35 20 38 4 (mobile)






More information about the rspec-users mailing list