mercredi 26 octobre 2016

Testing Devise Using capybara rspec and factory girl

i'm new at rails and i'm testing my devise gem User with capybara rspec and factory girl.

Here's spec code:

require 'rails_helper'
RSpec.describe User, type: :request do
  it "displays the user's email after successful login" do
    user = FactoryGirl.create(:user, email: 'test@test.com', password: 'password')
    visit root_url
    fill_in 'Email', with: 'test@test.com'
    fill_in 'Password', with: 'password'
    click_button 'Log in'
    expect page.has_content?('jdoe')
  end
end

The problem is in

expect page.has_content?('jdoe') No matter what i put instead 'jdoe' test works perfectly without any errors.

Here's factory:

FactoryGirl.define do
  factory :user do
    email 'test@test.com'
    password 'password'
    password_confirmation 'password'
  end
end

Maybe I missed something or going with a wrong way. How should I test here?

Aucun commentaire:

Enregistrer un commentaire