Sha256: 0f4042f1ba8ba977b1384f0bc2ba5378b515d7952692a5a52adc454cd76c4e8a

Contents?: true

Size: 799 Bytes

Versions: 1

Compression:

Stored size: 799 Bytes

Contents

require 'rest-more/test'

describe RestCore::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

1 entries across 1 versions & 1 rubygems

Version Path
rest-more-0.7.1 test/client/twitter/test_api.rb