Sha256: 7df92abe9ed88e073ec3cc8ec91332eaeba0d413273c3d3dae9d6350c0bee94d

Contents?: true

Size: 997 Bytes

Versions: 4

Compression:

Stored size: 997 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
      end
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
moip2-0.1.4 spec/moip2_spec.rb
moip2-0.1.3 spec/moip2_spec.rb
moip2-0.1.1 spec/moip2_spec.rb
moip2-0.1.0 spec/moip2_spec.rb