Sha256: 32d15764dc0b5c853ff2631884345fe182a3681efd7cc3fb5a6a1aa314d56d7d

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

require 'spec_helper'

describe VkontakteApi::Error do
  before(:each) do
    @error_data = Hashie::Mash.new(
      error_code:     5,
      error_msg:      'User authorization failed: invalid access_token.',
      request_params: [
        {
          key:   'oauth',
          value: '1'
        },
        {
          key:   'method',
          value: 'unknownMethod'
        },
        {
          key:   'access_token',
          value: '123'
        }
      ]
    )
  end
  
  describe "#message" do
    context "without parameters" do
      before(:each) do
        @e = VkontakteApi::Error.new(@error_data)
      end
      
      it "returns all needed data about an error" do
        message = 'VKontakte returned an error 5: \'User authorization failed: invalid access_token.\''
        message << ' after calling method \'unknownMethod\' without parameters.'
        
        expect {
          raise @e
        }.to raise_error(@e.class, message)
      end
    end
    
    context "with parameters" do
      before(:each) do
        @error_data[:request_params] << Hashie::Mash.new(key: 'some', value: 'params')
        @e = VkontakteApi::Error.new(@error_data)
      end
      
      it "returns all needed data about an error" do
        message = 'VKontakte returned an error 5: \'User authorization failed: invalid access_token.\''
        message << ' after calling method \'unknownMethod\' with parameters {"some"=>"params"}.'
        
        expect {
          raise @e
        }.to raise_error(@e.class, message)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vkontakte_api-1.2 spec/vkontakte_api/error_spec.rb