Sha256: f6ba7b03d507353f33d0068f21594069ca5fd217b0af0d0cae83c9330b13bd02

Contents?: true

Size: 1.72 KB

Versions: 1

Compression:

Stored size: 1.72 KB

Contents

require 'rest-more/test'

describe RC::Facebook::Error do
  after do
    WebMock.reset!
  end

  would 'have the right ancestors' do
    RC::Facebook::Error::AccessToken.should.lt RC::Facebook::Error

    RC::Facebook::Error::InvalidAccessToken.should.lt \
      RC::Facebook::Error::AccessToken

    RC::Facebook::Error::MissingAccessToken.should.lt \
      RC::Facebook::Error::AccessToken
  end

  def error2env hash
    {RC::RESPONSE_BODY => hash,
     RC::REQUEST_PATH  => '/' ,
     RC::REQUEST_QUERY => {}}
  end

  would 'parse right' do
    %w[OAuthInvalidTokenException OAuthException].each{ |type|
      RC::Facebook::Error.call(error2env('error' => {'type' => type})).
        should.kind_of?(RC::Facebook::Error::InvalidAccessToken)
    }

    RC::Facebook::Error.call(
      error2env('error'=>{'type'   =>'QueryParseException',
                          'message'=>'An active access token..'})).
      should.kind_of?(RC::Facebook::Error::MissingAccessToken)

    RC::Facebook::Error.call(
      error2env('error'=>{'type'   =>'QueryParseException',
                          'message'=>'Oh active access token..'})).
      should.not.kind_of?(RC::Facebook::Error::MissingAccessToken)

    RC::Facebook::Error.call(error2env('error_code' => 190)).
      should.kind_of?(RC::Facebook::Error::InvalidAccessToken)

    RC::Facebook::Error.call(error2env('error_code' => 104)).
      should.kind_of?(RC::Facebook::Error::MissingAccessToken)

    RC::Facebook::Error.call(error2env('error_code' => 999)).
      should.not.kind_of?(RC::Facebook::Error::AccessToken)

    error = RC::Facebook::Error.call(error2env(['not a hash']))
    error.should.not.kind_of?(RC::Facebook::Error::AccessToken)
    error.should    .kind_of?(RC::Facebook::Error)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rest-more-3.4.0 test/facebook/test_error.rb