Do I need a Devise user controller if I just change the "Register" view?

In the capybara / rspec integration test, I follow these steps: just trying to register a new element.

visit new_member_registration_path fill_in('Name:', :with => 'Rob Doe' ) fill_in('member_email', :with => ' rob@smith.com ' ) fill_in('member_email_confirmation', :with => ' rob@smith.com ' ) fill_in('member_password', :with => 'secret') fill_in('Company or Venue Name:', :with => 'Rob Inc.') fill_in('Contact Number:', :with => '040544404440') click_button('Sign up') save_and_open_page 

For some reason, the "email" and "password" data are not passed to the DeviseRegistrations controller (it is empty when viewing the test log) and, therefore, the verification fails. However, there are no rspec errors up to the save_and_open_ page (so these fields are populated).

What am I missing? Do I need to subclass the DeviseRegistrations controller?

Tested on Rails 3.0.7 using rack test 0.5.7 and rails 3.1rc1 and rack test 0.6.0

+7
source share
2 answers

The problem was in the application layout file. I had another (albeit hidden) form that placed the fields of the empty form.

After I created an empty project and saw that it worked perfectly, I cleared all potential parts of my application until I found the culprit.

Thus, the answer to the question: no, a custom development controller is not required when you use custom development types.

+2
source

Assuming you have a debugger in the Gemfile, here is how you can use it. (It is assumed that you are using the Rack driver for Capybara.)

 # test.rb visit new_member_registration_path fill_in('Name:', :with => 'Rob Doe' ) debugger 

The terminal will stop your script and wait for you to do something.

 # Terminal /file/path/to/you/test.rb:12 fill_in('Name:', :with => 'Rob Doe' ) (rdb:1) 

Open an IRB session here:

 (rdb:1) irb 

Here you can use any RSpec or Capybara method:

 >> current_path.should == 'foo/bar' 

Try submitting the form at this point:

 >> click_button "Sign Up" >> save_and_open_page 

See what error messages are provided to you on the received page. With the Rack driver, you will not see the completed fields. In this case, you can try using the Selenium driver

 # test.rb Capybara.default_driver = :selenium visit new_member_registration_path 

However, you cannot control Capybara from IRB using the Selenium driver. However, you can see what forms of value Selenium puts into your form. Because Selenium happens quickly, you can use the debugger to pause the test while you check the page that Selenium has opened in your browser.

+3
source

All Articles