Sha256: ae1d908ed6f15399526b92f17ae8dcd7e0fb821b47d8be95dca61b144274da91

Contents?: true

Size: 1.71 KB

Versions: 3

Compression:

Stored size: 1.71 KB

Contents

require "helper"

RSpec.describe Affirm::Configuration do
  after { restore_config }

  context "when public_api_key is specified" do
    before do
      Affirm.configure do |config|
        config.public_api_key = "abc"
      end
    end

    it "returns public api key" do
      expect(Affirm.configuration.public_api_key).to eq("abc")
    end
  end

  context "when private_api_key is specified" do
    before do
      Affirm.configure do |config|
        config.private_api_key = "xyz"
      end
    end

    it "returns private api key" do
      expect(Affirm.configuration.private_api_key).to eq("xyz")
    end
  end

  context "when environment is not specified" do
    before do
      Affirm.configure {}
    end

    it "defaults to production" do
      expect(Affirm.configuration.environment).to eq(:production)
    end
  end

  context "when environment is set to production" do
    before do
      Affirm.configure do |config|
        config.environment = :production
      end
    end

    it "sets environment to production" do
      expect(Affirm.configuration.environment).to eq(:production)
    end

    it "sets endpoint to production" do
      expect(Affirm.configuration.endpoint).to eq("https://api.affirm.com")
    end
  end

  context "when environment is set to sandbox" do
    before do
      Affirm.configure do |config|
        config.environment = :sandbox
      end
    end

    it "sets environment to sandbox" do
      expect(Affirm.configuration.environment).to eq(:sandbox)
    end

    it "sets endpoint to sandbox" do
      expect(Affirm.configuration.endpoint).to eq("https://sandbox.affirm.com")
    end
  end

  private

  def restore_config
    Affirm.configuration = nil
    Affirm.configure {}
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
affirm-ruby-1.0.1 spec/configuration_spec.rb
affirm-ruby-1.0.0 spec/configuration_spec.rb
affirm-ruby-0.0.1 spec/configuration_spec.rb