Sha256: e83e48544c6d7d3c4851ec85ff8cfc935955c20a351b366fe62b61ed63860096

Contents?: true

Size: 987 Bytes

Versions: 4

Compression:

Stored size: 987 Bytes

Contents

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

    let(:moip) do
      described_class.auth = auth
      described_class.new
    end

    it "creates a new Api using default environment" do
      expect(moip.client.env).to eq(:sandbox)
    end

    it "creates a new Api using defined auth" do
      expect(moip.client.auth).to eq(auth)
    end

    it "creates a new Client" do
      expect(moip).to be_a(Moip2::Api)
    end

    it "valid_env comparision rails variable" do
      expect { Moip2.env = :production }.not_to raise_error
    end

    it "invalid enviroment error" do
      expect { Moip2.env = "abc" }.to raise_error(Moip2::InvalidEnviromentError)
    end

    context "when auth is not set" do
      let(:moip) do
        described_class.auth = nil
        described_class.new
      end

      it "raises an error" do
        expect { moip }.to raise_error("Auth is not set")
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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