[rspec-users] Controller specs erroneously loading views in edge rails?
Tim Haines
tmhaines at gmail.com
Tue Sep 2 18:41:22 EDT 2008
Hi guys,
After updating to edge rails I've just struck this problem too. I've just
grabbed fresh updates of rspec, rspec-rails, and rails and I'm receiving a
few controller spec failures related to view rendering when views shouldn't
be rendered (failures relate to mock objects not having expected attributes
and methods).
I've logged this in lighthouse ->
http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/516
Here's a copy of the full backtrace of one of the fails:
vendor/rails/actionpack/lib/action_controller/routing/route_set.rb:376:in
`raise_named_route_error'
vendor/rails/actionpack/lib/action_controller/routing/route_set.rb:340:in
`generate'
vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:208:in
`rewrite_path'
vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:187:in
`rewrite_url'
vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:165:in
`rewrite'
vendor/rails/actionpack/lib/action_controller/base.rb:630:in `url_for'
vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:85:in
`send'
vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:85:in
`url_for'
(eval):15:in `user_path'
vendor/rails/actionpack/lib/action_controller/polymorphic_routes.rb:111:in
`__send__'
vendor/rails/actionpack/lib/action_controller/polymorphic_routes.rb:111:in
`polymorphic_url'
vendor/rails/actionpack/lib/action_controller/polymorphic_routes.rb:118:in
`polymorphic_path'
vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:91:in
`url_for'
vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:228:in
`link_to'
app/views/home/index.html.erb:5
app/views/home/index.html.erb:4:in `each'
app/views/home/index.html.erb:4
vendor/rails/actionpack/lib/action_view/renderable.rb:35:in `send'
vendor/rails/actionpack/lib/action_view/renderable.rb:35:in `render'
vendor/rails/actionpack/lib/action_view/template.rb:68:in
`render_template'
vendor/rails/actionpack/lib/action_view/base.rb:266:in `orig_render'
vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_view/base.rb:26:in
`render'
vendor/rails/actionpack/lib/action_view/base.rb:369:in
`_render_with_layout'
vendor/rails/actionpack/lib/action_view/base.rb:260:in `orig_render'
vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_view/base.rb:26:in
`render'
vendor/rails/actionpack/lib/action_controller/base.rb:1118:in
`render_for_file'
vendor/rails/actionpack/lib/action_controller/base.rb:881:in
`render_without_benchmark'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in
`render'
vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:8:in
`realtime'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in
`render'
vendor/plugins/rspec-rails/lib/spec/rails/example/controller_example_group.rb:213:in
`render'
vendor/rails/actionpack/lib/action_controller/base.rb:853:in
`render_without_benchmark'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in
`render'
vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:8:in
`realtime'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in
`render'
vendor/plugins/rspec-rails/lib/spec/rails/example/controller_example_group.rb:213:in
`render'
vendor/rails/actionpack/lib/action_controller/base.rb:1170:in
`default_render'
vendor/rails/actionpack/lib/action_controller/base.rb:1176:in
`perform_action_without_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:617:in
`call_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:610:in
`perform_action_without_benchmark'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:293:in
`measure'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
vendor/rails/actionpack/lib/action_controller/rescue.rb:202:in
`perform_action_without_caching'
vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:13:in
`perform_action'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:48:in
`cache'
vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache'
vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:12:in
`perform_action'
vendor/rails/actionpack/lib/action_controller/base.rb:535:in `send'
vendor/rails/actionpack/lib/action_controller/base.rb:535:in
`process_without_filters'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in
`synchronize'
vendor/rails/actionpack/lib/action_controller/base.rb:535:in
`process_without_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:606:in
`process_without_session_management_support'
vendor/rails/actionpack/lib/action_controller/session_management.rb:130:in
`process_without_test'
vendor/rails/actionpack/lib/action_controller/test_process.rb:18:in
`process'
vendor/rails/actionpack/lib/action_controller/test_process.rb:400:in
`process'
vendor/rails/actionpack/lib/action_controller/test_process.rb:371:in
`get'
controllers/home_controller_spec.rb:12
vendor/plugins/rspec/lib/spec/example/example_methods.rb:83:in
`instance_eval'
vendor/plugins/rspec/lib/spec/example/example_methods.rb:83:in
`eval_block'
vendor/plugins/rspec/lib/spec/example/example_methods.rb:21:in `execute'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb:48:in
`timeout'
vendor/plugins/rspec/lib/spec/example/example_methods.rb:18:in `execute'
vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:305:in
`execute_examples'
vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:304:in
`each'
vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:304:in
`execute_examples'
vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:132:in
`run'
vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:22:in `run'
vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:21:in
`each'
vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:21:in `run'
vendor/plugins/rspec/lib/spec/runner/options.rb:115:in `run_examples'
vendor/plugins/rspec/lib/spec.rb:21:in `run'
vendor/plugins/rspec/lib/spec/runner.rb:192:in `register_at_exit_hook'
controllers/home_controller_spec
On Sun, Aug 24, 2008 at 8:57 AM, Sven Fuchs <svenfuchs at artweb-design.de>wrote:
> Ok, done.
>
>
> http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/508-recent-changes-in-actionpack-break-controller-specs
>
> Thanks!
>
>
> On 23.08.2008, at 16:28, David Chelimsky wrote:
>
> There are a number of changes to action pack recently that are
>> incompatible with rspec. Please report these to lighthouse.
>>
>> Thanks,
>> David
>>
>> On Sat, Aug 23, 2008 at 6:12 AM, Sven Fuchs <svenfuchs at artweb-design.de>
>> wrote:
>>
>>> 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)
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> rspec-users mailing list
>>> rspec-users at rubyforge.org
>>> http://rubyforge.org/mailman/listinfo/rspec-users
>>>
>>> _______________________________________________
>> 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)
>
>
>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20080903/235a99fc/attachment-0001.html>
More information about the rspec-users
mailing list