spec/unit/braintree/configuration_spec.rb in braintree-2.90.0 vs spec/unit/braintree/configuration_spec.rb in braintree-2.91.0

- old
+ new

@@ -165,10 +165,23 @@ it "lazily initializes so that you can do Braintree::Configuration.logger.level = when configuring the client lib" do config = Braintree::Configuration.new :logger => nil config.logger.should_not == nil end + + it "can set logger on gateway instance" do + gateway = Braintree::Configuration.gateway + old_logger = Braintree::Configuration.logger + + new_logger = Logger.new("/dev/null") + + gateway.config.logger = new_logger + + expect(gateway.config.logger).to eq(new_logger) + + gateway.config.logger = old_logger + end end describe "self.environment" do it "raises an exception if it hasn't been set yet" do Braintree::Configuration.instance_variable_set(:@environment, nil) @@ -181,10 +194,18 @@ Braintree::Configuration.instance_variable_set(:@environment, "") expect do Braintree::Configuration.environment end.to raise_error(Braintree::ConfigurationError, "Braintree::Configuration.environment needs to be set") end + + it "converts environment to symbol" do + config = Braintree::Configuration.new({ + :environment => "sandbox" + }) + + expect(config.environment).to eq(:sandbox) + end end describe "self.gateway" do it "sets its proxy config" do Braintree::Configuration.proxy_address = "localhost" @@ -330,9 +351,25 @@ end it "is https for sandbox" do Braintree::Configuration.environment = :sandbox Braintree::Configuration.instantiate.protocol.should == "https" + end + end + + describe "graphql_server" do + it "is localhost or GRAPHQL_HOST environment variable for development" do + Braintree::Configuration.environment = :development + old_gateway_url = ENV['GRAPHQL_HOST'] + begin + ENV['GRAPHQL_HOST'] = nil + Braintree::Configuration.instantiate.graphql_server.should == "graphql.bt.local" + + ENV['GRAPHQL_HOST'] = 'gateway' + Braintree::Configuration.instantiate.graphql_server.should == 'gateway' + ensure + ENV['GRAPHQL_HOST'] = old_gateway_url + end end end describe "server" do it "is localhost or GATEWAY_HOST environment variable for development" do