Sha256: b9c054f10ae509a6bf9b94cd95d5420ab1eeb9fad38b584aaf19f9aeb090f268

Contents?: true

Size: 1.47 KB

Versions: 9

Compression:

Stored size: 1.47 KB

Contents

require 'helper'

describe MLB::Team, ".all" do
  context "with connection" do
    before do
      stub_request(:get, 'http://api.freebase.com/api/service/mqlread').
        with(:query => {:query => MLB::Team.mql_query}).
        to_return(:body => fixture("teams.json"))
    end

    after do
      MLB::Team.reset
    end

    it "should request the correct resource" do
      MLB::Team.all
      a_request(:get, 'http://api.freebase.com/api/service/mqlread').
        with(:query => {:query => MLB::Team.mql_query}).
        should have_been_made
    end

    it "should return the correct results" do
      teams = MLB::Team.all
      teams.first.name.should == "Arizona Diamondbacks"
    end
  end

  context "with timeout" do
    before do
      stub_request(:get, 'http://api.freebase.com/api/service/mqlread').
        with(:query => {:query => MLB::Team.mql_query}).
        to_timeout
    end

    after do
      MLB::Team.reset
    end

    it "should return the correct results" do
      teams = MLB::Team.all
      teams.first.name.should == "Arizona Diamondbacks"
    end
  end

  context "without connection" do
    before do
      stub_request(:get, 'http://api.freebase.com/api/service/mqlread').
        with(:query => {:query => MLB::Team.mql_query}).
        to_raise(SocketError)
    end

    after do
      MLB::Team.reset
    end

    it "should return the correct results" do
      teams = MLB::Team.all
      teams.first.name.should == "Arizona Diamondbacks"
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mlb-0.6.1 spec/mlb_spec.rb
mlb-0.6.0 spec/mlb_spec.rb
mlb-0.5.9 spec/mlb_spec.rb
mlb-0.5.8 spec/mlb_spec.rb
mlb-0.5.7 spec/mlb_spec.rb
mlb-0.5.6 spec/mlb_spec.rb
mlb-0.5.5 spec/mlb_spec.rb
mlb-0.5.4 spec/mlb_spec.rb
mlb-0.5.3 spec/mlb_spec.rb