Sha256: a353dca2a30db8042c0bfdbf92b406ce6cdc69ebddc8ee67ba1bbd052c6fe2ea

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

require "spec_helper"

describe PayPal::Request do
  describe "#post" do
    before :all do
      VCR.eject_cassette
      VCR.turn_off!
    end

    after :all do
      VCR.turn_on!
    end

    let(:uri) { "https://api-3t.sandbox.paypal.com/nvp" }
    let(:username) { "test@api.com" }
    let(:password) { "testpassword" }

    before do
      subject.uri = uri
    end

    it "verifies certificate" do
      stub_request(:post, uri).to_return(:status => 200, :body => "", :headers => {})
      Curl::Easy.any_instance.should_receive(:ssl_verify_host=).with(true)
      Curl::Easy.any_instance.should_receive(:ssl_verify_peer=).with(true)
      subject.post
    end

    it "sets cacert" do
      stub_request(:post, uri).to_return(:status => 200, :body => "", :headers => {})
      Curl::Easy.any_instance.should_receive(:cacert=).with(File.expand_path("../../../lib/paypal/cacert.pem", __FILE__))
      subject.post
    end

    it "sets body" do
      stub_request(:post, uri).with(:body => 'AMT=10.00')
      subject.post({'AMT' => '10.00'})
    end

    it "sets headers" do
      stub_request(:post, uri).with(:headers => {'X-PAYPAL-SECURITY-USERID' => username})
      subject.post({}, {'X-PAYPAL-SECURITY-USERID' => username})
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
paypal-payment-0.1.2 spec/paypal/request_spec.rb