Note that there are some explanatory texts on larger screens.

plurals
  1. POValidation failed error in Rails application and Cucumber with Factory Girl
    primarykey
    data
    text
    <p>I have the following error: "Validation failed: Email address is already used" while trying to run feature for Devise user signing in.</p> <p>I suspect the problem is in Factory generated user, which somehow being created twice with the same email address. I tried to run rake db:test:prepare in order to reset test database, unfortunately, with no results.</p> <p>my <strong>user_factory.rb</strong></p> <pre><code>Factory.define :user do |user| user.email "user_#{rand(1000).to_s}@example.com" user.password "password" user.confirmed_at nil end </code></pre> <p>Steps, which are failing with validation error are <strong>"Then I should be registered and signed in"</strong> and <strong>"And user signs in"</strong>. my <strong>signing_in.feature</strong></p> <pre><code>Feature: Signing in In order to use the site As a user I want to be able to sign in Scenario: Signing in via confirmation Given there is an unconfirmed user And I open the email with subject "Confirmation instructions" And they click the first link in the email Then I should be registered and signed in Scenario: Signing in via form Given there is a confirmed user And I am on the homepage And user signs in Then I should see "Signed in successfully" </code></pre> <p>my <strong>user_steps.rb</strong></p> <pre><code>def unconfirmed_user @unconfirmed_user = Factory(:user) end def sign_up user visit '/users/sign_up' fill_in('Email', :with =&gt; "unique@unique.com") fill_in('Password', :with =&gt; user.password) fill_in('Password confirmation', :with =&gt; user.password) click_button('Sign up') end def sign_in user visit 'users/sign_in' fill_in('Email', :with =&gt; user.email) fill_in('Password', :with =&gt; user.password) click_button('Sign in') end When /^I'm signing up$/ do sign_up unconfirmed_user end Given /^there is an unconfirmed user$/ do unconfirmed_user end Given /^there is a confirmed user$/ do unconfirmed_user.confirm! end Then /^I should be registered and signed in$/ do page.should have_content("Signed in as #{unconfirmed_user.email}") end Given /^user signs in$/ do sign_in unconfirmed_user.confirm! end When /^I open the email with subject "([^"]*?)"$/ do |subject| open_email(@unconfirmed_user.email, :with_subject =&gt; subject) end </code></pre> <p>What it can be? Thanks in advance for your help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload