Hi,

I wonder if anyone can help me. I'm having a problem with my request  
specs.

I'm simulating a post in my specs thusly:

   it "should check confirmation password" do
     response = post(url(:account), { :account  => {
       :name => 'Name',
       :email => '[email protected]',
       :password => 'secret',
       :password_confirmation => 'wrong',
     }})
   end

but this is generating an error "interning empty string" when I try to  
call 'render' in the controller. This is because the :format param has  
been set to "" rather than nil (or a valid format). The error  
backtrace is this:

merb-core-1.0.6.1/lib/merb-core/controller/mixins/responder.rb:301:in  
`to_sym'
merb-core-1.0.6.1/lib/merb-core/controller/mixins/responder.rb:301:in  
`_perform_content_negotiation'
merb-core-1.0.6.1/lib/merb-core/controller/mixins/responder.rb:346:in  
`content_type'
merb-core-1.0.6.1/lib/merb-core/controller/mixins/render.rb:120:in  
`render'
/Profession/Development/signedsealed.org/development/signedsealed.org/ 
app/controllers/accounts.rb:23:in `create'
merb-core-1.0.6.1/lib/merb-core/controller/abstract_controller.rb: 
315:in `send'
merb-core-1.0.6.1/lib/merb-core/controller/abstract_controller.rb: 
315:in `_call_action'
merb-core-1.0.6.1/lib/merb-core/controller/abstract_controller.rb: 
289:in `_dispatch'
merb-core-1.0.6.1/lib/merb-core/controller/merb_controller.rb:252:in  
`_dispatch'
merb-core-1.0.6.1/lib/merb-core/test/helpers/mock_request_helper.rb: 
367:in `dispatch_request'
merb-core-1.0.6.1/lib/merb-core/test/helpers/mock_request_helper.rb: 
118:in `dispatch_to'
merb-core-1.0.6.1/lib/merb-core/test/helpers/mock_request_helper.rb: 
340:in `mock_request'
merb-core-1.0.6.1/lib/merb-core/test/helpers/mock_request_helper.rb: 
259:in `post'
./spec/requests/accounts_spec.rb:64
rspec-1.1.3/lib/spec/example/example_methods.rb:78:in `instance_eval'
rspec-1.1.3/lib/spec/example/example_methods.rb:78:in  
`run_with_description_capturing'
rspec-1.1.3/lib/spec/example/example_methods.rb:19:in `execute'
/opt/local/lib/ruby/1.8/timeout.rb:48:in `timeout'
rspec-1.1.3/lib/spec/example/example_methods.rb:16:in `execute'
rspec-1.1.3/lib/spec/example/example_group_methods.rb:292:in  
`execute_examples'
rspec-1.1.3/lib/spec/example/example_group_methods.rb:291:in `each'
rspec-1.1.3/lib/spec/example/example_group_methods.rb:291:in  
`execute_examples'
rspec-1.1.3/lib/spec/example/example_group_methods.rb:121:in `run'
rspec-1.1.3/lib/spec/runner/example_group_runner.rb:22:in `run'
rspec-1.1.3/lib/spec/runner/example_group_runner.rb:21:in `each'
rspec-1.1.3/lib/spec/runner/example_group_runner.rb:21:in `run'
rspec-1.1.3/lib/spec/runner/options.rb:90:in `run_examples'
rspec-1.1.3/lib/spec/runner/command_line.rb:19:in `run'
rspec-1.1.3/bin/spec:4


What appears to happen (though I have only a sketchy understanding of  
what's going on) is that the code breaks my request down using the  
router to generate an {:format => nil, :action =>  
"theaction", :controller => "thecontroller"}.

:action and :controller get split out and used to instantiate and call  
the right method on the right controller but :format gets merged into  
the params. These params are encoded into a query string and sent,  
through 'fake_request' as part of the post body. This results in  
the :format being sent as a parameter:

..&format=&...

Which is then converted to an empty string by the controller, rather  
than nil.

This empty string is what's causing the problem.

Now, I can fix this by simply removing the :format parameter from the  
post body:

def build_request(params = {}, env = {})
   params.delete(:format)
   ...
end

but this is obviously a hack.

The format parameter is dealt with correctly if I use webrat's  
"click_button" to post a form, so what's the difference?

Has anyone else seen this? Is the problem in the way I'm calling the  
post? I'm new to this kind of integration testing and making it up as  
I go along. That might show..

Thanks in advance,

Garry



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"merb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/merb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to