spec/api/game_spec.rb in triviacrack-0.2.0 vs spec/api/game_spec.rb in triviacrack-0.3.0
- old
+ new
@@ -25,16 +25,21 @@
context 'given that the request fails' do
let(:code) { 400 }
it { expect{ subject }.to raise_error TriviaCrack::Errors::RequestError }
+ it { expect{ subject }.to raise_error(an_instance_of(TriviaCrack::Errors::RequestError)
+ .and having_attributes(code: 400)) }
+ it { expect{ subject }.to raise_error(an_instance_of(TriviaCrack::Errors::RequestError)
+ .and having_attributes(url: "/api/users/#{session.user_id}/dashboard")) }
end
end
describe "#get_game" do
+ let(:game_id) { 123 }
- subject { client.get_game 123 }
+ subject { client.get_game game_id }
let(:raw_data) { SpecData.get "game.json" }
context 'given that the request is successful' do
let(:code) { 200 }
@@ -45,10 +50,14 @@
context 'given that the request fails' do
let(:code) { 400 }
it { expect{ subject }.to raise_error TriviaCrack::Errors::RequestError }
+ it { expect{ subject }.to raise_error(an_instance_of(TriviaCrack::Errors::RequestError)
+ .and having_attributes(code: code)) }
+ it { expect{ subject }.to raise_error(an_instance_of(TriviaCrack::Errors::RequestError)
+ .and having_attributes(url: "/api/users/#{session.user_id}/games/#{game_id}")) }
end
end
describe "#start_new_game" do
@@ -65,8 +74,12 @@
context 'given that the request fails' do
let(:code) { 400 }
it { expect{ subject }.to raise_error TriviaCrack::Errors::RequestError }
+ it { expect{ subject }.to raise_error(an_instance_of(TriviaCrack::Errors::RequestError)
+ .and having_attributes(code: code)) }
+ it { expect{ subject }.to raise_error(an_instance_of(TriviaCrack::Errors::RequestError)
+ .and having_attributes(url: "/api/users/#{session.user_id}/games")) }
end
end
end