On Tuesday, December 4, 2012 8:25:35 PM UTC-8, macarthy wrote: > > > > > Here is the backtrace , I'm using :type => :helper since my formbuilder is > in the li directory > > Thanks > > ----- output ---- > > StandardFormBuilder > standard fields > should build input fields (FAILED - 1) > > Failures: > > 1) StandardFormBuilder standard fields should build input fields > Failure/Error: Unable to find matching line from backtrace > TypeError: > wrong argument type Class (expected Module) > # > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.13/lib/abstract_controller/helpers.rb:123:in > > `include' > # > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.13/lib/abstract_controller/helpers.rb:123:in > > `block in add_template_helper' > # > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.13/lib/abstract_controller/helpers.rb:123:in > > `module_eval' > # > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.13/lib/abstract_controller/helpers.rb:123:in > > `add_template_helper' > # > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.13/lib/abstract_controller/helpers.rb:98:in > > `block in helper' > # > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.13/lib/abstract_controller/helpers.rb:97:in > > `each' > # > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.13/lib/abstract_controller/helpers.rb:97:in > > `helper' > # > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.13/lib/action_view/test_case.rb:85:in > > `include_helper_modules!' > # > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.13/lib/action_view/test_case.rb:78:in > > `new' > # > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:359:in > > `run' > # > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:28:in > > `block (2 levels) in run' > # > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:28:in > > `map' > # > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:28:in > > `block in run' > # > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/reporter.rb:34:in > > `report' > # > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:25:in > > `run' > # > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in > > `run' > # > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in > > `block in autorun' > > Finished in 0.00117 seconds > 1 example, 1 failure > > Failed examples: > > rspec ./spec/lib/standard_form_builder_spec.rb:36 # StandardFormBuilder > standard fields should build input fields > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.13/lib/abstract_controller/helpers.rb:123:in > > `include': wrong argument type Class (expected Module) (TypeError) > from > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.13/lib/abstract_controller/helpers.rb:123:in > > `block in add_template_helper' > from > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.13/lib/abstract_controller/helpers.rb:123:in > > `module_eval' > from > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.13/lib/abstract_controller/helpers.rb:123:in > > `add_template_helper' > from > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.13/lib/abstract_controller/helpers.rb:98:in > > `block in helper' > from > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.13/lib/abstract_controller/helpers.rb:97:in > > `each' > from > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.13/lib/abstract_controller/helpers.rb:97:in > > `helper' > from > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.13/lib/action_view/test_case.rb:85:in > > `include_helper_modules!' > from > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.0.13/lib/action_view/test_case.rb:78:in > > `new' > from > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/example_group.rb:366:in > > `run' > from > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:28:in > > `block (2 levels) in run' > from > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:28:in > > `map' > from > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:28:in > > `block in run' > from > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/reporter.rb:34:in > > `report' > from > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:25:in > > `run' > from > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in > > `run' > from > /Users/macarthy/.rvm/gems/ruby-1.9.3-p194/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in > > `block in autorun' > > > > > On Monday, December 3, 2012 6:03:30 PM UTC+7, [email protected] wrote: >> >> On Mon, Dec 3, 2012 at 12:34 AM, macarthy <[email protected]> wrote: >> > Does anyone have an example of testing a custom form builder with >> rspec ? >> > >> > in /spec/helpers/my_form_builder_spec.rb >> > >> > require 'spec_helper' >> > >> > describe MyFormBuilder do >> > >> > before (:each) do >> > >> > @object = mock_model(Company) >> > >> > @object.stub!(:longname).and_return("Company") >> > >> > @object.stub!(:phone).and_return("+(66) 000 00001") >> > >> > @builder = StandardFormBuilder.new(:company, @object, self, {}, >> nil) end >> > >> > end >> > >> > >> > >> > I'm getting the following error >> > >> > wrong argument type Class (expected Module) >> >> Which line in what file is this coming from? Please post the backtrace >> so we can see more detail. >> >> > >> > I think it is try to include RSpec::Rails::HelperExampleGroup >> > >> > Any ideas? >> > >> > >> > Thanks J >> > >> > -- >> > You received this message because you are subscribed to the Google >> Groups >> > "rspec" group. >> > To post to this group, send email to [email protected]. >> > To unsubscribe from this group, send email to >> > [email protected]. >> > To view this discussion on the web visit >> > https://groups.google.com/d/msg/rspec/-/rwqPfaLVM-0J. >> > For more options, visit https://groups.google.com/groups/opt_out. >> > >> > >> >
Looking at your backtrace, the culprit is here: https://github.com/rails/rails/blob/v3.0.13/actionpack/lib/abstract_controller/helpers.rb#L123 Rails is trying to include your class as a helper module but it is not a module. For validation, compare the error you're getting to what you get in IRB with code like: Class.new { include Class.new } Anyhow, it would take me a while to dig through the entire backtrace to see exactly how it is getting there, but I suspect that rails' support for testing helpers assumes that helpers are modules, and tries to mix them in to a testable object, the same way rails does to mix helper modules into a template context. rspec-rails generally wraps what rails provides, so when you tag your example group with `:type => :helper` it is triggering this. I recommend trying to not tag your example group with `:type => :helper`. After all, this isn't a helper module, right? HTH, Myron -- You received this message because you are subscribed to the Google Groups "rspec" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msg/rspec/-/WSWqok9sDzIJ. For more options, visit https://groups.google.com/groups/opt_out.
