Sha256: 1ada7dbf7bc7b1bbc898d7ce077d9524bc7166d03698f363afd1aa316cd7520b
Contents?: true
Size: 1.25 KB
Versions: 3
Compression:
Stored size: 1.25 KB
Contents
require "spec_helper" describe Rexpense::Request do describe "#run" do subject { described_class.new({ method: 'post', params: {}, url: 'https://sandbox.rexpense.com', user_agent: 'My Test User-Agent', token: 'my-auth-hash' }) } it "does a request using Typhoeus::Request" do expect(Typhoeus::Request).to receive(:new).with("https://sandbox.rexpense.com", { method: "post", params: {}, headers: { "Accept" => "application/json", "Content-Type" => "application/json", "User-Agent" => "My Test User-Agent", "Authorization" => "Basic bXktYXV0aC1oYXNoOlg=" }, accept_encoding: "gzip", params_encoding: :rack }).and_return(double(run: true, response: true)) subject.run end it "invokes Typhoeus::Request#run" do expect_any_instance_of(Typhoeus::Request).to receive(:run) subject.run end it "invokes Typhoeus::Request#response" do allow_any_instance_of(Typhoeus::Request).to receive(:run) expect_any_instance_of(Typhoeus::Request).to receive(:response) subject.run end it "generates the base 64 of the user token" do allow_any_instance_of(Typhoeus::Request).to receive(:run) expect(Base64).to receive(:strict_encode64).with("my-auth-hash:X").and_call_original subject.run end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rexpense-2.1.0 | spec/lib/rexpense/request_spec.rb |
rexpense-2.0.0 | spec/lib/rexpense/request_spec.rb |
rexpense-1.0.0 | spec/lib/rexpense/request_spec.rb |