I use Factory Girl to create two instances in my / unit test model for a group. I am testing a model to verify that the .current call returns only the "current" groups according to the expiry attribute, as shown below ...
describe ".current" do let!(:current_group) { FactoryGirl.create(:group, :expiry => Time.now + 1.week) } let!(:expired_group) { FactoryGirl.create(:group, :expiry => Time.now - 3.days) } specify { Group.current.should == [current_group] } end
My problem is that I received confirmation in a model that checks for the expiration of a new group after today's date. This causes the check below to fail.
1) Group.current Failure/Error: let!(:expired_group) { FactoryGirl.create(:group, :expiry => Time.now - 3.days) } ActiveRecord::RecordInvalid: Validation failed: Expiry is before todays date
Is there a way to force the creation of a group or circumvent the check when creating with Factory Girl?
ruby-on-rails ruby-on-rails-3 rspec rspec-rails factory-bot
Norto23 Feb 17 '12 at 3:10 2012-02-17 03:10
source share