Forum: RSpec Problem with testing helper

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ivo D. (Guest)
on 2008-12-30 17:39
(Received via mailing list)
Hi

I bumped into a problem and tracked it down to this:

Form tag helpers in helpers do not seem to be testable. The helper
does actually work like it should if used in a view.

Example:

This helper:
#############
def form_builder
   form_tag "foo" do
     text_field_tag("bar")
   end
end


And this spec:
#############
it "should make a form" do
   form_builder.should have_tag("form")
end


throws:
#############
undefined method `output_buffer=' for
#<Spec::Rails::Example::HelperExampleGroup::Subclass_1:0x2670ac8>


with trace:
#############
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_controller/
test_process.rb:471:in `method_missing'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_view/helpers/
capture_helper.rb:132:in `with_output_buffer'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_view/helpers/
capture_helper.rb:39:in `capture'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_view/helpers/
form_tag_helper.rb:460:in `form_tag_in_block'
/Library/Ruby/Gems/1.8/gems/actionpack-2.2.2/lib/action_view/helpers/
form_tag_helper.rb:39:in `form_tag'


rspec and rspec-rails 1.1.11, rails 2.2.2

Any clues?

Thanks
-c
David C. (Guest)
on 2008-12-30 17:43
(Received via mailing list)
On Tue, Dec 30, 2008 at 9:14 AM, Ivo D.
<removed_email_address@domain.invalid> wrote:
> #############
>  form_builder.should have_tag("form")
> #############
>
>
> rspec and rspec-rails 1.1.11, rails 2.2.2
>
> Any clues?

Please file a bug report at http://rspec.lighthouseapp.com

Thx,
David
Ivo D. (Guest)
on 2008-12-30 18:23
(Received via mailing list)
Done:

http://rspec.lighthouseapp.com/projects/5645-rspec...

Regards
-c

Op 30-dec-08, om 16:41 heeft David C. het volgende geschreven:
This topic is locked and can not be replied to.