I'm trying to set up a simple online store. I'm using the gem devise for user registration. When I run the site on local host everything works fine, however when I run rspec it appears that after completing the sign up form I'm redirected to the wrong paths.
By route.rb looks like this:
Rails.application.routes.draw do
devise_for :admins
resources :products, only: [:index]
resource :cart, only: [:show]
resources :order_items, only: [:create, :update, :destroy]
root to: "products#index"
devise_for :users, :controllers => { registrations: 'registrations' }
end
my test looks like this:
describe "user logging into Store" do
context "when an unsigned in user visits the page they can log in" do
it "displays the successfull log in message when logged in" do
visit("/")
click_link('Register')
expect(page.current_path).to eq('/users/sign_up')
fill_in("Email", with: "tester1@test.com")
fill_in("Password", with: "password123")
fill_in("Password confirmation", with: "password123")
click_button('Sign up')
expect(page.current_path).to eq('/')
expect(page).to have_content("Welcome! You have signed up successfully.")
end
end
end
and the error looks like this:
Failure/Error: expect(page.current_path).to eq('/')
expected: "/"
got: "/users"
(compared using ==)
I've been stuck for a while now so any help would be greatly appreciated. Thanks
Aucun commentaire:
Enregistrer un commentaire