I''m banging my head over this really strange error in a view test when I run "rake spec". The weird thing is that I don''t get the error when I run the spec file by itself. Here is the spec (I know, fixtures are the devil): describe "/units/new.html.erb here" do fixtures :units, :accounts, :groups it_should_behave_like ''/units/_form'' before do login_as :cathy assigns[:unit] = @unit = Unit.new @groups = accounts(:dawson).groups render "/units/new.html" end it "should render new form" do response.should have_tag("form[action=?][method=post]", units_path) end end And the error: 4) ActionView::TemplateError in ''Spec::Rails::Example::ViewExampleGroup/ units/new.html.erb should render new form'' You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occurred while evaluating nil.include? On line #13 of units/_form.html.erb 10: <% unless @unit.root? -%> 11: <li> 12: <label for="unit_parent_id"><%=h ''Parent Unit''.t %></label> 13: <%= f.select :parent_id, [1,2,3] %> 14: <%#= f.select :parent_id, 15: nested_set_options_for_select(current_account.units.root) {|u| "#{''?'' * u.level} #{u.name}"} %> 16: </li> vendor/plugins/rspec/lib/spec/mocks/proxy.rb:71:in `send'' vendor/plugins/rspec/lib/spec/mocks/proxy.rb:71:in `message_received'' vendor/plugins/rspec/lib/spec/mocks/proxy.rb:100:in `include?'' vendor/rails/actionpack/lib/action_view/helpers/ form_options_helper.rb:304:in `option_value_selected?'' vendor/rails/actionpack/lib/action_view/helpers/ form_options_helper.rb:163:in `options_for_select'' vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb: 29:in `inject'' vendor/rails/actionpack/lib/action_view/helpers/ form_options_helper.rb:161:in `each'' vendor/rails/actionpack/lib/action_view/helpers/ form_options_helper.rb:161:in `inject'' vendor/rails/actionpack/lib/action_view/helpers/ form_options_helper.rb:161:in `options_for_select'' vendor/rails/actionpack/lib/action_view/helpers/ form_options_helper.rb:358:in `to_select_tag'' vendor/rails/actionpack/lib/action_view/helpers/ form_options_helper.rb:84:in `select'' vendor/rails/actionpack/lib/action_view/helpers/ form_options_helper.rb:409:in `select'' app/views//units/_form.html.erb:13:in `_run_47app47views47units47_form46html46erb'' vendor/rails/actionpack/lib/action_view/base.rb:390:in `send'' vendor/rails/actionpack/lib/action_view/base.rb:390:in `compile_and_render_template'' vendor/rails/actionpack/lib/action_view/base.rb:366:in `render_template'' vendor/rails/actionpack/lib/action_view/base.rb:316:in `globalize_old_render_file'' vendor/plugins/globalize/lib/globalize/rails/action_view.rb:18:in `render_file'' vendor/rails/actionpack/lib/action_view/base.rb:331:in `orig_render'' vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/ action_view/base.rb:22:in `render'' vendor/rails/actionpack/lib/action_view/partials.rb:117:in `render_partial'' vendor/rails/actionpack/lib/action_controller/benchmarking.rb: 26:in `benchmark'' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/1.8/benchmark.rb:293:in `measure'' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ ruby/1.8/benchmark.rb:307:in `realtime'' vendor/rails/actionpack/lib/action_controller/benchmarking.rb: 26:in `benchmark'' vendor/rails/actionpack/lib/action_view/partials.rb:116:in `render_partial'' vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/ action_view/base.rb:13:in `render_partial'' vendor/rails/actionpack/lib/action_view/base.rb:352:in `orig_render'' vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/ action_view/base.rb:22:in `render'' app/views//units/new.html.erb:6:in `_run_47app47views47units47new46html46erb'' vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb: 248:in `fields_for'' vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb: 184:in `form_for'' app/views//units/new.html.erb:5:in `_run_47app47views47units47new46html46erb'' vendor/rails/actionpack/lib/action_view/base.rb:390:in `send'' vendor/rails/actionpack/lib/action_view/base.rb:390:in `compile_and_render_template'' vendor/rails/actionpack/lib/action_view/base.rb:366:in `render_template'' vendor/rails/actionpack/lib/action_view/base.rb:316:in `globalize_old_render_file'' vendor/plugins/globalize/lib/globalize/rails/action_view.rb:18:in `render_file'' vendor/rails/actionpack/lib/action_controller/base.rb:1109:in `render_for_file'' vendor/rails/actionpack/lib/action_controller/base.rb:861:in `render_with_no_layout'' vendor/rails/actionpack/lib/action_controller/layout.rb:269:in `render_without_benchmark'' vendor/rails/actionpack/lib/action_controller/benchmarking.rb: 51:in `render'' /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: 51:in `render'' vendor/plugins/rspec_on_rails/lib/spec/rails/example/ view_example_group.rb:129:in `send'' vendor/plugins/rspec_on_rails/lib/spec/rails/example/ view_example_group.rb:129:in `render'' spec/views/units/new.html.erb_spec.rb:11 vendor/plugins/rspec/lib/spec/example/example_methods.rb:42:in `instance_eval'' vendor/plugins/rspec/lib/spec/example/example_methods.rb:42:in `eval_each_fail_fast'' vendor/plugins/rspec/lib/spec/example/example_methods.rb:41:in `each'' vendor/plugins/rspec/lib/spec/example/example_methods.rb:41:in `eval_each_fail_fast'' vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: 216:in `run_before_each'' vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: 316:in `execute_in_class_hierarchy'' vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: 315:in `each'' vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: 315:in `execute_in_class_hierarchy'' vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: 215:in `run_before_each'' vendor/plugins/rspec/lib/spec/example/example_methods.rb:65:in `before_example'' vendor/plugins/rspec/lib/spec/example/example_methods.rb:13: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:11:in `execute'' vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: 256:in `execute_examples'' vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: 254:in `each'' vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: 254:in `execute_examples'' vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: 115: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:85:in `run_examples'' vendor/plugins/rspec/lib/spec/runner/command_line.rb:19:in `run'' vendor/plugins/rspec/bin/spec:3 I''m not sure why the error is in the mock proxy because this spec isn''t using mocking at all. Any ideas? Brandon -------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 186 bytes Desc: This is a digitally signed message part Url : http://rubyforge.org/pipermail/rspec-users/attachments/20071207/1810c78e/attachment-0001.bin
I''m away from my computer right now so I can''t give you details, but I know that view examples use mocks under the hood for some things. On 12/7/07, Brandon Keepers <brandon at collectiveidea.com> wrote:> I''m banging my head over this really strange error in a view test when > I run "rake spec". The weird thing is that I don''t get the error when > I run the spec file by itself. > > Here is the spec (I know, fixtures are the devil): > > describe "/units/new.html.erb here" do > fixtures :units, :accounts, :groups > it_should_behave_like ''/units/_form'' > > before do > login_as :cathy > assigns[:unit] = @unit = Unit.new > @groups = accounts(:dawson).groups > render "/units/new.html" > end > > it "should render new form" do > response.should have_tag("form[action=?][method=post]", units_path) > end > > end > > And the error: > > 4) > ActionView::TemplateError in ''Spec::Rails::Example::ViewExampleGroup/ > units/new.html.erb should render new form'' > You have a nil object when you didn''t expect it! > You might have expected an instance of Array. > The error occurred while evaluating nil.include? > On line #13 of units/_form.html.erb > > 10: <% unless @unit.root? -%> > 11: <li> > 12: <label for="unit_parent_id"><%=h ''Parent Unit''.t %></label> > 13: <%= f.select :parent_id, [1,2,3] %> > 14: <%#= f.select :parent_id, > 15: nested_set_options_for_select(current_account.units.root) > {|u| "#{''?'' * u.level} #{u.name}"} %> > 16: </li> > > vendor/plugins/rspec/lib/spec/mocks/proxy.rb:71:in `send'' > vendor/plugins/rspec/lib/spec/mocks/proxy.rb:71:in > `message_received'' > vendor/plugins/rspec/lib/spec/mocks/proxy.rb:100:in `include?'' > vendor/rails/actionpack/lib/action_view/helpers/ > form_options_helper.rb:304:in `option_value_selected?'' > vendor/rails/actionpack/lib/action_view/helpers/ > form_options_helper.rb:163:in `options_for_select'' > vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb: > 29:in `inject'' > vendor/rails/actionpack/lib/action_view/helpers/ > form_options_helper.rb:161:in `each'' > vendor/rails/actionpack/lib/action_view/helpers/ > form_options_helper.rb:161:in `inject'' > vendor/rails/actionpack/lib/action_view/helpers/ > form_options_helper.rb:161:in `options_for_select'' > vendor/rails/actionpack/lib/action_view/helpers/ > form_options_helper.rb:358:in `to_select_tag'' > vendor/rails/actionpack/lib/action_view/helpers/ > form_options_helper.rb:84:in `select'' > vendor/rails/actionpack/lib/action_view/helpers/ > form_options_helper.rb:409:in `select'' > app/views//units/_form.html.erb:13:in > `_run_47app47views47units47_form46html46erb'' > vendor/rails/actionpack/lib/action_view/base.rb:390:in `send'' > vendor/rails/actionpack/lib/action_view/base.rb:390:in > `compile_and_render_template'' > vendor/rails/actionpack/lib/action_view/base.rb:366:in > `render_template'' > vendor/rails/actionpack/lib/action_view/base.rb:316:in > `globalize_old_render_file'' > vendor/plugins/globalize/lib/globalize/rails/action_view.rb:18:in > `render_file'' > vendor/rails/actionpack/lib/action_view/base.rb:331:in > `orig_render'' > vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/ > action_view/base.rb:22:in `render'' > vendor/rails/actionpack/lib/action_view/partials.rb:117:in > `render_partial'' > vendor/rails/actionpack/lib/action_controller/benchmarking.rb: > 26:in `benchmark'' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ > ruby/1.8/benchmark.rb:293:in `measure'' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ > ruby/1.8/benchmark.rb:307:in `realtime'' > vendor/rails/actionpack/lib/action_controller/benchmarking.rb: > 26:in `benchmark'' > vendor/rails/actionpack/lib/action_view/partials.rb:116:in > `render_partial'' > vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/ > action_view/base.rb:13:in `render_partial'' > vendor/rails/actionpack/lib/action_view/base.rb:352:in > `orig_render'' > vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/ > action_view/base.rb:22:in `render'' > app/views//units/new.html.erb:6:in > `_run_47app47views47units47new46html46erb'' > vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb: > 248:in `fields_for'' > vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb: > 184:in `form_for'' > app/views//units/new.html.erb:5:in > `_run_47app47views47units47new46html46erb'' > vendor/rails/actionpack/lib/action_view/base.rb:390:in `send'' > vendor/rails/actionpack/lib/action_view/base.rb:390:in > `compile_and_render_template'' > vendor/rails/actionpack/lib/action_view/base.rb:366:in > `render_template'' > vendor/rails/actionpack/lib/action_view/base.rb:316:in > `globalize_old_render_file'' > vendor/plugins/globalize/lib/globalize/rails/action_view.rb:18:in > `render_file'' > vendor/rails/actionpack/lib/action_controller/base.rb:1109:in > `render_for_file'' > vendor/rails/actionpack/lib/action_controller/base.rb:861:in > `render_with_no_layout'' > vendor/rails/actionpack/lib/action_controller/layout.rb:269:in > `render_without_benchmark'' > vendor/rails/actionpack/lib/action_controller/benchmarking.rb: > 51:in `render'' > /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: > 51:in `render'' > vendor/plugins/rspec_on_rails/lib/spec/rails/example/ > view_example_group.rb:129:in `send'' > vendor/plugins/rspec_on_rails/lib/spec/rails/example/ > view_example_group.rb:129:in `render'' > spec/views/units/new.html.erb_spec.rb:11 > vendor/plugins/rspec/lib/spec/example/example_methods.rb:42:in > `instance_eval'' > vendor/plugins/rspec/lib/spec/example/example_methods.rb:42:in > `eval_each_fail_fast'' > vendor/plugins/rspec/lib/spec/example/example_methods.rb:41:in > `each'' > vendor/plugins/rspec/lib/spec/example/example_methods.rb:41:in > `eval_each_fail_fast'' > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: > 216:in `run_before_each'' > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: > 316:in `execute_in_class_hierarchy'' > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: > 315:in `each'' > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: > 315:in `execute_in_class_hierarchy'' > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: > 215:in `run_before_each'' > vendor/plugins/rspec/lib/spec/example/example_methods.rb:65:in > `before_example'' > vendor/plugins/rspec/lib/spec/example/example_methods.rb:13: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:11:in > `execute'' > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: > 256:in `execute_examples'' > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: > 254:in `each'' > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: > 254:in `execute_examples'' > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: > 115: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:85:in > `run_examples'' > vendor/plugins/rspec/lib/spec/runner/command_line.rb:19:in `run'' > vendor/plugins/rspec/bin/spec:3 > > > I''m not sure why the error is in the mock proxy because this spec > isn''t using mocking at all. > > Any ideas? > > Brandon
David, Did you ever get a chance to look at this to see if I am missing something obvious. I''m getting these errors randomly. Brandon On Dec 7, 2007, at 11:42 AM, Brandon Keepers wrote:> I''m banging my head over this really strange error in a view test > when I run "rake spec". The weird thing is that I don''t get the > error when I run the spec file by itself. > > Here is the spec (I know, fixtures are the devil): > > describe "/units/new.html.erb here" do > fixtures :units, :accounts, :groups > it_should_behave_like ''/units/_form'' > > before do > login_as :cathy > assigns[:unit] = @unit = Unit.new > @groups = accounts(:dawson).groups > render "/units/new.html" > end > > it "should render new form" do > response.should have_tag("form[action=?][method=post]", units_path) > end > > end > > And the error: > > 4) > ActionView::TemplateError in ''Spec::Rails::Example::ViewExampleGroup/ > units/new.html.erb should render new form'' > You have a nil object when you didn''t expect it! > You might have expected an instance of Array. > The error occurred while evaluating nil.include? > On line #13 of units/_form.html.erb > > 10: <% unless @unit.root? -%> > 11: <li> > 12: <label for="unit_parent_id"><%=h ''Parent Unit''.t %></label> > 13: <%= f.select :parent_id, [1,2,3] %> > 14: <%#= f.select :parent_id, > 15: nested_set_options_for_select(current_account.units.root) > {|u| "#{''?'' * u.level} #{u.name}"} %> > 16: </li> > > vendor/plugins/rspec/lib/spec/mocks/proxy.rb:71:in `send'' > vendor/plugins/rspec/lib/spec/mocks/proxy.rb:71:in > `message_received'' > vendor/plugins/rspec/lib/spec/mocks/proxy.rb:100:in `include?'' > vendor/rails/actionpack/lib/action_view/helpers/ > form_options_helper.rb:304:in `option_value_selected?'' > vendor/rails/actionpack/lib/action_view/helpers/ > form_options_helper.rb:163:in `options_for_select'' > vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb: > 29:in `inject'' > vendor/rails/actionpack/lib/action_view/helpers/ > form_options_helper.rb:161:in `each'' > vendor/rails/actionpack/lib/action_view/helpers/ > form_options_helper.rb:161:in `inject'' > vendor/rails/actionpack/lib/action_view/helpers/ > form_options_helper.rb:161:in `options_for_select'' > vendor/rails/actionpack/lib/action_view/helpers/ > form_options_helper.rb:358:in `to_select_tag'' > vendor/rails/actionpack/lib/action_view/helpers/ > form_options_helper.rb:84:in `select'' > vendor/rails/actionpack/lib/action_view/helpers/ > form_options_helper.rb:409:in `select'' > app/views//units/_form.html.erb:13:in > `_run_47app47views47units47_form46html46erb'' > vendor/rails/actionpack/lib/action_view/base.rb:390:in `send'' > vendor/rails/actionpack/lib/action_view/base.rb:390:in > `compile_and_render_template'' > vendor/rails/actionpack/lib/action_view/base.rb:366:in > `render_template'' > vendor/rails/actionpack/lib/action_view/base.rb:316:in > `globalize_old_render_file'' > vendor/plugins/globalize/lib/globalize/rails/action_view.rb:18:in > `render_file'' > vendor/rails/actionpack/lib/action_view/base.rb:331:in > `orig_render'' > vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/ > action_view/base.rb:22:in `render'' > vendor/rails/actionpack/lib/action_view/partials.rb:117:in > `render_partial'' > vendor/rails/actionpack/lib/action_controller/benchmarking.rb: > 26:in `benchmark'' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ > ruby/1.8/benchmark.rb:293:in `measure'' > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ > ruby/1.8/benchmark.rb:307:in `realtime'' > vendor/rails/actionpack/lib/action_controller/benchmarking.rb: > 26:in `benchmark'' > vendor/rails/actionpack/lib/action_view/partials.rb:116:in > `render_partial'' > vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/ > action_view/base.rb:13:in `render_partial'' > vendor/rails/actionpack/lib/action_view/base.rb:352:in > `orig_render'' > vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/ > action_view/base.rb:22:in `render'' > app/views//units/new.html.erb:6:in > `_run_47app47views47units47new46html46erb'' > vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb: > 248:in `fields_for'' > vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb: > 184:in `form_for'' > app/views//units/new.html.erb:5:in > `_run_47app47views47units47new46html46erb'' > vendor/rails/actionpack/lib/action_view/base.rb:390:in `send'' > vendor/rails/actionpack/lib/action_view/base.rb:390:in > `compile_and_render_template'' > vendor/rails/actionpack/lib/action_view/base.rb:366:in > `render_template'' > vendor/rails/actionpack/lib/action_view/base.rb:316:in > `globalize_old_render_file'' > vendor/plugins/globalize/lib/globalize/rails/action_view.rb:18:in > `render_file'' > vendor/rails/actionpack/lib/action_controller/base.rb:1109:in > `render_for_file'' > vendor/rails/actionpack/lib/action_controller/base.rb:861:in > `render_with_no_layout'' > vendor/rails/actionpack/lib/action_controller/layout.rb:269:in > `render_without_benchmark'' > vendor/rails/actionpack/lib/action_controller/benchmarking.rb: > 51:in `render'' > /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: > 51:in `render'' > vendor/plugins/rspec_on_rails/lib/spec/rails/example/ > view_example_group.rb:129:in `send'' > vendor/plugins/rspec_on_rails/lib/spec/rails/example/ > view_example_group.rb:129:in `render'' > spec/views/units/new.html.erb_spec.rb:11 > vendor/plugins/rspec/lib/spec/example/example_methods.rb:42:in > `instance_eval'' > vendor/plugins/rspec/lib/spec/example/example_methods.rb:42:in > `eval_each_fail_fast'' > vendor/plugins/rspec/lib/spec/example/example_methods.rb:41:in > `each'' > vendor/plugins/rspec/lib/spec/example/example_methods.rb:41:in > `eval_each_fail_fast'' > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: > 216:in `run_before_each'' > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: > 316:in `execute_in_class_hierarchy'' > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: > 315:in `each'' > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: > 315:in `execute_in_class_hierarchy'' > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: > 215:in `run_before_each'' > vendor/plugins/rspec/lib/spec/example/example_methods.rb:65:in > `before_example'' > vendor/plugins/rspec/lib/spec/example/example_methods.rb:13: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:11:in > `execute'' > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: > 256:in `execute_examples'' > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: > 254:in `each'' > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: > 254:in `execute_examples'' > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: > 115: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:85:in > `run_examples'' > vendor/plugins/rspec/lib/spec/runner/command_line.rb:19:in `run'' > vendor/plugins/rspec/bin/spec:3 > > > I''m not sure why the error is in the mock proxy because this spec > isn''t using mocking at all. > > Any ideas? > > Brandon-------------- next part -------------- A non-text attachment was scrubbed... Name: PGP.sig Type: application/pgp-signature Size: 186 bytes Desc: This is a digitally signed message part Url : http://rubyforge.org/pipermail/rspec-users/attachments/20071210/9f83d4bc/attachment.bin
On Dec 10, 2007 11:42 AM, Brandon Keepers <brandon at collectiveidea.com> wrote:> David, > > Did you ever get a chance to look at this to see if I am missing > something obvious. I''m getting these errors randomly.Haven''t yet. Anybody else on this list having a similar experience?> > Brandon > > > On Dec 7, 2007, at 11:42 AM, Brandon Keepers wrote: > > > I''m banging my head over this really strange error in a view test > > when I run "rake spec". The weird thing is that I don''t get the > > error when I run the spec file by itself. > > > > Here is the spec (I know, fixtures are the devil): > > > > describe "/units/new.html.erb here" do > > fixtures :units, :accounts, :groups > > it_should_behave_like ''/units/_form'' > > > > before do > > login_as :cathy > > assigns[:unit] = @unit = Unit.new > > @groups = accounts(:dawson).groups > > render "/units/new.html" > > end > > > > it "should render new form" do > > response.should have_tag("form[action=?][method=post]", units_path) > > end > > > > end > > > > And the error: > > > > 4) > > ActionView::TemplateError in ''Spec::Rails::Example::ViewExampleGroup/ > > units/new.html.erb should render new form'' > > You have a nil object when you didn''t expect it! > > You might have expected an instance of Array. > > The error occurred while evaluating nil.include? > > On line #13 of units/_form.html.erb > > > > 10: <% unless @unit.root? -%> > > 11: <li> > > 12: <label for="unit_parent_id"><%=h ''Parent Unit''.t %></label> > > 13: <%= f.select :parent_id, [1,2,3] %> > > 14: <%#= f.select :parent_id, > > 15: nested_set_options_for_select(current_account.units.root) > > {|u| "#{''?'' * u.level} #{u.name}"} %> > > 16: </li> > > > > vendor/plugins/rspec/lib/spec/mocks/proxy.rb:71:in `send'' > > vendor/plugins/rspec/lib/spec/mocks/proxy.rb:71:in > > `message_received'' > > vendor/plugins/rspec/lib/spec/mocks/proxy.rb:100:in `include?'' > > vendor/rails/actionpack/lib/action_view/helpers/ > > form_options_helper.rb:304:in `option_value_selected?'' > > vendor/rails/actionpack/lib/action_view/helpers/ > > form_options_helper.rb:163:in `options_for_select'' > > vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb: > > 29:in `inject'' > > vendor/rails/actionpack/lib/action_view/helpers/ > > form_options_helper.rb:161:in `each'' > > vendor/rails/actionpack/lib/action_view/helpers/ > > form_options_helper.rb:161:in `inject'' > > vendor/rails/actionpack/lib/action_view/helpers/ > > form_options_helper.rb:161:in `options_for_select'' > > vendor/rails/actionpack/lib/action_view/helpers/ > > form_options_helper.rb:358:in `to_select_tag'' > > vendor/rails/actionpack/lib/action_view/helpers/ > > form_options_helper.rb:84:in `select'' > > vendor/rails/actionpack/lib/action_view/helpers/ > > form_options_helper.rb:409:in `select'' > > app/views//units/_form.html.erb:13:in > > `_run_47app47views47units47_form46html46erb'' > > vendor/rails/actionpack/lib/action_view/base.rb:390:in `send'' > > vendor/rails/actionpack/lib/action_view/base.rb:390:in > > `compile_and_render_template'' > > vendor/rails/actionpack/lib/action_view/base.rb:366:in > > `render_template'' > > vendor/rails/actionpack/lib/action_view/base.rb:316:in > > `globalize_old_render_file'' > > vendor/plugins/globalize/lib/globalize/rails/action_view.rb:18:in > > `render_file'' > > vendor/rails/actionpack/lib/action_view/base.rb:331:in > > `orig_render'' > > vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/ > > action_view/base.rb:22:in `render'' > > vendor/rails/actionpack/lib/action_view/partials.rb:117:in > > `render_partial'' > > vendor/rails/actionpack/lib/action_controller/benchmarking.rb: > > 26:in `benchmark'' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ > > ruby/1.8/benchmark.rb:293:in `measure'' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ > > ruby/1.8/benchmark.rb:307:in `realtime'' > > vendor/rails/actionpack/lib/action_controller/benchmarking.rb: > > 26:in `benchmark'' > > vendor/rails/actionpack/lib/action_view/partials.rb:116:in > > `render_partial'' > > vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/ > > action_view/base.rb:13:in `render_partial'' > > vendor/rails/actionpack/lib/action_view/base.rb:352:in > > `orig_render'' > > vendor/plugins/rspec_on_rails/lib/spec/rails/extensions/ > > action_view/base.rb:22:in `render'' > > app/views//units/new.html.erb:6:in > > `_run_47app47views47units47new46html46erb'' > > vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb: > > 248:in `fields_for'' > > vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb: > > 184:in `form_for'' > > app/views//units/new.html.erb:5:in > > `_run_47app47views47units47new46html46erb'' > > vendor/rails/actionpack/lib/action_view/base.rb:390:in `send'' > > vendor/rails/actionpack/lib/action_view/base.rb:390:in > > `compile_and_render_template'' > > vendor/rails/actionpack/lib/action_view/base.rb:366:in > > `render_template'' > > vendor/rails/actionpack/lib/action_view/base.rb:316:in > > `globalize_old_render_file'' > > vendor/plugins/globalize/lib/globalize/rails/action_view.rb:18:in > > `render_file'' > > vendor/rails/actionpack/lib/action_controller/base.rb:1109:in > > `render_for_file'' > > vendor/rails/actionpack/lib/action_controller/base.rb:861:in > > `render_with_no_layout'' > > vendor/rails/actionpack/lib/action_controller/layout.rb:269:in > > `render_without_benchmark'' > > vendor/rails/actionpack/lib/action_controller/benchmarking.rb: > > 51:in `render'' > > /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: > > 51:in `render'' > > vendor/plugins/rspec_on_rails/lib/spec/rails/example/ > > view_example_group.rb:129:in `send'' > > vendor/plugins/rspec_on_rails/lib/spec/rails/example/ > > view_example_group.rb:129:in `render'' > > spec/views/units/new.html.erb_spec.rb:11 > > vendor/plugins/rspec/lib/spec/example/example_methods.rb:42:in > > `instance_eval'' > > vendor/plugins/rspec/lib/spec/example/example_methods.rb:42:in > > `eval_each_fail_fast'' > > vendor/plugins/rspec/lib/spec/example/example_methods.rb:41:in > > `each'' > > vendor/plugins/rspec/lib/spec/example/example_methods.rb:41:in > > `eval_each_fail_fast'' > > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: > > 216:in `run_before_each'' > > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: > > 316:in `execute_in_class_hierarchy'' > > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: > > 315:in `each'' > > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: > > 315:in `execute_in_class_hierarchy'' > > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: > > 215:in `run_before_each'' > > vendor/plugins/rspec/lib/spec/example/example_methods.rb:65:in > > `before_example'' > > vendor/plugins/rspec/lib/spec/example/example_methods.rb:13: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:11:in > > `execute'' > > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: > > 256:in `execute_examples'' > > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: > > 254:in `each'' > > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: > > 254:in `execute_examples'' > > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb: > > 115: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:85:in > > `run_examples'' > > vendor/plugins/rspec/lib/spec/runner/command_line.rb:19:in `run'' > > vendor/plugins/rspec/bin/spec:3 > > > > > > I''m not sure why the error is in the mock proxy because this spec > > isn''t using mocking at all. > > > > Any ideas? > > > > Brandon > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On 12/10/07 6:55 PM, "David Chelimsky" <dchelimsky at gmail.com> wrote:> On Dec 10, 2007 11:42 AM, Brandon Keepers <brandon at collectiveidea.com> wrote: >> David, >> >> Did you ever get a chance to look at this to see if I am missing >> something obvious. I''m getting these errors randomly. > > Haven''t yet. Anybody else on this list having a similar experience?I''ve also been getting very confused with specs failing with rake:spec but passing when running focused examples (e.g.from textmate). This is without fixtures but using mocks. It''s as if the mocks were somehow remembering the should_receive declarations between specs. They didn''t seem to get updated. Turned out I made a mistake a using partial mocks namely trying to set should_receive on the real object instead of the mock. This mistakes somehow only became apparent when running with rake:spec. I''m using flexmock 0.8, rspec plugin 1.08 with rails 1.2.6 I''m pretty sure I still get some failures in a rake:spec but not in isolation, I''ll post examples when I run into them again Jeroen P.s. I had to read this bit a few times before understanding partial mocking with flexmock: "If you you give flexmock a real object in the argument list, it will treat that real object as a base for a partial mock object. The return value m may be used to set expectations. The real_object should be used in the reference portion of the test." http://onestepback.org/software/flexmock/