Sha256: 4456e5f6ad3b8500b4785ee6d2271e95f8f2fbbaf3d65085bcb7aed4ad2d5441

Contents?: true

Size: 817 Bytes

Versions: 3

Compression:

Stored size: 817 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/1/account/verify_credentials.json').
      to_return(:body => '{"status": "OK"}')

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

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

    lambda{
      RC::Twitter.new.delete('123').tap{}
    }.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-2.0.3 test/twitter/test_api.rb
rest-more-2.0.2 test/twitter/test_api.rb
rest-more-2.0.0 test/twitter/test_api.rb