Sha256: 1af9da98b3844c094e95fe1de660186b047c6c3a029d9b5030fa736b0b955845

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

require 'spec_helper'

describe XboxLeaders::Api do
  describe '#initialize' do
    it 'allows a specified timeout in seconds' do
      api = XboxLeaders::Api.new(10)
      api.timeout.should == 10
    end

    it 'defaults to a 6-second timeout' do
      api = XboxLeaders::Api.new
      api.timeout.should == 6
    end
  end

  context 'making requests' do
    it 'validates the gamertag' do
      api = XboxLeaders::Api.new
      lambda { api.fetch_profile('Major Nelson') }.should_not raise_exception
      lambda { api.fetch_profile('fajdkfjdife99fgsd<F2>') }.should raise_exception
    end

    it 'fetches a profile' do
      response = XboxLeaders::Api.new.fetch_profile('Major Nelson')
      response['gamertag'].should == 'Major Nelson'
    end

    it 'fetches a list of games' do
      response = XboxLeaders::Api.new.fetch_games('Major Nelson')
      response['games'].count.should be > 0
    end

    it 'fetches a list of achievements' do
      response = XboxLeaders::Api.new.fetch_achievements('Major Nelson', '1297287449')
      response['game'].should_not be_nil
    end

    it 'fetches a list of friends' do
      response = XboxLeaders::Api.new.fetch_friends('Major Nelson')
      response['total'].should be > 0
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xbox_leaders-2.0.0 spec/xbox_leaders/api_spec.rb