test/helper.rb in peddler-1.1.1 vs test/helper.rb in peddler-1.2.0
- old
+ new
@@ -1,8 +1,8 @@
require 'simplecov'
require 'coveralls'
-require 'peddler/test/vcr_matcher'
+require 'peddler/vcr_matcher'
SimpleCov.formatters = [
SimpleCov::Formatter::HTMLFormatter,
Coveralls::SimpleCov::Formatter
]
@@ -38,32 +38,35 @@
break
end
end
end
-# Sets up clients and bootstraps VCR for integration tests
-class IntegrationTest < MiniTest::Test
+# Bootstraps VCR
+module Recorder
def setup
- ENV['LIVE'] ? VCR.turn_off! : VCR.insert_cassette(api)
+ ENV['LIVE'] ? VCR.turn_off! : VCR.insert_cassette(test_name)
end
def teardown
VCR.eject_cassette if VCR.turned_on?
end
+ def test_name
+ self.class.name.sub('Test', '')
+ end
+end
+
+# Sets up clients for integration testing
+class IntegrationTest < MiniTest::Test
+ include Recorder
+
def clients
Accounts.map do |account|
- klass = MWS.const_get("#{api}::Client")
+ klass = MWS.const_get("#{test_name}::Client")
klass.new(account)
end
end
-
- private
-
- def api
- self.class.name.sub('Test', '')
- end
end
VCR.configure do |c|
c.hook_into :excon
c.cassette_library_dir = 'test/vcr_cassettes'
@@ -72,10 +75,10 @@
c.before_record do |interaction|
code = interaction.response.status.code
interaction.ignore! if code >= 400 && code != 414
end
c.default_cassette_options = {
- match_requests_on: [::Peddler::Test::VCRMatcher],
+ match_requests_on: [::Peddler::VCRMatcher],
record: !ENV['RECORD'] ? :none : :new_episodes
}
# So that fixtures do not depend on merchant credentials
Accounts.each do |account|