test case: BUGFIX ensure test setup, new Domain object for each instance

before :all runs once per context, before :example runs for each it block
be sure test cases with hacks/forced changes do not impact later tests
This commit is contained in:
Matt Farnsworth 2015-10-21 16:22:34 +03:00
parent 53695c3647
commit e702cbde95

View file

@ -64,10 +64,15 @@ describe Domain do
end
context 'with valid attributes' do
before :all do
before :example do
@domain = Fabricate(:domain)
end
after do
@domain.delete
@domain = nil
end
it 'should be valid' do
@domain.valid?
@domain.errors.full_messages.should match_array([])
@ -458,7 +463,7 @@ describe Domain do
end
context 'about registrant update confirm' do
before :all do
before :example do
@domain.registrant_verification_token = 123
@domain.registrant_verification_asked_at = Time.zone.now
@domain.statuses << DomainStatus::PENDING_UPDATE
@ -479,7 +484,7 @@ describe Domain do
end
context 'about registrant update confirm when domain is invalid' do
before :all do
before :example do
@domain.registrant_verification_token = 123
@domain.registrant_verification_asked_at = Time.zone.now
@domain.statuses << DomainStatus::PENDING_UPDATE