1
votes

Everytime i run the default devise user_step test " sign in" it fails.

Strange thing is the error i get

Scenario: User signs in successfully     # features/users/sign_in.feature:12
    Given I exist as a user                # features/step_definitions/user_steps.rb:58
    And I am not logged in                 # features/step_definitions/user_steps.rb:49
    When I sign in with valid credentials  # features/step_definitions/user_steps.rb:72
    Then show me the page                  # features/step_definitions/user_steps.rb:152
And I see a successful sign in message # features/step_definitions/user_steps.rb:156
      expected to find text "Signed in successfully." in "Mywebsite Follow us How it works More Login × **Invalid email or password**. Login * Email Password Remember me Not a member yet? Sign Up Now!Forgot your password?Didn't receive confirmation instructions? Rails Tutorial " (RSpec::Expectations::ExpectationNotMetError)
      ./features/step_definitions/user_steps.rb:157:in `/^I see a successful sign in message$/'
      features/users/sign_in.feature:17:in `And I see a successful sign in message'

As you see capybara/cucumber tries to connect but gets "Invalid email or password"

So I used a trick seen on SO and added to see what capybara really was getting

 Then /^show me the page$/ do
  save_and_open_page
end

It tries to use the credentials I put on top of my file user_steps.rb:

 def create_visitor
  @visitor ||= { :name => "Testy McUserton", :email => "[email protected]",
    :password => "please", :password_confirmation => "please" }
end

But it gets me "invalid (i can see [email protected] written in the email field on the capyabra page so it understands that i want this to be the email.

I'm lost. Why doesn't it work ?

1

1 Answers

0
votes

You need to create the user in the database first. User.create(name: "Testy McUserton", email: "[email protected]", password: "please", :password_confirmation: "please"). Then you can login with the credentials. You can also use factorygirl link