[rspec-devel] [ rspec-Bugs-13713 ] form helper method 'select' can not be called when calling custom helper methods from specs

noreply at rubyforge.org noreply at rubyforge.org
Thu Sep 6 09:15:49 EDT 2007


Bugs item #13713, was opened at 2007-09-06 10:55
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=13713&group_id=797

Category: rails plugin
Group: None
>Status: Closed
>Resolution: Accepted
Priority: 3
Submitted By: Juha Suuraho (juhazi)
>Assigned to: David Chelimsky (dchelimsky)
Summary: form helper method 'select' can not be called when calling custom helper methods from specs

Initial Comment:
Method select from ActionView::Helpers::FormOptionsHelper cannot be called from helper specs.

helper code:
  def return_a_select
    select(:test_object, :test_method, ["1",1])
  end

spec code:
  it "should return a select input tag" do
    return_a_select.should_not be_nil
  end

result:
  ArgumentError in 'CompaniesHelper should return a select input tag'
  wrong number of arguments (3 for 1)

suggested reason:
  in /vendor/plugins/rspec_on_rails/lib/spec/rails/dsl/behaviour/helper.rb:
+++++++++++++++++++++++++++++++++++++++
          module ExampleMethods
.....
          include ActionView::Helpers::FormHelper
          include ActionView::Helpers::FormOptionsHelper
          include ActionView::Helpers::FormTagHelper
.....
          include ActionView::Helpers::PrototypeHelper
          include ActionView::Helpers::PrototypeHelper::JavaScriptGenerator::GeneratorMethods
          include ActionView::Helpers::ScriptaculousHelper
++++++++++++++++++++++++++++++++++++++++
as you can see FormOptionsHelper is included before PrototypeHelper::JavaScriptGenerator::GeneratorMethods, which in my opinion results in the select helper method from latter to overwrite the former.

I'm not sure how this could be fixed if the latter helper module is by default included in all helpers.

----------------------------------------------------------------------

>Comment By: David Chelimsky (dchelimsky)
Date: 2007-09-06 13:15

Message:
I believe that you are correct. Looking at the way Rails includes these helpers in ActionView::Base, it does not get included automatically.

I've removed ActionView::Helpers::PrototypeHelper::JavaScriptGenerator:
:GeneratorMethods.

Fixed in r2527



----------------------------------------------------------------------

Comment By: Juha Suuraho (juhazi)
Date: 2007-09-06 12:47

Message:
After more research, atleast this particular
helper(ActionView::Helpers::PrototypeHelper::JavaScriptGenerator::GeneratorMethods)
are not meant to be included in the default helper scope,
but to be used inside a javascript generating block, like:

update_page do |page|
  page.select('some_id')
end

atleast this module should be removed from the include list.

----------------------------------------------------------------------

Comment By: David Chelimsky (dchelimsky)
Date: 2007-09-06 11:35

Message:
The javascript helpers are a recent addition and seem to be causing trouble. Maybe we should yank them. If you need them in a spec, you can always include them yourself.

Thoughts?

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=13713&group_id=797


More information about the rspec-devel mailing list