I have this code:
before(:all) { @user = FactoryGirl.create(:user)}
byebug
subject { @user }
it { should respond_to(:email)}
it { should respond_to(:password)}
it { should respond_to(:password_confirmation)}
it { should be_valid }
it { should validate_presence_of(:email) }
it { should validate_confirmation_of(:password) }
it { should allow_value('[email protected]').for(:email)}
describe 'validations' do
subject { FactoryGirl.create(:user)}
it { should validate_uniqueness_of(:email).case_insensitive}
end
When it stops after byebug, it discovers that @user is nil:
1: require 'rails_helper'
2:
3: describe User do
4: before(:all) { @user = FactoryGirl.create(:user)}
5: byebug
=> 6: subject { @user }
7: it { should respond_to(:email)}
8: it { should respond_to(:password)}
9: it { should respond_to(:password_confirmation)}
10:
(byebug) display @user
1: @user = nil
(byebug)
Why is it happening? If I change FactoryGirl to User.create, nothing changes.