Skip to content

Commit

Permalink
Prefer asserting on the exception rather than the message
Browse files Browse the repository at this point in the history
protects more against the change
  • Loading branch information
alvarogarcia7 committed Nov 1, 2015
1 parent 3bf17bc commit e0af0cf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions spec/consensus_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions spec/question_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit e0af0cf

Please sign in to comment.