lundi 23 mars 2015

Rails4.2 + Rspec: test fails only with certain randomized seed

I have a pretty simple test that passes when run by itself, passes 80-90% of the time when run as part of the entire suite, but fails literally one out of every 8-10 times the suite is run, depending on the randomized seed.



# reminder.rb
class Reminder < ActiveRecord::Base
DAYS = [3,10]
attr_accessible :daynum
...
validates_inclusion_of :daynum, in: DAYS
...
end

#reminder_spec.rb
...
it 'should validate inclusion of daynum in days' do
rem = build :reminder, daynum: 0
rem.valid?

rem.should_not be_valid
rem.errors.full_messages.should include("Daynum is not included in the list")
end
...


Using binding.pry before the expectations when using the seed that results in the test failing, I have gathered this info:



rem.errors.full_messages # => ["Daynum translation missing: es.activerecord.errors.models.reminder.attributes.daynum.inclusion"]


In most randomized tests, and when running this spec by itself, I get the expected message:



rem.errors.full_messages # => ["Daynum is not included in the list"]


I'm assuming that there's an issue with cleanup going on but I'm not sure how to begin debugging this test. It mentions a missing translation but I'm not trying to translate anything in this spec/method. Can anyone point me in the right direction?


Aucun commentaire:

Enregistrer un commentaire