Skip to content

Commit

Permalink
Only load AWS test credentials once
Browse files Browse the repository at this point in the history
Whenever the tests run, the following error appeared:

    warning: already initialized constant AWSTestCredentials

This moves the AWSTestCredentials init from the individual specs to a
spec helper class: `spec/support/helpers/amazon_helpers.rb`.
  • Loading branch information
leesharma committed Nov 29, 2017
1 parent 487a308 commit 54fa761
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 1 addition & 2 deletions spec/lib/amazon_product_api/item_lookup_endpoint_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# frozen_string_literal: true

require 'amazon_product_api/item_lookup_endpoint'
require 'support/helpers/amazon_helpers'

describe AmazonProductAPI::ItemLookupEndpoint do
AWSTestCredentials = Struct.new(:access_key, :secret_key, :associate_tag)

let(:aws_credentials) {
AWSTestCredentials.new('aws_access_key',
'aws_secret_key',
Expand Down
3 changes: 1 addition & 2 deletions spec/lib/amazon_product_api/item_search_endpoint_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# frozen_string_literal: true

require 'amazon_product_api/item_search_endpoint'
require 'support/helpers/amazon_helpers'

describe AmazonProductAPI::ItemSearchEndpoint do
AWSTestCredentials = Struct.new(:access_key, :secret_key, :associate_tag)

let(:aws_credentials) {
AWSTestCredentials.new('aws_access_key',
'aws_secret_key',
Expand Down
6 changes: 6 additions & 0 deletions spec/support/helpers/amazon_helpers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

# Mocks an AWS Credentials object
AWSTestCredentials = Struct.new(:access_key,
:secret_key,
:associate_tag)

0 comments on commit 54fa761

Please sign in to comment.