Sha256: 8a13781f97c6af7519b66847812580d9a4246a8f3108fdf0d095097b98bdf305

Contents?: true

Size: 783 Bytes

Versions: 1

Compression:

Stored size: 783 Bytes

Contents

require 'rest-more/test'

describe RC::Dropbox do
  after do
    WebMock.reset!
    Muack.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').tap{}
    }.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

1 entries across 1 versions & 1 rubygems

Version Path
rest-more-3.0.0 test/dropbox/test_api.rb