Sha256: 76331d12a87af72a0c53168f84de8d321e2d47fa2bbec8cc41c665830f4ec7a0

Contents?: true

Size: 1.77 KB

Versions: 4

Compression:

Stored size: 1.77 KB

Contents

describe Moip2::ConnectClient do
  let(:auth) do
    Moip2::Auth::Basic.new("TOKEN", "SECRET")
  end

  let(:oauth) do
    Moip2::Auth::OAuth.new "9fdc242631454d4c95d82e27b4127394_v2"
  end

  describe "initialize env with string" do
    let(:client) do
      described_class.new "sandbox", auth
    end

    it { expect(client.env).to eq :sandbox }
  end

  describe "initialize on sandbox with OAuth" do
    let(:client) do
      described_class.new :sandbox, oauth
    end

    it { expect(client.uri).to eq "https://connect-sandbox.moip.com.br" }
    it { expect(client.env).to eq :sandbox }
    it do
      expect(client.opts[:headers]["Authorization"]).
        to eq "OAuth 9fdc242631454d4c95d82e27b4127394_v2"
    end
  end

  describe "initialize on production with OAuth" do
    let(:client) do
      described_class.new :production, oauth
    end

    it { expect(client.uri).to eq "https://connect.moip.com.br" }
    it { expect(client.env).to eq :production }
    it do
      expect(client.opts[:headers]["Authorization"]).
        to eq "OAuth 9fdc242631454d4c95d82e27b4127394_v2"
    end
  end

  describe "initialize on sandbox with Basic authentication" do
    let(:client) do
      described_class.new :sandbox, auth
    end

    it { expect(client.uri).to eq "https://connect-sandbox.moip.com.br" }
    it { expect(client.env).to eq :sandbox }
    it { expect(client.opts[:headers]["Authorization"]).to eq "Basic VE9LRU46U0VDUkVU" }
  end

  describe "initialize on production with Basic authentication" do
    let(:client) do
      described_class.new :production, auth
    end

    it { expect(client.uri).to eq "https://connect.moip.com.br" }
    it { expect(client.env).to eq :production }
    it { expect(client.opts[:headers]["Authorization"]).to eq "Basic VE9LRU46U0VDUkVU" }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
moip2-1.3.1 spec/moip2/connect_client_spec.rb
moip2-1.2.1 spec/moip2/connect_client_spec.rb
moip2-1.2.0 spec/moip2/connect_client_spec.rb
moip2-1.1.0 spec/moip2/connect_client_spec.rb