lundi 4 mai 2015

RSpec Tests fail with FactoryGirl, pass when isolated

I am upgrading an app from Rails 3 to Rails 4 and have a model called item with the following schema:

#===Schema Information
# Table name: items
#
#type :string
#maturity: string

and a spec with a series of test, but this one in particular is the one I have the issue with:

describe 'next_version' do
it 'should return the created_at date of the Item one version higher' do
first = FactoryGirl.create(:item, maturity: 'PRODUCTION')
second = FactoryGirl.create(:item, maturity: 'PREPRODUCTION', created_at: Time.now.in_time_zone)

expect(first.next_version_created_at.to_s)to eq second.created_at.utc.to_s)

The fix, I believe is easy enough.. just add..

 created_at: Time.now.in_time_zone

..to the Production item and done. However, the test passes if I run it by itself, and the entire spec passed (146 tests) in Rails 3, however when I run the entire spec now this one and 3 other similar cases fail, unless I run them alone.

Thoughts?

Aucun commentaire:

Enregistrer un commentaire