Sha256: df7f6d0aca9e3b3a3f389b68aac20cd39575e2eb3b538047c2e1e1dec02fa29c
Contents?: true
Size: 1.36 KB
Versions: 1
Compression:
Stored size: 1.36 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 "requests the correct resource" do MLB::Team.all expect(a_request(:get, 'http://api.freebase.com/api/service/mqlread').with(query: {query: MLB::Team.mql_query})).to have_been_made end it "returns the correct results" do teams = MLB::Team.all expect(teams.first.name).to eq "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 "returns the correct results" do teams = MLB::Team.all expect(teams.first.name).to eq "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 "returns the correct results" do teams = MLB::Team.all expect(teams.first.name).to eq "Arizona Diamondbacks" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mlb-0.6.2 | spec/mlb_spec.rb |