spec/api/profile_spec.rb in triviacrack-0.2.0 vs spec/api/profile_spec.rb in triviacrack-0.3.0
- old
+ new
@@ -8,12 +8,13 @@
let(:response) { double(code: code, body: raw_data) }
before { allow(Unirest).to receive(:get) { response } }
describe "#get_profile" do
+ let(:user_id) { 111 }
- subject { client.get_profile 111 }
+ subject { client.get_profile user_id }
let(:raw_data) { SpecData.get "profile.json" }
context 'given that the request is successful' do
let(:code) { 200 }
@@ -24,10 +25,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}/profiles/#{user_id}")) }
end
end
describe "#get_my_profile" do
@@ -44,8 +49,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}/profiles/#{session.user_id}")) }
end
end
end