From e702cbde958675dc2d4a2b4c21a2c827929c1921 Mon Sep 17 00:00:00 2001 From: Matt Farnsworth Date: Wed, 21 Oct 2015 16:22:34 +0300 Subject: [PATCH] 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 --- spec/models/domain_spec.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/spec/models/domain_spec.rb b/spec/models/domain_spec.rb index 015a407e0..a6a0cfbf8 100644 --- a/spec/models/domain_spec.rb +++ b/spec/models/domain_spec.rb @@ -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