Bazley
Bazley

Reputation: 2847

Rspec failing test - FactoryGirl

Here is my spec:

require 'spec_helper'

describe "User pages" do

  let(:user) { FactoryGirl.create(:user) }

  subject { page }

  describe "for non-signed-in user" do

    describe "profile page" do

      before do
        visit user_path(user)
      end

      it { should have_content("Sign in") }
      it { should have_title("Sign in") }
    end
  end
end

Here is factories.rb:

FactoryGirl.define do

  factory :user do
    sequence(:name)     { |n| "User #{n}" }
    sequence(:email)    { |n| "user_#{n}@example.com" }
    sequence(:callsign) { |n| "user_#{n}" }
    password "foobar"
    password_confirmation "foobar"

    factory :admin do
      admin true
    end
  end
end

I keep getting this error message:

User pages for non-signed-in user profile page

Failure/Error: let(:user) { FactoryGirl.create(:user) }

ActiveRecord::RecordInvalid:

Validation failed: Callsign can't be blank, Callsign is invalid

I am baffled. Why does it complain that callsign is blank when I have set it in factories.rb?

Upvotes: 0

Views: 40

Answers (1)

Bazley
Bazley

Reputation: 2847

I am an idiot. I just had to restart spork.

Upvotes: 0

Related Questions