FactoryGirl gives wrong value on enum status field
<p>I am trying to build a FactoryGirl factory for the Client.rb model:</p>

<p>Client.rb</p>

<pre><code>  enum status: [ :unregistered, :registered ]

 has_many :quotation_requests

  #Validations

  validates :first_name, 
            presence: true,
            length: {minimum: 2}

  validates :last_name, 
            presence: true,
            length: {minimum: 2}

  validates :email, email: true

  validates :status, presence: true
</code></pre>

<p>Factory:</p>

<pre><code>FactoryGirl.define do
  factory :client do
    first_name "Peter"
    last_name "Johnson"
    sequence(:email) { |n| "peterjohnson#{n}@example.com" }
    password "somepassword"
    status "unregistered"
  end
end
</code></pre>

<p>client_spec.rb</p>

<pre><code>    require 'rails_helper'

    RSpec.describe Client, type: :model do

        describe 'factory' do

          it "has a valid factory" do
            expect(FactoryGirl.build(:client).to be_valid
          end

        end
end
</code></pre>

<p>I get the following errorL</p>

<pre><code>  1) Client factory has a valid factory
     Failure/Error: expect(FactoryGirl.build(:client, status: 'unregistered')).to be_valid
       expected #&lt;Client id: nil, email: "peterjohnson1@example.com", encrypted_password: "$2a$04$urndfdXNfKVqYB5t3kERZ.c.DUitIVXEZ6f19FNYZ2C...", first_name: "Peter", last_name: "Johnson", status: "0", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, created_at: nil, updated_at: nil&gt; to be valid, but got errors: Status can't be blank
</code></pre>

<p>The error is that Status can't be blank. </p>

<p>I don't understand how this is possible as the factory is clearly assigning a value to the status attribute.</p>

<p>How can I get this factory to build a valid client object?</p>

<p>Rails 4.2
Using factory_girl 4.7.0
Using factory_girl_rails 4.7.0</p>