google4r-checkout-jn 1.1.jniziol
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.
- data/CHANGES +136 -0
- data/LICENSE +22 -0
- data/README.md +72 -0
- data/lib/google4r/checkout.rb +34 -0
- data/lib/google4r/checkout/commands.rb +665 -0
- data/lib/google4r/checkout/frontend.rb +222 -0
- data/lib/google4r/checkout/merchant_calculation.rb +323 -0
- data/lib/google4r/checkout/notifications.rb +774 -0
- data/lib/google4r/checkout/shared.rb +1386 -0
- data/lib/google4r/checkout/utils.rb +94 -0
- data/lib/google4r/checkout/xml_generation.rb +1023 -0
- data/test/frontend_configuration_example.rb +13 -0
- data/test/integration/checkout_command_test.rb +261 -0
- data/test/test_helper.rb +105 -0
- data/test/unit/add_merchant_order_number_command_test.rb +65 -0
- data/test/unit/add_tracking_data_command_test.rb +68 -0
- data/test/unit/address_test.rb +131 -0
- data/test/unit/anonymous_address_test.rb +75 -0
- data/test/unit/archive_order_command_test.rb +63 -0
- data/test/unit/area_test.rb +44 -0
- data/test/unit/authorization_amount_notification_test.rb +69 -0
- data/test/unit/authorize_order_command_test.rb +63 -0
- data/test/unit/backorder_items_command_test.rb +69 -0
- data/test/unit/callback_handler_test.rb +83 -0
- data/test/unit/cancel_items_command_test.rb +76 -0
- data/test/unit/cancel_order_command_test.rb +74 -0
- data/test/unit/carrier_calculated_shipping_test.rb +57 -0
- data/test/unit/charge_amount_notification_test.rb +72 -0
- data/test/unit/charge_and_ship_order_command_test.rb +69 -0
- data/test/unit/charge_fee_test.rb +53 -0
- data/test/unit/charge_order_command_test.rb +69 -0
- data/test/unit/chargeback_amount_notification_test.rb +69 -0
- data/test/unit/checkout_command_test.rb +149 -0
- data/test/unit/checkout_command_xml_generator_test.rb +216 -0
- data/test/unit/command_test.rb +116 -0
- data/test/unit/deliver_order_command_test.rb +65 -0
- data/test/unit/delivery_method_test.rb +42 -0
- data/test/unit/digital_content_test.rb +105 -0
- data/test/unit/flat_rate_shipping_test.rb +133 -0
- data/test/unit/frontend_test.rb +144 -0
- data/test/unit/item_info_test.rb +69 -0
- data/test/unit/item_test.rb +171 -0
- data/test/unit/marketing_preferences_test.rb +65 -0
- data/test/unit/merchant_calculated_shipping_test.rb +173 -0
- data/test/unit/merchant_calculation_callback_test.rb +137 -0
- data/test/unit/merchant_calculation_result_test.rb +78 -0
- data/test/unit/merchant_calculation_results_test.rb +203 -0
- data/test/unit/merchant_code_result_test.rb +51 -0
- data/test/unit/merchant_code_test.rb +122 -0
- data/test/unit/new_order_notification_test.rb +115 -0
- data/test/unit/notification_acknowledgement_test.rb +67 -0
- data/test/unit/notification_handler_test.rb +113 -0
- data/test/unit/order_adjustment_test.rb +119 -0
- data/test/unit/order_report_command_test.rb +109 -0
- data/test/unit/order_state_change_notification_test.rb +158 -0
- data/test/unit/parameterized_url_test.rb +57 -0
- data/test/unit/pickup_shipping_test.rb +70 -0
- data/test/unit/postal_area_test.rb +71 -0
- data/test/unit/private_data_parser_test.rb +68 -0
- data/test/unit/refund_amount_notification_test.rb +67 -0
- data/test/unit/refund_order_command_test.rb +79 -0
- data/test/unit/reset_items_shipping_information_command_test.rb +69 -0
- data/test/unit/return_items_command_test.rb +69 -0
- data/test/unit/risk_information_notification_test.rb +98 -0
- data/test/unit/send_buyer_message_command_test.rb +68 -0
- data/test/unit/ship_items_command_test.rb +81 -0
- data/test/unit/shipping_adjustment_test.rb +100 -0
- data/test/unit/shopping_cart_test.rb +146 -0
- data/test/unit/tax_rule_test.rb +70 -0
- data/test/unit/tax_table_test.rb +88 -0
- data/test/unit/tracking_data_test.rb +54 -0
- data/test/unit/unarchive_order_command_test.rb +63 -0
- data/test/unit/url_parameter_test.rb +55 -0
- data/test/unit/us_country_area_test.rb +76 -0
- data/test/unit/us_state_area_test.rb +70 -0
- data/test/unit/us_zip_area_test.rb +66 -0
- data/test/unit/world_area_test.rb +48 -0
- data/var/cacert.pem +7815 -0
- metadata +230 -0
@@ -0,0 +1,88 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/area_test.rb
|
4
|
+
# Author: Manuel Holtgrewe <purestorm at ggnore dot net>
|
5
|
+
# Copyright: (c) 2007 by Manuel Holtgrewe
|
6
|
+
# License: MIT License as follows:
|
7
|
+
#
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
9
|
+
# a copy of this software and associated documentation files (the
|
10
|
+
# "Software"), to deal in the Software without restriction, including
|
11
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
12
|
+
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
13
|
+
# persons to whom the Software is furnished to do so, subject to the
|
14
|
+
# following conditions:
|
15
|
+
#
|
16
|
+
# The above copyright notice and this permission notice shall be included
|
17
|
+
# in all copies or substantial portions of the Software.
|
18
|
+
#
|
19
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
20
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
22
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
23
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
24
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
25
|
+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
26
|
+
#++
|
27
|
+
|
28
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
29
|
+
|
30
|
+
require 'google4r/checkout'
|
31
|
+
|
32
|
+
require 'test/frontend_configuration'
|
33
|
+
|
34
|
+
# Test for the TaxTable class.
|
35
|
+
class Google4R::Checkout::TaxTableTest < Test::Unit::TestCase
|
36
|
+
include Google4R::Checkout
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@table = TaxTable.new(false)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_table_behaves_correctly
|
43
|
+
assert_respond_to @table, :rules
|
44
|
+
assert_respond_to @table, :name
|
45
|
+
assert_respond_to @table, :name=
|
46
|
+
assert_respond_to @table, :standalone
|
47
|
+
assert_respond_to @table, :merchant_calculated
|
48
|
+
assert_respond_to @table, :merchant_calculated=
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_initialized_correctly
|
52
|
+
assert_nil @table.name
|
53
|
+
assert_equal [], @table.rules
|
54
|
+
assert_equal false, @table.standalone
|
55
|
+
assert_equal false, @table.merchant_calculated
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_accessors_work_correctly
|
59
|
+
@table.name = "name"
|
60
|
+
assert_equal "name", @table.name
|
61
|
+
|
62
|
+
@table.merchant_calculated = true
|
63
|
+
assert_equal true, @table.merchant_calculated
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_create_rule_works_correctly_with_block
|
67
|
+
the_rule = nil
|
68
|
+
|
69
|
+
res =
|
70
|
+
@table.create_rule do |rule|
|
71
|
+
the_rule = rule
|
72
|
+
assert_kind_of TaxRule, rule
|
73
|
+
end
|
74
|
+
|
75
|
+
assert_equal res, the_rule
|
76
|
+
assert @table.rules.include?(the_rule)
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_create_rule_works_correctly_without_block
|
80
|
+
res = nil
|
81
|
+
|
82
|
+
res = @table.create_rule
|
83
|
+
|
84
|
+
assert_kind_of TaxRule, res
|
85
|
+
|
86
|
+
assert @table.rules.include?(res)
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'google4r/checkout'
|
2
|
+
|
3
|
+
require 'test/frontend_configuration'
|
4
|
+
#--
|
5
|
+
# Project: google_checkout4r
|
6
|
+
# File: test/unit/tracking_data_test.rb
|
7
|
+
# Author: Tony Chan <api.htchan at gmail dot com>
|
8
|
+
# Copyright: (c) 2007 by Manuel Holtgrewe
|
9
|
+
# License: MIT License as follows:
|
10
|
+
#
|
11
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
12
|
+
# a copy of this software and associated documentation files (the
|
13
|
+
# "Software"), to deal in the Software without restriction, including
|
14
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
15
|
+
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
16
|
+
# persons to whom the Software is furnished to do so, subject to the
|
17
|
+
# following conditions:
|
18
|
+
#
|
19
|
+
# The above copyright notice and this permission notice shall be included
|
20
|
+
# in all copies or substantial portions of the Software.
|
21
|
+
#
|
22
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
23
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
24
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
25
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
26
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
27
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
28
|
+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
29
|
+
#++
|
30
|
+
|
31
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
32
|
+
|
33
|
+
require 'google4r/checkout'
|
34
|
+
|
35
|
+
require 'test/frontend_configuration'
|
36
|
+
|
37
|
+
# Test for the class TrackingData.
|
38
|
+
class Google4R::Checkout::TrackingDataTest < Test::Unit::TestCase
|
39
|
+
include Google4R::Checkout
|
40
|
+
|
41
|
+
def setup
|
42
|
+
@tracking_data = TrackingData.new('UPS', '1234')
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_initialization_works
|
46
|
+
assert_kind_of TrackingData, @tracking_data
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_responds_correctly
|
50
|
+
[ :carrier, :tracking_number].each do |sym|
|
51
|
+
assert_respond_to @tracking_data, sym
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/unarchive_command_test.rb
|
4
|
+
# Author: Tony Chan <api.htchan at gmail dot com>
|
5
|
+
# Copyright: (c) 2007 by Tony Chan
|
6
|
+
# License: MIT License as follows:
|
7
|
+
#
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
9
|
+
# a copy of this software and associated documentation files (the
|
10
|
+
# "Software"), to deal in the Software without restriction, including
|
11
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
12
|
+
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
13
|
+
# persons to whom the Software is furnished to do so, subject to the
|
14
|
+
# following conditions:
|
15
|
+
#
|
16
|
+
# The above copyright notice and this permission notice shall be included
|
17
|
+
# in all copies or substantial portions of the Software.
|
18
|
+
#
|
19
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
20
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
22
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
23
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
24
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
25
|
+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
26
|
+
#++
|
27
|
+
|
28
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
29
|
+
|
30
|
+
require 'google4r/checkout'
|
31
|
+
|
32
|
+
require 'test/frontend_configuration'
|
33
|
+
|
34
|
+
# Tests for the UnarchiveOrderCommand class.
|
35
|
+
class Google4R::Checkout::UnarchiveOrderCommandTest < Test::Unit::TestCase
|
36
|
+
include Google4R::Checkout
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@frontend = Frontend.new(FRONTEND_CONFIGURATION)
|
40
|
+
@command = @frontend.create_unarchive_order_command
|
41
|
+
|
42
|
+
@command.google_order_number = '841171949013218'
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_behaves_correctly
|
46
|
+
[ :google_order_number ].each do |symbol|
|
47
|
+
assert_respond_to @command, symbol
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_xml
|
52
|
+
assert_element_exists(command_selector(@command), @command.to_xml)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_accessors
|
56
|
+
assert_equal('841171949013218', @command.google_order_number)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_to_xml_does_not_raise_exception
|
60
|
+
assert_nothing_raised { @command.to_xml }
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/paramterized_url_test.rb
|
4
|
+
# Author: Johnathan Niziol <jniziol at gmail dot com>
|
5
|
+
# Copyright: (c) 2007 by Johnathan Niziol
|
6
|
+
# License: MIT License as follows:
|
7
|
+
#
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
9
|
+
# a copy of this software and associated documentation files (the
|
10
|
+
# "Software"), to deal in the Software without restriction, including
|
11
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
12
|
+
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
13
|
+
# persons to whom the Software is furnished to do so, subject to the
|
14
|
+
# following conditions:
|
15
|
+
#
|
16
|
+
# The above copyright notice and this permission notice shall be included
|
17
|
+
# in all copies or substantial portions of the Software.
|
18
|
+
#
|
19
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
20
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
22
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
23
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
24
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
25
|
+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
26
|
+
#++
|
27
|
+
|
28
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
29
|
+
|
30
|
+
require 'google4r/checkout'
|
31
|
+
|
32
|
+
require 'test/frontend_configuration'
|
33
|
+
|
34
|
+
# Test for the TaxTable class.
|
35
|
+
class Google4R::Checkout::UrlParameterTest < Test::Unit::TestCase
|
36
|
+
include Google4R::Checkout
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@parameterized_url = ParameterizedUrl.new("http://www.google.com")
|
40
|
+
@url_parameter = @parameterized_url.create_url_parameter(:name => 'order', :type => 'order-id')
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_url_parameter_behaves_correctly
|
44
|
+
assert_respond_to @url_parameter, :parameterized_url
|
45
|
+
assert_respond_to @url_parameter, :name
|
46
|
+
assert_respond_to @url_parameter, :parameter_type
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_initialized_correctly
|
50
|
+
assert_equal "order", @url_parameter.name
|
51
|
+
assert_equal "order-id", @url_parameter.parameter_type
|
52
|
+
assert_equal @parameterized_url, @url_parameter.parameterized_url
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/us_country_area_test.rb
|
4
|
+
# Author: Manuel Holtgrewe <purestorm at ggnore dot net>
|
5
|
+
# Copyright: (c) 2007 by Manuel Holtgrewe
|
6
|
+
# License: MIT License as follows:
|
7
|
+
#
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
9
|
+
# a copy of this software and associated documentation files (the
|
10
|
+
# "Software"), to deal in the Software without restriction, including
|
11
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
12
|
+
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
13
|
+
# persons to whom the Software is furnished to do so, subject to the
|
14
|
+
# following conditions:
|
15
|
+
#
|
16
|
+
# The above copyright notice and this permission notice shall be included
|
17
|
+
# in all copies or substantial portions of the Software.
|
18
|
+
#
|
19
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
20
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
22
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
23
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
24
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
25
|
+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
26
|
+
#++
|
27
|
+
|
28
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
29
|
+
|
30
|
+
require 'google4r/checkout'
|
31
|
+
|
32
|
+
require 'test/frontend_configuration'
|
33
|
+
|
34
|
+
# Test for the class UsCountryArea.
|
35
|
+
class Google4R::Checkout::UsCountryAreaTest < Test::Unit::TestCase
|
36
|
+
include Google4R::Checkout
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@area = UsCountryArea.new
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_constants_are_defined
|
43
|
+
assert defined?(UsCountryArea::CONTINENTAL_48)
|
44
|
+
assert defined?(UsCountryArea::FULL_50_STATES)
|
45
|
+
assert defined?(UsCountryArea::ALL)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_initialization
|
49
|
+
assert_nil @area.area
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_creator_sets_area
|
53
|
+
area = UsCountryArea.new(UsCountryArea::ALL)
|
54
|
+
assert_equal UsCountryArea::ALL, area.area
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
def test_us_country_area_behaves_correctly
|
59
|
+
assert_respond_to @area, :area
|
60
|
+
assert_respond_to @area, :area=
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_us_country_area_area_accessor_works
|
64
|
+
assert_nil @area.area
|
65
|
+
|
66
|
+
[ UsCountryArea::CONTINENTAL_48, UsCountryArea::FULL_50_STATES, UsCountryArea::ALL ].each do |str|
|
67
|
+
@area.area = str
|
68
|
+
assert_equal str, @area.area
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_us_country_area_area_validation_works
|
73
|
+
assert_raises(RuntimeError) { @area.area = 'invalid value' }
|
74
|
+
assert_nil @area.area
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/area_test.rb
|
4
|
+
# Author: Manuel Holtgrewe <purestorm at ggnore dot net>
|
5
|
+
# Copyright: (c) 2007 by Manuel Holtgrewe
|
6
|
+
# License: MIT License as follows:
|
7
|
+
#
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
9
|
+
# a copy of this software and associated documentation files (the
|
10
|
+
# "Software"), to deal in the Software without restriction, including
|
11
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
12
|
+
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
13
|
+
# persons to whom the Software is furnished to do so, subject to the
|
14
|
+
# following conditions:
|
15
|
+
#
|
16
|
+
# The above copyright notice and this permission notice shall be included
|
17
|
+
# in all copies or substantial portions of the Software.
|
18
|
+
#
|
19
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
20
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
22
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
23
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
24
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
25
|
+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
26
|
+
#++
|
27
|
+
|
28
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
29
|
+
|
30
|
+
require 'google4r/checkout'
|
31
|
+
|
32
|
+
require 'test/frontend_configuration'
|
33
|
+
|
34
|
+
# Test for the class UsStateArea.
|
35
|
+
class Google4R::Checkout::UsStateAreaTest < Test::Unit::TestCase
|
36
|
+
include Google4R::Checkout
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@area = UsStateArea.new
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_initialization
|
43
|
+
assert_nil @area.state
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_creator_sets_state
|
47
|
+
area = UsStateArea.new('CA')
|
48
|
+
assert_equal 'CA', area.state
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_us_state_area_behaves_correctly
|
52
|
+
assert_respond_to @area, :state
|
53
|
+
assert_respond_to @area, :state=
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_us_country_area_area_accessor_works
|
57
|
+
assert_nil @area.state
|
58
|
+
|
59
|
+
@area.state = 'CA'
|
60
|
+
assert_equal 'CA', @area.state
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_us_country_area_area_must_have_the_correct_format
|
64
|
+
assert_raises(RuntimeError) { @area.state = 'ca' }
|
65
|
+
assert_nil @area.state
|
66
|
+
|
67
|
+
assert_raises(RuntimeError) { @area.state = 'CAL' }
|
68
|
+
assert_nil @area.state
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/area_test.rb
|
4
|
+
# Author: Manuel Holtgrewe <purestorm at ggnore dot net>
|
5
|
+
# Copyright: (c) 2007 by Manuel Holtgrewe
|
6
|
+
# License: MIT License as follows:
|
7
|
+
#
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
9
|
+
# a copy of this software and associated documentation files (the
|
10
|
+
# "Software"), to deal in the Software without restriction, including
|
11
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
12
|
+
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
13
|
+
# persons to whom the Software is furnished to do so, subject to the
|
14
|
+
# following conditions:
|
15
|
+
#
|
16
|
+
# The above copyright notice and this permission notice shall be included
|
17
|
+
# in all copies or substantial portions of the Software.
|
18
|
+
#
|
19
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
20
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
22
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
23
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
24
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
25
|
+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
26
|
+
#++
|
27
|
+
|
28
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
29
|
+
|
30
|
+
require 'google4r/checkout'
|
31
|
+
|
32
|
+
require 'test/frontend_configuration'
|
33
|
+
|
34
|
+
# Test for the class UsZipArea.
|
35
|
+
class Google4R::Checkout::UsZipAreaTest < Test::Unit::TestCase
|
36
|
+
include Google4R::Checkout
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@area = UsZipArea.new
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_initialization
|
43
|
+
assert_nil @area.pattern
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_creator_sets_area
|
47
|
+
area = UsZipArea.new('123*')
|
48
|
+
assert_equal '123*', area.pattern
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_us_zip_area_behaves_correctly
|
52
|
+
# test that the methods and constants are defined correctly
|
53
|
+
assert_respond_to @area, :pattern
|
54
|
+
assert_respond_to @area, :pattern=
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_us_zip_area_pattern_accessor_works
|
58
|
+
assert_nil @area.pattern
|
59
|
+
|
60
|
+
@area.pattern = '12345678'
|
61
|
+
assert_equal '12345678', @area.pattern
|
62
|
+
|
63
|
+
@area.pattern = '12*'
|
64
|
+
assert_equal '12*', @area.pattern
|
65
|
+
end
|
66
|
+
end
|