Sha256: 7a40f3411c7d5e7b767b3a4ccb7b4bc7c9203cb39619d92b4ca21af0d3f48630

Contents?: true

Size: 1.52 KB

Versions: 4

Compression:

Stored size: 1.52 KB

Contents

require "spec_helper"

describe Goodreads do
  describe ".new" do
    it "returns a new client instance" do
      expect(Goodreads.new).to be_a(Goodreads::Client)
    end
  end

  describe ".configure" do
    it "sets a global configuration options" do
      config = Goodreads.configure(api_key: "FOO", api_secret: "BAR")
      expect(config).to be_a(Hash)
      expect(config).to have_key(:api_key)
      expect(config).to have_key(:api_secret)
      expect(config[:api_key]).to eql("FOO")
      expect(config[:api_secret]).to eql("BAR")
    end

    it "raises ConfigurationError on invalid config parameter" do
      expect { Goodreads.configure(nil) }
        .to raise_error(ArgumentError, "Options hash required.")

      expect { Goodreads.configure("foo") }
        .to raise_error(ArgumentError, "Options hash required.")
    end
  end

  describe ".configuration" do
    before do
      Goodreads.configure(api_key: "FOO", api_secret: "BAR")
    end

    it "returns global configuration options" do
      config = Goodreads.configuration
      expect(config).to be_a(Hash)
      expect(config).to have_key(:api_key)
      expect(config).to have_key(:api_secret)
      expect(config[:api_key]).to eql("FOO")
      expect(config[:api_secret]).to eql("BAR")
    end
  end

  describe ".reset_configuration" do
    before do
      Goodreads.configure(api_key: "FOO", api_secret: "BAR")
    end

    it "resets global configuration options" do
      Goodreads.reset_configuration
      expect(Goodreads.configuration).to eql({})
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
goodreads-0.9.0 spec/goodreads_spec.rb
goodreads-0.8.0 spec/goodreads_spec.rb
goodreads-0.7.0 spec/goodreads_spec.rb
goodreads-0.6.2 spec/goodreads_spec.rb