Reputation: 9896
I've changed the name of a column in my database and have changed spec/factories.rb
accordingly, however when I run my rspec
tests, it's still trying to make use of the old column names. I've restarted the Ruby on Rails server, yet that doesn't fix it.
# Changed :height to :height_feet
# Added :height_inches
FactoryGirl.define do
factory :user do
...
height 180
end
end
# Changed to:
FactoryGirl.define do
factory :user do
...
height_feet 5
height_inches 11
end
end
Yet when I run rspec spec/models
the following line:
let(:user) { FactoryGirl.create(:user) }
produces the following error:
Failure/Error: let(:user) { FactoryGirl.create(:user) }
NoMethodError:
undefined method `height' for #<User:0x0000000532fc08>
Any thoughts on how I can fix this?
Upvotes: 0
Views: 888
Reputation: 9896
I fixed this problem by upgrading to FactoryGirl 2.0.0 from FactoryGirl 1.4.0. From the troubleshooting link:
https://github.com/sporkrb/spork/wiki/Spork.trap_method-Jujitsu
Factory Girl 2 does not have the auto-loading issues of previous versions, so you do not need to do anything to get Spork to work.
Upvotes: 1
Reputation: 1895
It's your spork server you'll need to restart. I don't use guard so I'm not totally sure how, but have a look at this question, there is some other useful info on refreshing:
Spork: how to refresh validations and other code?
Upvotes: 1