test/unit/peddler/test_client.rb in peddler-0.9.1 vs test/unit/peddler/test_client.rb in peddler-0.9.2

- old
+ new

@@ -11,18 +11,16 @@ @body = 'foo' Excon.defaults[:mock] = true Excon.stub({}, body: @body, status: 200) @klass = Class.new(Peddler::Client) + @klass.parser = Parser @client = @klass.new - @client.aws_access_key_id = 'key' @client.aws_secret_access_key = 'secret' @client.merchant_id = 'seller' @client.marketplace_id = 'ATVPDKIKX0DER' # US - @client.parser = Parser - @client.operation('Foo') end def teardown Excon.stubs.clear @@ -113,7 +111,26 @@ chunks = '' streamer = ->(chunk, _, _) { chunks << chunk } @client.run(&streamer) assert_equal @body, chunks + end + + def test_request_preserves_user_agent + instrumentor = Class.new + class << instrumentor + attr_accessor :events + + def instrument(name, params = {}) + events.update(name => params) + yield if block_given? + end + end + instrumentor.events = {} + + @client.defaults.update(instrumentor: instrumentor) + @client.run + headers = instrumentor.events['excon.request'][:headers] + + assert headers.has_key?('User-Agent') end end