karmacoma
2009-Mar-07 15:49 UTC
[rspec-users] Rails 2.2.2 Problem - button_to_function - nil.with_output_buffer
Hi, I am in the process of upgrading my rails application to be compatible with rails 2.2.2. All is going well apart from a few remaining issues. My problem is: I am experiencing a test failure with what seems to be related to the "with_output_buffer" method found in "lib/action_view/ helpers/capture_helper.rb" and my use of the "button_to_function" method. The code itself works fine. It is simply the test itself that won''t pass due to a NoMethodError exception. Note: I am currently using rspec & rspec-rails (1.1.99.12), although the same problem also exists when tested with the current stable version: 1.1.12. So, given the following helper module: --- module ImagesHelper def hide_images_button content_tag :div, :class => :hide_images_button do button_to_function "Hide Images", :id => :hide_images_button do | page| page[:more_images_button].toggle page[:image_browser].toggle end end end end --- With the accompanying test: --- require File.expand_path(File.dirname(__FILE__) + ''/../spec_helper'') describe ImagesHelper do it "should render a hide_images_button" do helper.hide_images_button.should have_tag(''div[class=?]'', ''hide_images_button'') do with_tag(''input[id=?][type=?][value=?][onclick^=?]'', ''hide_images_button'', ''button'', ''Hide Images'', "$ ("more_images_button").toggle();\n$ ("image_browser").toggle();;") end end end --- I am getting the following failure: --- F 1) NoMethodError in ''ImagesHelper should render a hide_images_button'' You have a nil object when you didn''t expect it! The error occurred while evaluating nil.with_output_buffer /home/oliver/git/greyville/app/helpers/images_helper.rb:4:in `hide_images_button'' /home/oliver/git/greyville/app/helpers/images_helper.rb:3:in `hide_images_button'' spec/helpers/images_helper_spec.rb:5: Finished in 0.025206 seconds 1 example, 1 failure --- Any bright ideas on how I can fix this issue? Your help would be much appreciated. Regards, Oliver Beddows.
karmacoma
2009-Mar-09 09:44 UTC
[rspec-users] Rails 2.2.2 Problem - button_to_function - nil.with_output_buffer
Hi, I am in the process of upgrading my rails application to be compatible with rails 2.2.2. All is going well apart from a few remaining issues. My problem is: I am experiencing a test failure with what seems to be related to the "with_output_buffer" method found in "lib/action_view/ helpers/capture_helper.rb" and my use of the "button_to_function" method. The code itself works fine. It is simply the test itself that won''t pass due to a NoMethodError exception. Note: I am currently using rspec & rspec-rails (1.1.99.12), although the same problem also exists when tested with the current stable version: 1.1.12. So, given the following helper module: --- module ImagesHelper def hide_images_button content_tag :div, :class => :hide_images_button do button_to_function "Hide Images", :id => :hide_images_button do | page| page[:more_images_button].toggle page[:image_browser].toggle end end end end --- With the accompanying test: --- require File.expand_path(File.dirname(__FILE__) + ''/../spec_helper'') describe ImagesHelper do it "should render a hide_images_button" do helper.hide_images_button.should have_tag(''div[class=?]'', ''hide_images_button'') do with_tag(''input[id=?][type=?][value=?][onclick^=?]'', ''hide_images_button'', ''button'', ''Hide Images'', "$ ("more_images_button").toggle();\n$ ("image_browser").toggle();;") end end end --- I am getting the following failure: --- F 1) NoMethodError in ''ImagesHelper should render a hide_images_button'' You have a nil object when you didn''t expect it! The error occurred while evaluating nil.with_output_buffer /home/oliver/git/greyville/app/helpers/images_helper.rb:4:in `hide_images_button'' /home/oliver/git/greyville/app/helpers/images_helper.rb:3:in `hide_images_button'' spec/helpers/images_helper_spec.rb:5: Finished in 0.025206 seconds 1 example, 1 failure --- Any bright ideas on how I can fix this issue? Your help would be much appreciated. Regards, Oliver Beddows.
David Chelimsky
2009-Mar-09 11:25 UTC
[rspec-users] Rails 2.2.2 Problem - button_to_function - nil.with_output_buffer
On Mon, Mar 9, 2009 at 4:44 AM, karmacoma <oliver.beddows at googlemail.com> wrote:> Hi, > I am in the process of upgrading my rails application to be compatible > with rails 2.2.2. All is going well apart from a few remaining issues. > > My problem is: I am experiencing a test failure with what seems to be > related to the "with_output_buffer" method found in "lib/action_view/ > helpers/capture_helper.rb" and my use of the "button_to_function" > method. > > The code itself works fine. It is simply the test itself that won''t > pass due to a NoMethodError exception. > > Note: I am currently using rspec & rspec-rails (1.1.99.12), although > the same problem also exists when tested with the current stable > version: 1.1.12. > > So, given the following helper module: > --- > module ImagesHelper > ?def hide_images_button > ? content_tag :div, :class => :hide_images_button do > ? ? button_to_function "Hide Images", :id => :hide_images_button do | > page| > ? ? ? page[:more_images_button].toggle > ? ? ? page[:image_browser].toggle > ? ? end > ? end > ?end > end > --- > > With the accompanying test: > --- > require File.expand_path(File.dirname(__FILE__) + ''/../spec_helper'') > > describe ImagesHelper do > ?it "should render a hide_images_button" do > ? helper.hide_images_button.should have_tag(''div[class=?]'', > ''hide_images_button'') do > ? ? with_tag(''input[id=?][type=?][value=?][onclick^=?]'', > ''hide_images_button'', ''button'', ''Hide Images'', "$ > ("more_images_button").toggle();\n$ > ("image_browser").toggle();;") > ? end > ?end > end > --- > > I am getting the following failure: > --- > F > > 1) > NoMethodError in ''ImagesHelper should render a hide_images_button'' > You have a nil object when you didn''t expect it! > The error occurred while evaluating nil.with_output_buffer > /home/oliver/git/greyville/app/helpers/images_helper.rb:4:in > `hide_images_button'' > /home/oliver/git/greyville/app/helpers/images_helper.rb:3:in > `hide_images_button'' > spec/helpers/images_helper_spec.rb:5: > > Finished in 0.025206 seconds > > 1 example, 1 failure > --- > > Any bright ideas on how I can fix this issue? Your help would be much > appreciated.Please report bugs to http://rspec.lighthouseapp.com. Cheers, David> Regards, Oliver Beddows.
David Chelimsky
2009-Mar-13 04:43 UTC
[rspec-users] Rails 2.2.2 Problem - button_to_function - nil.with_output_buffer
On Sat, Mar 7, 2009 at 10:49 AM, karmacoma <oliver.beddows at googlemail.com> wrote:> Hi, > I am in the process of upgrading my rails application to be compatible > with rails 2.2.2. All is going well apart from a few remaining issues. > > My problem is: I am experiencing a test failure with what seems to be > related to the "with_output_buffer" method found in "lib/action_view/ > helpers/capture_helper.rb" and my use of the "button_to_function" > method. > > The code itself works fine. It is simply the test itself that won''t > pass due to a NoMethodError exception. > > Note: I am currently using rspec & rspec-rails (1.1.99.12), although > the same problem also exists when tested with the current stable > version: 1.1.12. > > So, given the following helper module: > --- > module ImagesHelper > ?def hide_images_button > ? ?content_tag :div, :class => :hide_images_button do > ? ? ?button_to_function "Hide Images", :id => :hide_images_button do | > page| > ? ? ? ?page[:more_images_button].toggle > ? ? ? ?page[:image_browser].toggle > ? ? ?end > ? ?end > ?end > end > --- > > With the accompanying test: > --- > require File.expand_path(File.dirname(__FILE__) + ''/../spec_helper'') > > describe ImagesHelper do > ?it "should render a hide_images_button" do > ? ?helper.hide_images_button.should have_tag(''div[class=?]'', > ''hide_images_button'') do > ? ? ?with_tag(''input[id=?][type=?][value=?][onclick^=?]'', > ''hide_images_button'', ''button'', ''Hide Images'', "$ > ("more_images_button").toggle();\n$ > ("image_browser").toggle();;") > ? ?end > ?end > end > --- > > I am getting the following failure: > --- > F > > 1) > NoMethodError in ''ImagesHelper should render a hide_images_button'' > You have a nil object when you didn''t expect it! > The error occurred while evaluating nil.with_output_buffer > /home/oliver/git/greyville/app/helpers/images_helper.rb:4:in > `hide_images_button'' > /home/oliver/git/greyville/app/helpers/images_helper.rb:3:in > `hide_images_button'' > spec/helpers/images_helper_spec.rb:5: > > Finished in 0.025206 seconds > > 1 example, 1 failure > --- > > Any bright ideas on how I can fix this issue? Your help would be much > appreciated.This was reported in lighthouse: http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/719 And fixed: http://github.com/dchelimsky/rspec-rails/commit/804f8cbc0468b1fe632cfb6c488de28d0ed39155 If you follow the instructions on http://wiki.github.com/dchelimsky/rspec/edge and build 1.1.9.13 or .14 or just edge, you''ll be fine.> Regards, Oliver Beddows. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >