I can open the view after running rails server and I see the newly created text field for billing_name as seen below and it works just fine.
views/registrations/new.html.erb
<h2>My New Signup</h2>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<p><%= f.label :email %><br />
<%= f.email_field :email %></p>
<p><%= f.label :password %><br />
<%= f.password_field :password %></p>
<p><%= f.label :password_confirmation, 'Password Confirmation' %><br />
<%= f.password_field :password_confirmation %></p>
<p><%= f.label :billing_name, 'Billing Name' %><br />
<%= f.text_field :billing_name %></p>
<p><%= f.submit "Sign up" %></p>
<% end %>
When I run my specs, however, it appears to be looking at the default devise view and cannot find that newly created billing_name field. If I save_and_open_page before trying to access that field in my spec it shows the default devise registration page, even though when I run rails server -e test, it displays my new customized view.
Here is the spec:
specs/requests/registration_spec.rb
require 'spec_helper'
describe "Registraion" do
describe "GET /signup" do
it "allows signup with proper credentials" do
visit signup_path
fill_in "user_email", :with => "sample@email.com"
fill_in "user_password", :with => "password"
fill_in "user_password_confirmation", :with => "password"
save_and_open_page
fill_in "user_billing_name", :with => "First Last"
end
end
end
And my spec helper is just the basic one that is auto-generated:
specs/spec_helper.rb
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
config.mock_with :rspec
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = true
end
When you override the Devise controllers, be sure to also override the devise_for routes.
For example (in routes.rb):
The Devise wiki also has an example.