From e0af0cf6caaec12865abf66c480e2fc6496113f0 Mon Sep 17 00:00:00 2001 From: Alvaro Garcia Date: Sun, 1 Nov 2015 20:08:02 +0100 Subject: [PATCH] Prefer asserting on the exception rather than the message protects more against the change --- spec/consensus_spec.rb | 6 +++--- spec/question_spec.rb | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/spec/consensus_spec.rb b/spec/consensus_spec.rb index bc128d5..d8241d5 100644 --- a/spec/consensus_spec.rb +++ b/spec/consensus_spec.rb @@ -13,7 +13,7 @@ it 'needs a proposal' do non_proposal = nil - expect{Consensus.new(non_proposal)}.to raise_error "Needs a proposal" + expect{Consensus.new(non_proposal)}.to raise_error NotProposal expect{Consensus.new(@proposal)}.to_not raise_error end @@ -60,7 +60,7 @@ it "the introduction phase has a minimum duration " do minimum_duration_in_days = 2 - expect{@consensus.next_phase}.to raise_error "Minimum duration not reached yet" + expect{@consensus.next_phase}.to raise_error MinimumDurationNotReached end describe "when introduction phase minimum duration has passed" do @@ -72,7 +72,7 @@ end it "can not go to next phase whith unaccepted questions " do - expect{@consensus.next_phase}.to raise_error 'There are unaccepted questions' + expect{@consensus.next_phase}.to raise_error UnacceptedQuestions end it "can go to next phase whith all questions are accepted " do diff --git a/spec/question_spec.rb b/spec/question_spec.rb index b340928..9a25dab 100644 --- a/spec/question_spec.rb +++ b/spec/question_spec.rb @@ -22,16 +22,16 @@ describe 'when addressed' do it "only could be answered by the addressed person" do @question.address :person - expect{@question.answer(:other_than_addressed)}.to raise_error 'The question is addressed to another person' + expect{@question.answer(:other_than_addressed)}.to raise_error NotAllowed end end it "must be answered to be accepted " do - expect{@question.accept :questioner}.to raise_error 'Must be answered before' + expect{@question.accept :questioner}.to raise_error Unanswered end it "must be answered to be rejected " do - expect{@question.reject :questioner, :any_reason}.to raise_error 'Must be answered before' + expect{@question.reject :questioner, :any_reason}.to raise_error Unanswered end describe 'when answered' do @@ -46,7 +46,7 @@ end it "must be accepted by the questioner" do - expect{@question.accept :anybody}.to raise_error 'This action must be made by the questioner' + expect{@question.accept :anybody}.to raise_error NotQuestioner end it "can be rejected with a reason" do @@ -55,7 +55,7 @@ end it "must be rejected by the questioner" do - expect{@question.reject :anybody, :any_reason}.to raise_error 'This action must be made by the questioner' + expect{@question.reject :anybody, :any_reason}.to raise_error NotQuestioner end end