Sha256: e0d0945402c9660c640612ba16e709cfa5eb01a7ca8ceef4d6f42cecc16ec5ea

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

# -*- encoding: utf-8 -*-
require 'spec_helper'

describe KewegoParty::Request do

  before do
    @client = KewegoParty::Client.new(:token => 'd4c804fd0f42533351aca404313d26eb')
  end

  it "raise an exception if the response not a kewego response" do
    VCR.turned_off do
      stub_request(:get, "http://api.kewego.com/app/getToken/?appKey=#{@client.token}").
          to_return(:body => fixture("not_kewego_response.xml"), :headers => {:content_type => "text/html; charset=utf-8"})

      expect {
        @client.app_get_token
      }.to raise_error(KewegoParty::InvalidResponseException)
    end
  end

  it "raise an exception if the response has a kewego error" do
    VCR.turned_off do
      stub_request(:get, "http://api.kewego.com/app/getToken/?appKey=#{@client.token}").
          to_return(:body => fixture("kewego_response_error.xml"), :headers => {:content_type => "text/html; charset=utf-8"})

      expect {
        @client.app_get_token
      }.to raise_error(KewegoParty::ErrorResponseException, 'appToken can not delivered')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kewego_party-0.0.1 spec/kewego_party/client/request_spec.rb