Sha256: c144d42e98eadddb937d6f590e9453f2b52d96786970dc0ed7c7d90fb80a8992
Contents?: true
Size: 965 Bytes
Versions: 4
Compression:
Stored size: 965 Bytes
Contents
require "spec_helper" describe Goodreads::Client do before :each do Goodreads.reset_configuration end let(:client) do described_class.new(api_key: api_key) end context "API key is missing" do let(:api_key) {} it "throws an error" do expect { client.book_by_isbn("0307463745") } .to raise_error(Goodreads::ConfigurationError, "API key required.") end end context "API key is invalid" do let(:api_key) { "INVALID_KEY" } before do stub_request(:get, "https://www.goodreads.com/book/isbn?format=xml&isbn=1&key=INVALID_KEY") .to_return(status: 401) stub_request(:get, "https://www.goodreads.com/book/isbn?format=xml&isbn=2&key=INVALID_KEY") .to_return(status: 403) end it "throws errors" do expect { client.book_by_isbn("1") }.to raise_error(Goodreads::Unauthorized) expect { client.book_by_isbn("2") }.to raise_error(Goodreads::Forbidden) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
goodreads-0.9.0 | spec/authentication_spec.rb |
goodreads-0.8.0 | spec/authentication_spec.rb |
goodreads-0.7.0 | spec/authentication_spec.rb |
goodreads-0.6.2 | spec/authentication_spec.rb |