Sha256: cf00c64bd2b9b466c01ee3bbc61ca44eb1d112c2303739f6d79f75b82a8d4337
Contents?: true
Size: 1.65 KB
Versions: 1
Compression:
Stored size: 1.65 KB
Contents
require 'spec_helper' describe XboxLeaders::Api do let(:url) { 'https://www.xboxleaders.com/api/2.0' } describe '#initialize' do it 'requires a url' do expect { XboxLeaders::Api.new }.to raise_error(ArgumentError) end it 'allows a specified timeout in seconds' do api = XboxLeaders::Api.new(url, 10) api.timeout.should == 10 end it 'defaults to a 6-second timeout' do api = XboxLeaders::Api.new(url) api.timeout.should == 6 end end context 'making requests' do let(:api) { XboxLeaders::Api.new(url) } it 'validates the gamertag' do VCR.use_cassette('profile') do lambda { api.fetch_profile('Major Nelson') }.should_not raise_exception end VCR.use_cassette('bad_profile') do lambda { api.fetch_profile('fajdkfjdife99fgsd<F2>') }.should raise_exception end end it 'fetches a profile' do VCR.use_cassette('profile') do response = api.fetch_profile('Major Nelson') response['gamertag'].should == 'Major Nelson' end end it 'fetches a list of games' do VCR.use_cassette('games') do response = api.fetch_games('Major Nelson') response['games'].count.should be > 0 end end it 'fetches a list of achievements' do VCR.use_cassette('achievements') do response = api.fetch_achievements('Major Nelson', '1297287449') response['game'].should_not be_nil end end it 'fetches a list of friends' do VCR.use_cassette('friends') do response = api.fetch_friends('Major Nelson') response['total'].should be > 0 end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
xbox_leaders-3.0.0 | spec/xbox_leaders/api_spec.rb |