Sha256: c1073bbba4a2cdb784d53e4a28b03b4993f1f6da8dc50533e90a4416c1a0209a

Contents?: true

Size: 1.79 KB

Versions: 5

Compression:

Stored size: 1.79 KB

Contents

require 'helper'

describe Fantasydata do

  after do
    Fantasydata.reset!
  end

  context "when delegating to a client" do

      before do
        Fantasydata.configure do |config|
          config.api_key = 'AK'
        end

        stub_get("/nfl/v2/JSON/AreAnyGamesInProgress").
          to_return(:body => fixture("game/in_progress.json"),
                    :headers => {:content_type => "application/json; charset=utf-8"})
      end

      it "requests the correct resource" do
        #Fantasydata.games_in_progress(:artist => 'radiohead')
        #expect(a_get("/api/v4/song/search")
        #.with(:query => {:artist => 'radiohead'}))
        #.to have_been_made
      end

      it "returns the same results as a client" do
        expect(Fantasydata.games_in_progress?).to eq Fantasydata::Client.new.games_in_progress?
      end

      describe ".respond_to?" do
        it "delegates to Fantasydata::Client" do
          expect(Fantasydata.respond_to?(:games_in_progress?)).to be_truthy
        end
        it "takes an optional argument" do
          expect(Fantasydata.respond_to?(:client, true)).to be_truthy
        end
      end

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

        context "when the options don't change" do
          it "caches the client" do
            expect(Fantasydata.client).to eq Fantasydata.client
          end
        end

        context "when the options change" do
          it "busts the cache" do
            client1 = Fantasydata.client
            Fantasydata.configure do |config|
              config.api_key = 'abc'
            end
            client2 = Fantasydata.client
            expect(client1).not_to eq client2
          end
        end
      end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fantasydata-0.2.2 spec/fantasydata_spec.rb
fantasydata-0.2.1 spec/fantasydata_spec.rb
fantasydata-0.2.0 spec/fantasydata_spec.rb
fantasydata-0.0.2 spec/fantasydata_spec.rb
fantasydata-0.0.1 spec/fantasydata_spec.rb