Sha256: e185b9127aeef430aafec6c39046677060b04cce3cc5f1ac02d059a2a3346d18

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

if respond_to?(:require_relative, true)
  require_relative 'common'
else
  require File.dirname(__FILE__) + '/common'
end

describe RestGraph::Error do
  after do
    WebMock.reset_webmock
    RR.verify
  end

  should 'have the right ancestors' do
    RestGraph::Error::AccessToken       .should < RestGraph::Error

    RestGraph::Error::InvalidAccessToken.should <
      RestGraph::Error::AccessToken

    RestGraph::Error::MissingAccessToken.should <
      RestGraph::Error::AccessToken
  end

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

    RestGraph::Error.parse('error' => {'type' => 'QueryParseException',
                                    'message' => 'An active access token..'}).
      should.kind_of?(RestGraph::Error::MissingAccessToken)

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

    RestGraph::Error.parse('error_code' => 190).
      should.kind_of?(RestGraph::Error::InvalidAccessToken)

    RestGraph::Error.parse('error_code' => 104).
      should.kind_of?(RestGraph::Error::MissingAccessToken)

    RestGraph::Error.parse('error_code' => 999).
      should.not.kind_of?(RestGraph::Error::AccessToken)

    error = RestGraph::Error.parse(['not a hash'])
    error.should.not.kind_of?(RestGraph::Error::AccessToken)
    error.should    .kind_of?(RestGraph::Error)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rest-graph-1.6.0 test/test_error.rb