Sha256: 0b07ee2a0111315d46713b006ea8e1b56a16c170a08cf226116086278b87b233

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

require "spec_helper"

describe Moiper::Request do
  describe "#process" do
    it "returns a Response object" do
      response = Moiper::Request.new.process("<someXml></someXml>")
      response.should be_kind_of Moiper::Response
    end
  end

  describe "#client" do
    let(:client) { Moiper::Request.new.client }

    it "uses SSL" do
      client.use_ssl?.should be_true
    end

    it "verifies the certificate" do
      client.verify_mode.should == OpenSSL::SSL::VERIFY_PEER
    end

    it "uses the right ca file" do
      client.ca_file.should == Moiper::Request::CA_FILE
    end
  end

  describe "#request" do
    subject { Moiper::Request.new.request }
    its(:content_type) { should eq "text/xml" }

    it "sets the correct token and key parameters" do
      Net::HTTP::Post.any_instance.should_receive(:basic_auth).with(Moiper.token, Moiper.key)
      Moiper::Request.new.request
    end

    it "has the correct user agent" do
      headers = Hash[subject.each_capitalized.to_a]
      headers["User-Agent"].should eq "Moiper/#{Moiper::VERSION}"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
moiper-0.1.1 spec/moiper/request_spec.rb
moiper-0.1.0 spec/moiper/request_spec.rb
moiper-0.0.1 spec/moiper/request_spec.rb