Sha256: f1568115cfa71f24e41181af564be19ce28fda295e736ee6827d95fae80cb19c

Contents?: true

Size: 793 Bytes

Versions: 3

Compression:

Stored size: 793 Bytes

Contents

require 'rest-more/test'

describe RC::Twitter do
  after do
    WebMock.reset!
    RR.verify
  end

  should 'get right' do
    stub_request(:get, 'https://api.twitter.com/me').
      to_return(:body => '{"status": "OK"}')

    RestCore::Twitter.new.get('me').should.eq({'status' => 'OK'})
  end

  def check status, klass
    stub_request(:delete, 'https://api.twitter.com/123').to_return(
      :body => '{}', :status => status)

    lambda{
      RestCore::Twitter.new.delete('123')
    }.should.raise(klass)

    WebMock.reset!
  end

  should 'raise exception when encountering error' do
    [401, 402, 403].each{ |status|
      check(status, RestCore::Twitter::Error)
    }

    [500, 502, 503].each{ |status|
      check(status, RestCore::Twitter::Error::ServerError)
    }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rest-more-0.8.0 test/client/twitter/test_api.rb
rest-more-0.7.2.1 test/client/twitter/test_api.rb
rest-more-0.7.2 test/client/twitter/test_api.rb