hiroprotagonist
hiroprotagonist

Reputation: 902

FactoryGirl not aware of new column

Hi I am using FactoryGirl 4.9.0 w/ Rails 4.2.11. I added a boolean column to a model called Query like so:

class AddSetLatestResultToQueries < ActiveRecord::Migration
  def change
    add_column :queries, :latest_result_s3_url_flag, :boolean, null: false, default: false
  end
end

This flag works fine and the app itself works fine but when it comes to rspec, FactoryGirl seems to be having trouble acknowledging this new column.

I tried to add it to the factory model like this:

FactoryGirl.define do
  factory :query do
    latest_result_s3_url_flag false
    title 'some title'
    latest_body 'SELECT TIMEOFDAY();'

 ... etc ...

end

But when I run rpsec spec, I see this error:

      NoMethodError:
        undefined method `latest_result_s3_url_flag=' for #<Query:0x00007ff6f9108428>

Upvotes: 3

Views: 425

Answers (1)

NeverBe
NeverBe

Reputation: 5038

Just run this:

RAILS_ENV=test rake db:migrate

Upvotes: 6

Related Questions