test/stripe/stripe_configuration_test.rb in stripe-5.30.0 vs test/stripe/stripe_configuration_test.rb in stripe-5.31.0
- old
+ new
@@ -18,10 +18,11 @@
assert_equal 80, config.read_timeout
assert_equal 30, config.write_timeout
assert_equal "https://api.stripe.com", config.api_base
assert_equal "https://connect.stripe.com", config.connect_base
assert_equal "https://files.stripe.com", config.uploads_base
+ assert_equal nil, config.api_version
end
should "allow for overrides when a block is passed" do
config = Stripe::StripeConfiguration.setup do |c|
c.open_timeout = 100
@@ -39,11 +40,11 @@
should "return a duplicate object with overrides" do
config = Stripe::StripeConfiguration.setup do |c|
c.open_timeout = 100
end
- duped_config = config.reverse_duplicate_merge(read_timeout: 500)
+ duped_config = config.reverse_duplicate_merge(read_timeout: 500, api_version: "2018-08-02")
assert_equal config.open_timeout, duped_config.open_timeout
assert_equal 500, duped_config.read_timeout
end
end
@@ -55,10 +56,28 @@
config.max_network_retries = "10"
assert_equal 10, config.max_network_retries
end
end
+ context "#max_network_retry_delay=" do
+ should "coerce the option into an integer" do
+ config = Stripe::StripeConfiguration.setup
+
+ config.max_network_retry_delay = "10"
+ assert_equal 10, config.max_network_retry_delay
+ end
+ end
+
+ context "#initial_network_retry_delay=" do
+ should "coerce the option into an integer" do
+ config = Stripe::StripeConfiguration.setup
+
+ config.initial_network_retry_delay = "10"
+ assert_equal 10, config.initial_network_retry_delay
+ end
+ end
+
context "#log_level=" do
should "be backwards compatible with old values" do
config = Stripe::StripeConfiguration.setup
config.log_level = "debug"
@@ -79,53 +98,62 @@
context "options that require all connection managers to be cleared" do
should "clear when setting allow ca_bundle_path" do
config = Stripe::StripeConfiguration.setup
- StripeClient.expects(:clear_all_connection_managers)
+ StripeClient.expects(:clear_all_connection_managers).with(config: config)
config.ca_bundle_path = "/path/to/ca/bundle"
end
should "clear when setting open timeout" do
config = Stripe::StripeConfiguration.setup
- StripeClient.expects(:clear_all_connection_managers)
+ StripeClient.expects(:clear_all_connection_managers).with(config: config)
config.open_timeout = 10
end
should "clear when setting read timeout" do
config = Stripe::StripeConfiguration.setup
- StripeClient.expects(:clear_all_connection_managers)
+ StripeClient.expects(:clear_all_connection_managers).with(config: config)
config.read_timeout = 10
end
should "clear when setting uploads_base" do
config = Stripe::StripeConfiguration.setup
- StripeClient.expects(:clear_all_connection_managers)
+ StripeClient.expects(:clear_all_connection_managers).with(config: config)
config.uploads_base = "https://other.stripe.com"
end
- should "clearn when setting api_base to be configured" do
+ should "clear when setting api_base to be configured" do
config = Stripe::StripeConfiguration.setup
- StripeClient.expects(:clear_all_connection_managers)
+ StripeClient.expects(:clear_all_connection_managers).with(config: config)
config.api_base = "https://other.stripe.com"
end
should "clear when setting connect_base" do
config = Stripe::StripeConfiguration.setup
- StripeClient.expects(:clear_all_connection_managers)
+ StripeClient.expects(:clear_all_connection_managers).with(config: config)
config.connect_base = "https://other.stripe.com"
end
should "clear when setting verify_ssl_certs" do
config = Stripe::StripeConfiguration.setup
- StripeClient.expects(:clear_all_connection_managers)
+ StripeClient.expects(:clear_all_connection_managers).with(config: config)
config.verify_ssl_certs = false
+ end
+ end
+
+ context "#key" do
+ should "generate the same key when values are identicial" do
+ assert_equal StripeConfiguration.setup.key, StripeConfiguration.setup.key
+
+ custom_config = StripeConfiguration.setup { |c| c.open_timeout = 1000 }
+ refute_equal StripeConfiguration.setup.key, custom_config.key
end
end
end
end