agcod 0.0.4 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,9 +1,14 @@
1
+ *.gem
1
2
  *.sw?
2
3
  .DS_Store
4
+ .bundle
5
+ .rvmrc
6
+ Gemfile.lock
7
+ agcod_cucumber.log
3
8
  coverage
4
- rdoc
5
- pkg
6
9
  features/support/app_root/config/agcod.yml
7
- log
8
- agcod_cucumber.log
9
10
  features/support/certification_requests
11
+ log
12
+ pkg/*
13
+ rdoc
14
+ vendor/bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in agcod.gemspec
4
+ gemspec
data/Rakefile CHANGED
@@ -1,27 +1,13 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "agcod"
8
- gem.summary = %Q{A Wrapper for Amazon Gift Cards On Demand}
9
- gem.email = "dpickett@enlightsolutions.com"
10
- gem.homepage = "http://github.com/dpickett/agcod"
11
- gem.authors = ["Dan Pickett"]
12
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
13
- end
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
14
3
 
15
- rescue LoadError
16
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
4
+ Rake::TestTask.new('test') do |t|
5
+ t.libs << 'lib' << 'test'
6
+ t.pattern = 'test/**/*_test.rb'
7
+ t.verbose = true
17
8
  end
18
9
 
19
- require 'rake/testtask'
20
- Rake::TestTask.new(:test) do |test|
21
- test.libs << 'lib' << 'test'
22
- test.pattern = 'test/**/*_test.rb'
23
- test.verbose = true
24
- end
10
+ task :default => :test
25
11
 
26
12
  begin
27
13
  require 'rcov/rcovtask'
@@ -37,30 +23,17 @@ rescue LoadError
37
23
  end
38
24
  end
39
25
 
40
- begin
41
- require 'cucumber/rake/task'
42
- Cucumber::Rake::Task.new(:features)
43
- rescue LoadError
44
- task :features do
45
- abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
46
- end
47
- end
26
+ require 'cucumber/rake/task'
27
+ Cucumber::Rake::Task.new(:features)
48
28
 
49
29
  require File.join(File.dirname(__FILE__), "lib", "agcod", "tasks")
50
30
 
51
- task :default => :spec
52
-
53
- require 'rake/rdoctask'
31
+ require 'rdoc/task'
54
32
  Rake::RDocTask.new do |rdoc|
55
- if File.exist?('VERSION.yml')
56
- config = YAML.load(File.read('VERSION.yml'))
57
- version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
58
- else
59
- version = ""
60
- end
33
+ require 'agcod/version'
61
34
 
62
35
  rdoc.rdoc_dir = 'rdoc'
63
- rdoc.title = "agcod #{version}"
36
+ rdoc.title = "agcod #{ Agcod::VERSION }"
64
37
  rdoc.rdoc_files.include('README*')
65
38
  rdoc.rdoc_files.include('lib/**/*.rb')
66
39
  end
@@ -1,74 +1,27 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "agcod/version"
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = %q{agcod}
8
- s.version = "0.0.4"
6
+ s.name = "agcod"
7
+ s.version = Agcod::VERSION
8
+ s.authors = ["Dan Pickett"]
9
+ s.email = %q{dpickett@enlightsolutions.com}
10
+ s.homepage = %q{http://github.com/dpickett/agcod}
11
+ s.summary = %q{A Wrapper for Amazon Gift Codes On Demand}
12
+ s.description = %q{Access the Amazon API to order gift codes}
9
13
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Dan Pickett"]
12
- s.date = %q{2010-11-18}
13
- s.email = %q{dpickett@enlightsolutions.com}
14
- s.extra_rdoc_files = [
15
- "LICENSE",
16
- "README.rdoc"
17
- ]
18
- s.files = [
19
- ".document",
20
- ".gitignore",
21
- "LICENSE",
22
- "README.rdoc",
23
- "Rakefile",
24
- "VERSION",
25
- "agcod.gemspec",
26
- "cucumber.yml",
27
- "features/error_handling.feature",
28
- "features/step_definitions/agcod_steps.rb",
29
- "features/success_certification.feature",
30
- "features/support/app_root/config/agcod.example.yml",
31
- "features/support/env.rb",
32
- "lib/agcod.rb",
33
- "lib/agcod/cancel_gift_card.rb",
34
- "lib/agcod/configuration.rb",
35
- "lib/agcod/create_gift_card.rb",
36
- "lib/agcod/error/configuration_error.rb",
37
- "lib/agcod/error/invalid_parameter.rb",
38
- "lib/agcod/health_check.rb",
39
- "lib/agcod/option_validators.rb",
40
- "lib/agcod/request.rb",
41
- "lib/agcod/tasks.rb",
42
- "lib/agcod/tasks/certification.rake",
43
- "lib/agcod/void_gift_card_creation.rb",
44
- "manual_features/cancel_claimed_giftcard.feature",
45
- "manual_features/insufficient_funds.feature",
46
- "manual_features/retry_and_http.feature",
47
- "tasks/agcod.rake",
48
- "test/agcod/configuration_test.rb",
49
- "test/app_root/config/agcod.yml",
50
- "test/macros/configuration.rb",
51
- "test/test_helper.rb"
52
- ]
53
- s.homepage = %q{http://github.com/dpickett/agcod}
54
- s.rdoc_options = ["--charset=UTF-8"]
55
- s.require_paths = ["lib"]
56
- s.rubygems_version = %q{1.3.7}
57
- s.summary = %q{A Wrapper for Amazon Gift Cards On Demand}
58
- s.test_files = [
59
- "test/agcod/configuration_test.rb",
60
- "test/macros/configuration.rb",
61
- "test/test_helper.rb"
62
- ]
14
+ s.rubyforge_project = "agcod"
63
15
 
64
- if s.respond_to? :specification_version then
65
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
66
- s.specification_version = 3
16
+ s.add_development_dependency 'cucumber'
17
+ s.add_development_dependency 'fakeweb'
18
+ s.add_development_dependency 'mocha'
19
+ s.add_development_dependency 'rake'
20
+ s.add_development_dependency 'rspec'
21
+ s.add_development_dependency 'shoulda'
67
22
 
68
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
69
- else
70
- end
71
- else
72
- end
23
+ s.files = `git ls-files`.split("\n")
24
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
25
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
26
+ s.require_paths = ["lib"]
73
27
  end
74
-
@@ -7,8 +7,7 @@ require 'rexml/document'
7
7
  require "uri"
8
8
  require "cgi"
9
9
  require "base64"
10
- require "hmac-sha1"
11
- require "digest/sha1"
10
+ require 'openssl'
12
11
  require "cgi"
13
12
  require "logger"
14
13
 
@@ -1,12 +1,12 @@
1
1
  module Agcod
2
2
  class Configuration
3
- REQUIRED_OPTIONS = ["access_key",
3
+ REQUIRED_OPTIONS = ["access_key",
4
4
  "secret_key",
5
5
  "partner_id",
6
6
  "uri",
7
7
  "discount_percentage"
8
- ]
9
-
8
+ ]
9
+
10
10
  class << self
11
11
  attr_reader :options
12
12
  attr_accessor :logger
@@ -17,11 +17,11 @@ module Agcod
17
17
  else
18
18
  @app_root = Rails.root if defined?(Rails)
19
19
  end
20
-
21
- if @app_root.nil? ||
20
+
21
+ if @app_root.nil? ||
22
22
  !FileTest.exists?(config_filename = File.join(@app_root, 'config', 'agcod.yml'))
23
-
24
- raise Error::ConfigurationError, "Configuration for AGCOD not found"
23
+
24
+ raise Error::ConfigurationError, "Configuration for AGCOD not found"
25
25
  end
26
26
 
27
27
  config_file = File.read(config_filename)
@@ -30,6 +30,7 @@ module Agcod
30
30
  environment = env if env
31
31
 
32
32
  @options = YAML.load(config_file)[environment]
33
+ raise Error::ConfigurationError, "Configuration for AGCOD (#{ environment } environment) not found" unless @options
33
34
  validate_options
34
35
  @options
35
36
  end
@@ -41,7 +42,7 @@ module Agcod
41
42
  validate_options
42
43
  @options
43
44
  end
44
-
45
+
45
46
  def access_key
46
47
  @options["access_key"]
47
48
  end
@@ -62,14 +63,18 @@ module Agcod
62
63
  @options["discount_percentage"]
63
64
  end
64
65
 
66
+ def verify_mode
67
+ @options["verify_mode"]
68
+ end
69
+
65
70
  private
66
-
71
+
67
72
  def validate_options
68
73
  REQUIRED_OPTIONS.each do |opt|
69
74
  if options[opt].nil? || options[opt] == ""
70
- raise Error::ConfigurationError, "#{opt} was not specified"
75
+ raise Error::ConfigurationError, "#{opt} was not specified"
71
76
  end
72
- end
77
+ end
73
78
  end
74
79
  end
75
80
  end
@@ -35,7 +35,8 @@ module Agcod
35
35
  #remove all the = and & from the serialized string
36
36
  sanitized_string = string_to_sign.gsub(/=|&/, "")
37
37
  # puts sanitized_string
38
- sha1 = HMAC::SHA1::digest(Agcod::Configuration.secret_key, sanitized_string)
38
+ digest = OpenSSL::Digest::Digest.new('sha1')
39
+ sha1 = OpenSSL::HMAC.digest(digest, Agcod::Configuration.secret_key, sanitized_string)
39
40
 
40
41
  #Base64 encoding adds a linefeed to the end of the string so chop the last character!
41
42
  CGI.escape(Base64.encode64(sha1).chomp)
@@ -49,12 +50,15 @@ module Agcod
49
50
  @response_id || @options["response_id"]
50
51
  end
51
52
 
52
- protected
53
+ def request_url
54
+ "#{ Agcod::Configuration.uri }?#{ build_sorted_and_signed_request_string }"
55
+ end
56
+
57
+ protected
53
58
 
54
59
  def process_response
55
60
  parse_response
56
61
 
57
-
58
62
  @errors = []
59
63
 
60
64
  self.xml_response.root.elements.each("Error") do |e|
@@ -63,6 +67,12 @@ module Agcod
63
67
 
64
68
  @status = self.xml_response.root.elements["Status/statusCode"].text unless xml_response.root.elements["Status/statusCode"].nil?
65
69
 
70
+ # in some cases we have a failure and no Error elements. Check for
71
+ # a status message in this case
72
+ if @status == 'FAILURE'
73
+ @errors << self.xml_response.root.elements["Status/statusMessage"].text unless xml_response.root.elements["Status/statusMessage"].nil?
74
+ end
75
+
66
76
  #something happened before it got to ACGWS (most likely a signature problem)
67
77
  @status = "FAILURE" if self.errors.size > 0 && self.status.blank?
68
78
 
@@ -76,24 +86,29 @@ module Agcod
76
86
  def attempt_retry
77
87
  #check for retry error
78
88
  if self.xml_response.root.elements["Status/errorCode"] &&
79
- self.xml_response.root.elements["Status/errorCode"].text == "E100" &&
80
- !@sent_retry
81
-
89
+ self.xml_response.root.elements["Status/errorCode"].text == "E100" &&
90
+ ! @sent_retry
91
+ then
82
92
  @sent_retry = true
83
- submit
93
+ submit
84
94
  end
85
95
  end
86
96
 
87
- protected
88
97
  def send_request
89
98
  #send the request
90
- uri = URI.parse(Agcod::Configuration.uri)
99
+ uri = URI.parse request_url
91
100
  http = Net::HTTP.new(uri.host, uri.port)
92
101
  http.read_timeout = 20
93
102
  http.open_timeout = 20
94
103
  http.use_ssl = true
95
104
 
96
- net_response, @response = http.get(uri.path + "?" + self.request)
105
+ if Agcod::Configuration.verify_mode
106
+ http.verify_mode = Agcod::Configuration.verify_mode.constantize
107
+ end
108
+
109
+ @response = @xml_response = nil
110
+ net_response, @response = http.get(uri.path + "?" + uri.query)
111
+ @response ||= net_response.read_body
97
112
 
98
113
  @sent = true
99
114
  end
@@ -101,15 +116,15 @@ module Agcod
101
116
  def default_parameters
102
117
  @timestamp = Time.now.utc
103
118
  {
104
- "Action" => self.action,
105
- "AWSAccessKeyId" => Agcod::Configuration.access_key,
106
- "SignatureVersion" => "1",
107
- "MessageHeader.recipientId" => "AMAZON",
108
- "MessageHeader.sourceId" => Agcod::Configuration.partner_id,
109
- "MessageHeader.retryCount" => "0",
119
+ "Action" => self.action,
120
+ "AWSAccessKeyId" => Agcod::Configuration.access_key,
121
+ "SignatureVersion" => "1",
122
+ "MessageHeader.recipientId" => "AMAZON",
123
+ "MessageHeader.sourceId" => Agcod::Configuration.partner_id,
124
+ "MessageHeader.retryCount" => "0",
110
125
  "MessageHeader.contentVersion" => "2008-01-01",
111
- "MessageHeader.messageType" => self.action + "Request",
112
- "Timestamp" => @timestamp.strftime("%Y-%m-%dT%H:%M:%S") + ".000Z"
126
+ "MessageHeader.messageType" => self.action + "Request",
127
+ "Timestamp" => @timestamp.strftime("%Y-%m-%dT%H:%M:%S") + ".000Z"
113
128
  }
114
129
  end
115
130
 
@@ -144,7 +159,7 @@ module Agcod
144
159
  log_string << " \##{self.request_id}" if self.request_id
145
160
  log_string << " received response #{self.response_id}" if self.response_id
146
161
  if self.respond_to?(:claim_code) && self.claim_code
147
- log_string << " received claim_code #{self.claim_code}"
162
+ log_string << " received claim_code #{self.claim_code}"
148
163
  end
149
164
  Agcod::Configuration.logger.debug log_string
150
165
  end
@@ -0,0 +1,3 @@
1
+ module Agcod
2
+ VERSION = "0.0.6"
3
+ end
@@ -14,7 +14,7 @@ class Agcod::ConfigurationTest < Test::Unit::TestCase
14
14
  end
15
15
 
16
16
  should "raise an error if the configuration file isn't specified" do
17
- assert_raise Agcod::Error::ConfigurationError do
17
+ assert_raise Agcod::Error::ConfigurationError do
18
18
  Agcod::Configuration.load
19
19
  end
20
20
  end
@@ -25,22 +25,28 @@ class Agcod::ConfigurationTest < Test::Unit::TestCase
25
25
  end
26
26
  end
27
27
 
28
+ should "raise an error if the environment key is not included in the config file" do
29
+ assert_raise Agcod::Error::ConfigurationError do
30
+ Agcod::Configuration.load(File.join(File.dirname(__FILE__), "..", "app_root"), "staging")
31
+ end
32
+ end
33
+
28
34
  should "read configuration from a supplied app root" do
29
35
  Agcod::Configuration.load(File.join(File.dirname(__FILE__), "..", "app_root"), "test")
30
36
  Agcod::Configuration::REQUIRED_OPTIONS.each do |opt|
31
37
  assert_not_nil Agcod::Configuration.send(opt)
32
38
  end
33
39
  end
34
-
40
+
35
41
  should "allow me to set config options at runtime" do
36
42
  Agcod::Configuration.set(@valid_options)
37
43
  assert_equal Agcod::Configuration.access_key, @valid_options["access_key"]
38
44
  end
39
45
 
40
46
  should_require_config_options [
41
- "access_key",
42
- "secret_key",
43
- "partner_id",
47
+ "access_key",
48
+ "secret_key",
49
+ "partner_id",
44
50
  "uri",
45
51
  "discount_percentage"
46
52
  ]
@@ -50,6 +56,7 @@ class Agcod::ConfigurationTest < Test::Unit::TestCase
50
56
  setup do
51
57
  configure_with_valid_options
52
58
  @log_path = File.join(File.dirname(__FILE__), "..", "log", "test.log")
59
+ FileUtils.mkdir_p(File.dirname(@log_path))
53
60
  FileUtils.touch(@log_path)
54
61
  @logger = Logger.new(@log_path)
55
62
  @logger.level = Logger::DEBUG
@@ -57,7 +64,7 @@ class Agcod::ConfigurationTest < Test::Unit::TestCase
57
64
  Agcod::Configuration.logger = @logger
58
65
 
59
66
  FakeWeb.allow_net_connect = false
60
-
67
+
61
68
  @request = Agcod::CreateGiftCard.new("request_id" => 34234, "value" => 12)
62
69
  @request.stubs(:response_id).returns(4323535)
63
70
  @request.stubs(:send_request)
@@ -67,7 +74,7 @@ class Agcod::ConfigurationTest < Test::Unit::TestCase
67
74
  end
68
75
 
69
76
  teardown do
70
- FileUtils.rm_f(@log_path)
77
+ FileUtils.rm_f(@log_path)
71
78
  end
72
79
 
73
80
  should "allow me to define a logger for logging requests" do
@@ -0,0 +1,45 @@
1
+ require "test_helper"
2
+
3
+ class Agcod::RequestTest < Test::Unit::TestCase
4
+ context 'a health check request' do
5
+ setup do
6
+ Agcod::Configuration.load(File.join(File.dirname(__FILE__), "..", "app_root"), "test")
7
+ @request = Agcod::HealthCheck.new
8
+ end
9
+
10
+ should 'read response body' do
11
+ register_response @request.request_url, "health_check/success"
12
+ @request.submit
13
+ assert_equal "SUCCESS", @request.status
14
+ end
15
+ end
16
+
17
+ context 'retrying a create gift card request' do
18
+ setup do
19
+ Agcod::Configuration.load(File.join(File.dirname(__FILE__), "..", "app_root"), "test")
20
+ @request = Agcod::CreateGiftCard.new('value' => 100, 'request_id' => 12345)
21
+ end
22
+
23
+ should 'use response of retried request' do
24
+ uri = URI.parse(@request.request_url)
25
+ register_response %r{^#{ uri.scheme }://#{ uri.host }}, %w( create_gift_card/retry create_gift_card/success )
26
+ @request.submit
27
+ assert_equal "SUCCESS", @request.status
28
+ end
29
+ end
30
+
31
+ context 'handle for a non-error failure' do
32
+ setup do
33
+ Agcod::Configuration.load(File.join(File.dirname(__FILE__), "..", "app_root"), "test")
34
+ @request = Agcod::CreateGiftCard.new('value' => 13.57, 'request_id' => 12345)
35
+ end
36
+
37
+ should 'store failure from statusMessage' do
38
+ uri = URI.parse(@request.request_url)
39
+ register_response %r{^#{ uri.scheme }://#{ uri.host }}, %w( create_gift_card/non-error-failure create_gift_card/success )
40
+ @request.submit
41
+ assert_equal "FAILURE", @request.status
42
+ assert(@request.errors.count > 0)
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0"?>
2
+ <CreateGiftCardResponse xmlns="http://agcws.amazon.com/doc/2008-01-01/">
3
+ <MessageHeader>
4
+ <messageType>CreateGiftCardResponse</messageType>
5
+ <sourceId>AMAZON</sourceId>
6
+ <recipientId>SomebodyImportant</recipientId>
7
+ <contentVersion>2008-01-01</contentVersion>
8
+ <retryCount>1</retryCount>
9
+ </MessageHeader>
10
+ <Status>
11
+ <statusCode>FAILURE</statusCode>
12
+ <errorCode></errorCode>
13
+ <statusMessage>Request Error </statusMessage>
14
+ </Status>
15
+ <gcCreationRequestId>SomebodyImportant12345</gcCreationRequestId>
16
+ <gcCreationResponseId>ABC123DEF456</gcCreationResponseId>
17
+ <gcClaimCode>AB12-CDE345-FG67</gcClaimCode>
18
+ <gcValue>
19
+ <amount>13.57</amount>
20
+ <currencyCode>USD</currencyCode>
21
+ </gcValue>
22
+ </CreateGiftCardResponse>
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0"?>
2
+ <CreateGiftCardResponse xmlns="http://agcws.amazon.com/doc/2008-01-01/">
3
+ <MessageHeader>
4
+ <messageType>CreateGiftCardResponse</messageType>
5
+ <sourceId>AMAZON</sourceId>
6
+ <recipientId>SomebodyImportant</recipientId>
7
+ <contentVersion>2008-01-01</contentVersion>
8
+ <retryCount>0</retryCount>
9
+ </MessageHeader>
10
+ <Status>
11
+ <statusCode>FAILURE</statusCode>
12
+ <errorCode>E100</errorCode>
13
+ <statusMessage>Please retry</statusMessage>
14
+ </Status>
15
+ <gcCreationRequestId>SomebodyImportant12345</gcCreationRequestId>
16
+ <gcCreationResponseId>ABC123DEF456</gcCreationResponseId>
17
+ </CreateGiftCardResponse>
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0"?>
2
+ <CreateGiftCardResponse xmlns="http://agcws.amazon.com/doc/2008-01-01/">
3
+ <MessageHeader>
4
+ <messageType>CreateGiftCardResponse</messageType>
5
+ <sourceId>AMAZON</sourceId>
6
+ <recipientId>SomebodyImportant</recipientId>
7
+ <contentVersion>2008-01-01</contentVersion>
8
+ <retryCount>1</retryCount>
9
+ </MessageHeader>
10
+ <Status>
11
+ <statusCode>SUCCESS</statusCode>
12
+ <errorCode></errorCode>
13
+ <statusMessage>CreateGiftCard Request successful</statusMessage>
14
+ </Status>
15
+ <gcCreationRequestId>SomebodyImportant12345</gcCreationRequestId>
16
+ <gcCreationResponseId>ABC123DEF456</gcCreationResponseId>
17
+ <gcClaimCode>AB12-CDE345-FG67</gcClaimCode>
18
+ <gcValue>
19
+ <amount>100</amount>
20
+ <currencyCode>USD</currencyCode>
21
+ </gcValue>
22
+ </CreateGiftCardResponse>
@@ -0,0 +1,15 @@
1
+ <?xml version="1.0"?>
2
+ <HealthCheckResponse xmlns="http://agcws.amazon.com/doc/2008-01-01/">
3
+ <MessageHeader>
4
+ <messageType>HealthCheckResponse</messageType>
5
+ <sourceId>AMAZON</sourceId>
6
+ <recipientId>SomebodyImportant</recipientId>
7
+ <contentVersion>2008-01-01</contentVersion>
8
+ <retryCount>0</retryCount>
9
+ </MessageHeader>
10
+ <Status>
11
+ <statusCode>SUCCESS</statusCode>
12
+ <errorCode/>
13
+ <statusMessage>HealthCheck Request successful</statusMessage>
14
+ </Status>
15
+ </HealthCheckResponse>
@@ -4,19 +4,37 @@ require 'shoulda'
4
4
  require 'fakeweb'
5
5
  require 'mocha'
6
6
 
7
+ module ActiveResource
8
+ class TimeoutError < StandardError
9
+ end
10
+ end
11
+
12
+ class String
13
+ def blank?
14
+ empty?
15
+ end
16
+ end
17
+
7
18
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
19
  $LOAD_PATH.unshift(File.dirname(__FILE__))
9
20
  require 'agcod'
10
21
 
11
- begin require "redgreen" rescue Exception; end
22
+ begin
23
+ require "redgreen"
24
+ rescue LoadError
25
+ end
12
26
 
13
27
  FakeWeb.allow_net_connect = false
14
28
 
15
29
  require "macros/configuration"
16
30
 
17
31
  class Test::Unit::TestCase
18
- def register_response(path, fixture)
19
-
32
+ def register_response(uri, fixtures)
33
+ fixtures = [fixtures].flatten.map do |f|
34
+ { :body => IO.read(xml_fixture_path(f)) }
35
+ end
36
+
37
+ FakeWeb.register_uri(:get, uri, fixtures)
20
38
  end
21
39
 
22
40
  def xml_fixture_path(fixture)
metadata CHANGED
@@ -1,40 +1,123 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: agcod
3
- version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 0
9
- - 4
10
- version: 0.0.4
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.6
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Dan Pickett
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2010-11-18 00:00:00 -05:00
19
- default_executable:
20
- dependencies: []
21
-
22
- description:
12
+ date: 2013-01-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: cucumber
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: fakeweb
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: mocha
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rspec
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: shoulda
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: Access the Amazon API to order gift codes
23
111
  email: dpickett@enlightsolutions.com
24
112
  executables: []
25
-
26
113
  extensions: []
27
-
28
- extra_rdoc_files:
29
- - LICENSE
30
- - README.rdoc
31
- files:
32
- - .document
114
+ extra_rdoc_files: []
115
+ files:
33
116
  - .gitignore
117
+ - Gemfile
34
118
  - LICENSE
35
119
  - README.rdoc
36
120
  - Rakefile
37
- - VERSION
38
121
  - agcod.gemspec
39
122
  - cucumber.yml
40
123
  - features/error_handling.feature
@@ -53,50 +136,63 @@ files:
53
136
  - lib/agcod/request.rb
54
137
  - lib/agcod/tasks.rb
55
138
  - lib/agcod/tasks/certification.rake
139
+ - lib/agcod/version.rb
56
140
  - lib/agcod/void_gift_card_creation.rb
57
141
  - manual_features/cancel_claimed_giftcard.feature
58
142
  - manual_features/insufficient_funds.feature
59
143
  - manual_features/retry_and_http.feature
60
144
  - tasks/agcod.rake
61
145
  - test/agcod/configuration_test.rb
146
+ - test/agcod/request_test.rb
62
147
  - test/app_root/config/agcod.yml
148
+ - test/fixtures/create_gift_card/non-error-failure.xml
149
+ - test/fixtures/create_gift_card/retry.xml
150
+ - test/fixtures/create_gift_card/success.xml
151
+ - test/fixtures/health_check/success.xml
63
152
  - test/macros/configuration.rb
64
153
  - test/test_helper.rb
65
- has_rdoc: true
66
154
  homepage: http://github.com/dpickett/agcod
67
155
  licenses: []
68
-
69
156
  post_install_message:
70
- rdoc_options:
71
- - --charset=UTF-8
72
- require_paths:
157
+ rdoc_options: []
158
+ require_paths:
73
159
  - lib
74
- required_ruby_version: !ruby/object:Gem::Requirement
160
+ required_ruby_version: !ruby/object:Gem::Requirement
75
161
  none: false
76
- requirements:
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- hash: 3
80
- segments:
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ segments:
81
167
  - 0
82
- version: "0"
83
- required_rubygems_version: !ruby/object:Gem::Requirement
168
+ hash: 2406941575318541167
169
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
170
  none: false
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- hash: 3
89
- segments:
171
+ requirements:
172
+ - - ! '>='
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ segments:
90
176
  - 0
91
- version: "0"
177
+ hash: 2406941575318541167
92
178
  requirements: []
93
-
94
- rubyforge_project:
95
- rubygems_version: 1.3.7
179
+ rubyforge_project: agcod
180
+ rubygems_version: 1.8.23
96
181
  signing_key:
97
182
  specification_version: 3
98
- summary: A Wrapper for Amazon Gift Cards On Demand
99
- test_files:
183
+ summary: A Wrapper for Amazon Gift Codes On Demand
184
+ test_files:
185
+ - features/error_handling.feature
186
+ - features/step_definitions/agcod_steps.rb
187
+ - features/success_certification.feature
188
+ - features/support/app_root/config/agcod.example.yml
189
+ - features/support/env.rb
100
190
  - test/agcod/configuration_test.rb
191
+ - test/agcod/request_test.rb
192
+ - test/app_root/config/agcod.yml
193
+ - test/fixtures/create_gift_card/non-error-failure.xml
194
+ - test/fixtures/create_gift_card/retry.xml
195
+ - test/fixtures/create_gift_card/success.xml
196
+ - test/fixtures/health_check/success.xml
101
197
  - test/macros/configuration.rb
102
198
  - test/test_helper.rb
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.0.4