ruby on rails - Why is this Factory causing a test to fail, when building the record manually passes? -


in rails app i'm testing user confirmations

scenario "unconfirmed user cannot login"   user = create(:user, confirmation_sent_at: 10.days.ago ) #factorygirl factory   login user   expect(current_path).to eq(#unconfirmed_user_path) end 

this fails, , user signed in.

however if change first line follows

user = create(:user) user.confirmation_sent_at = 10.days.ago user.save login user ..... 

the test passes.

what overlooking? these 2 pieces of code equivalent aren't they?

edit

#factories/user_factory.rb  factory :user   email { faker::internet.email }   password faker::internet.password(10, 20)  end  # models/user.rb # == schema information # # table name: users # #  id                     :integer          not null, primary key #  email                  :string(255)      default(""), not null #  encrypted_password     :string(255)      default(""), not null #  confirmation_token     :string(255) #  confirmed_at           :datetime #  confirmation_sent_at   :datetime #  ...  class user < activerecord::base    devise :invitable, :database_authenticatable, :registerable, :confirmable, :lockable, :recoverable, :rememberable, :trackable, :validatable, :omniauthable   ... end  


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -