Sha256: a514a8bc62288af65b2488fa7a5ca2c7baa5604f7824bdbfbb494146dc354a1e

Contents?: true

Size: 1.68 KB

Versions: 3

Compression:

Stored size: 1.68 KB

Contents

describe Veritrans::Config do

  before do
    hide_const("Rails")
  end

  it "should set Veritras as self inside config block" do
    Veritrans.config do
      self.should == Veritrans
    end
  end

  it "should have sandbox api_host by defualt" do
    Veritrans.config.api_host.should == "https://api.sandbox.veritrans.co.id"
  end

  it "should set client key and server key" do
    Veritrans.config do
      config.client_key = "kk-1"
      config.server_key = "sk-1"
    end

    Veritrans.config.client_key.should == "kk-1"
    Veritrans.config.server_key.should == "sk-1"
  end

  it "should load config" do
    data = Veritrans.config.load_config("./spec/configs/veritrans_flat.yml")
    data.should == {"client_key" => "flat_client_key", "server_key" => "flat_server_key"}
  end

  it "should load config according to hash" do
    data = Veritrans.config.load_config("./spec/configs/veritrans.yml#development")
    data.should == {"client_key" => "spec_client_key", "server_key" => "spec_server_key"}
  end

  it "should load config for Rails.env" do
    stub_const("Rails", Class.new {
      def self.env
        "test"
      end
    })

    data = Veritrans.config.load_config("./spec/configs/veritrans.yml")
    data.should == {"client_key" => "test_client_key", "server_key" => "test_server_key"}
  end

  it "should validate http_params type" do
    expect {
      Veritrans.config.http_options = nil
    }.to raise_error(ArgumentError, "http_options should be a hash")
  end

  it "should validate http_params type" do
    expect {
      Veritrans.config.http_options = {foo: "bar", tcp_nodelay: true}
    }.to raise_error(ArgumentError, /http_options contain unsupported keys: \[:foo\]/)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
veritrans-2.0.4 spec/veritrans_config_spec.rb
veritrans-2.0.3 spec/veritrans_config_spec.rb
veritrans-2.0.2 spec/veritrans_config_spec.rb