google4r-checkout 1.1.beta2 → 1.1.beta3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,13 @@
1
+ # Uncomment the following line if you are using Google Checkout in Great Britain
2
+ # and adjust it if you want to test google4r-checkout against any other (future)
3
+ # Google Checkout service.
4
+
5
+ # Money.default_currency = 'GBP'
6
+
7
+ # The test configuration for the Google4R::Checkout::Frontend class.
8
+ FRONTEND_CONFIGURATION =
9
+ {
10
+ :merchant_id => '',
11
+ :merchant_key => '',
12
+ :use_sandbox => true
13
+ }
@@ -0,0 +1,105 @@
1
+ # Project: google4r
2
+ # File: /test/test_helper.rb
3
+ # Author: Manuel Holtgrewe <purestorm at ggnore dot net>
4
+ # Copyright: (c) 2007 by Manuel Holtgrewe
5
+ # License: MIT License as follows:
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining
8
+ # a copy of this software and associated documentation files (the
9
+ # "Software"), to deal in the Software without restriction, including
10
+ # without limitation the rights to use, copy, modify, merge, publish,
11
+ # distribute, sublicense, and/or sell copies of the Software, and to permit
12
+ # persons to whom the Software is furnished to do so, subject to the
13
+ # following conditions:
14
+ #
15
+ # The above copyright notice and this permission notice shall be included
16
+ # in all copies or substantial portions of the Software.
17
+ #
18
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19
+ # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21
+ # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22
+ # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
24
+ # OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
+
26
+ # setup load path
27
+ $LOAD_PATH << File.join(File.dirname(__FILE__), '..')
28
+ $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
29
+
30
+ # require dependencies
31
+
32
+ require 'test/unit'
33
+
34
+ require 'rubygems'
35
+ require 'bundler'
36
+ Bundler.setup(:default, :test)
37
+
38
+ require 'mocha'
39
+ require 'nokogiri'
40
+
41
+ class Array
42
+ # Returns the "power set" for this Array. This means that an array with all
43
+ # subsets of the array's elements will be returned.
44
+ def power
45
+ # the power set line is stolen from http://johncarrino.net/blog/2006/08/11/powerset-in-ruby/
46
+ inject([[]]){|c,y|r=[];c.each{|i|r<<i;r<<i+[y]};r}
47
+ end
48
+ end
49
+
50
+ # A helper class for the tests that require TaxTable objects.
51
+ class TestTaxTableFactory
52
+ def effective_tax_tables_at(time)
53
+ table = Google4R::Checkout::TaxTable.new(false)
54
+ table.name = "Some Table"
55
+
56
+ [ table ]
57
+ end
58
+ end
59
+
60
+ class Test::Unit::TestCase
61
+ def assert_nospace_equal(expected, actual)
62
+ return assert_equal(expected.gsub(/\s/, ''), actual.gsub(/\s/, ''))
63
+ end
64
+
65
+ def command_selector(command)
66
+ "#{Google4R::Checkout::CommandXmlGenerator::COMMAND_TO_TAG[command.class]}" +
67
+ "[google-order-number='#{command.google_order_number}']"
68
+ end
69
+
70
+ def find_elements(selector, xml)
71
+ Nokogiri.parse(xml).css(selector)
72
+ end
73
+
74
+ def assert_element_exists(selector, xml, msg=nil)
75
+ found = find_elements(selector, xml)
76
+ assert_not_equal 0, found.size, (msg || "Expected to find #{selector} in #{xml}")
77
+ end
78
+
79
+ def assert_no_element_exists(selector, xml, msg=nil)
80
+ found = find_elements(selector, xml)
81
+ assert_equal 0, found.size, (msg || "Expected to find #{selector} in #{xml}")
82
+ end
83
+
84
+ def assert_element_text_equals(text, selector, xml, msg=nil)
85
+ found = find_elements(selector, xml)
86
+ assert_equal 1, found.size, "Expected to find one #{selector} in #{xml} but found #{found.size}"
87
+ assert_equal text, found.text, msg
88
+ end
89
+
90
+ def find_command_elements(selector, command)
91
+ find_elements("#{command_selector(command)} #{selector}", command.to_xml)
92
+ end
93
+
94
+ def assert_command_element_text_equals(text, selector, command, msg=nil)
95
+ assert_element_text_equals(text, "#{command_selector(command)} #{selector}", command.to_xml, msg)
96
+ end
97
+
98
+ def assert_command_element_exists(selector, command, msg=nil)
99
+ assert_element_exists("#{command_selector(command)} #{selector}", command.to_xml, msg)
100
+ end
101
+
102
+ def assert_no_command_element_exists(selector, command, msg=nil)
103
+ assert_no_element_exists("#{command_selector(command)} #{selector}", command.to_xml, msg)
104
+ end
105
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google4r-checkout
3
3
  version: !ruby/object:Gem::Version
4
- hash: -1848230122
4
+ hash: -1848230121
5
5
  prerelease: true
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - beta2
10
- version: 1.1.beta2
9
+ - beta3
10
+ version: 1.1.beta3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tony Chan
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-23 00:00:00 -04:00
18
+ date: 2010-06-28 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -114,6 +114,8 @@ files:
114
114
  - test/unit/us_state_area_test.rb
115
115
  - test/unit/us_zip_area_test.rb
116
116
  - test/unit/world_area_test.rb
117
+ - test/test_helper.rb
118
+ - test/frontend_configuration_example.rb
117
119
  - README.md
118
120
  - LICENSE
119
121
  - CHANGES
@@ -216,3 +218,5 @@ test_files:
216
218
  - test/unit/us_state_area_test.rb
217
219
  - test/unit/us_zip_area_test.rb
218
220
  - test/unit/world_area_test.rb
221
+ - test/test_helper.rb
222
+ - test/frontend_configuration_example.rb