Sha256: f02a44adef9eb01d106a4ee4f07504a7b19a8c000b7f8bc62099a4fa0568500e

Contents?: true

Size: 774 Bytes

Versions: 3

Compression:

Stored size: 774 Bytes

Contents

require 'rest-more/test'

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

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

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

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

    lambda{
      RC::Dropbox.new.delete('123')
    }.should.raise(klass)

    WebMock.reset!
  end

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rest-more-1.0.2 test/dropbox/test_api.rb
rest-more-1.0.1 test/dropbox/test_api.rb
rest-more-1.0.0 test/dropbox/test_api.rb