Sha256: f9da0cec83183ef95296caf36bb529d8eb21ff81bd05fbef131ba79bd4c8c520

Contents?: true

Size: 715 Bytes

Versions: 3

Compression:

Stored size: 715 Bytes

Contents

require "spec_helper"

describe "Client" do
  before :each do
    Goodreads.reset_configuration
  end

  it "raises Goodreads::ConfigurationError if API key was not provided" do
    client = Goodreads::Client.new

    expect { client.book_by_isbn("0307463745") }
      .to raise_error(Goodreads::ConfigurationError, "API key required.")
  end

  it "raises Goodreads::Unauthorized if API key is not valid" do
    client = Goodreads::Client.new(api_key: "INVALID_KEY")

    stub_request(:get, "https://www.goodreads.com/book/isbn?format=xml&isbn=054748250711&key=INVALID_KEY")
      .to_return(status: 401)

    expect { client.book_by_isbn("054748250711") }
      .to raise_error(Goodreads::Unauthorized)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
goodreads-0.6.1 spec/authentication_spec.rb
goodreads-0.6.0 spec/authentication_spec.rb
goodreads-0.5.0 spec/authentication_spec.rb