tax_cloud 0.3.0 → 0.4.0

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.
Files changed (82) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +8 -25
  3. data/.rubocop_todo.yml +47 -0
  4. data/.travis.yml +5 -5
  5. data/CHANGELOG.rdoc +11 -0
  6. data/CONTRIBUTORS.txt +3 -0
  7. data/Gemfile +16 -5
  8. data/LICENSE.rdoc +1 -1
  9. data/README.rdoc +12 -8
  10. data/Rakefile +7 -11
  11. data/lib/config/locales/en.yml +2 -2
  12. data/lib/hash.rb +3 -4
  13. data/lib/tasks/tax_cloud.rake +4 -4
  14. data/lib/tasks/tax_code_groups.rake +11 -11
  15. data/lib/tasks/tax_codes.rake +12 -12
  16. data/lib/tax_cloud.rb +8 -3
  17. data/lib/tax_cloud/address.rb +10 -5
  18. data/lib/tax_cloud/cart_item.rb +2 -0
  19. data/lib/tax_cloud/client.rb +13 -3
  20. data/lib/tax_cloud/configuration.rb +13 -2
  21. data/lib/tax_cloud/errors.rb +2 -0
  22. data/lib/tax_cloud/errors/api_error.rb +3 -3
  23. data/lib/tax_cloud/errors/missing_config_error.rb +2 -1
  24. data/lib/tax_cloud/errors/missing_config_option_error.rb +2 -1
  25. data/lib/tax_cloud/errors/soap_error.rb +6 -6
  26. data/lib/tax_cloud/errors/tax_cloud_error.rb +4 -3
  27. data/lib/tax_cloud/errors/unexpected_soap_response_error.rb +3 -3
  28. data/lib/tax_cloud/record.rb +2 -0
  29. data/lib/tax_cloud/responses.rb +2 -0
  30. data/lib/tax_cloud/responses/authorized.rb +3 -1
  31. data/lib/tax_cloud/responses/authorized_with_capture.rb +3 -1
  32. data/lib/tax_cloud/responses/base.rb +5 -4
  33. data/lib/tax_cloud/responses/captured.rb +3 -1
  34. data/lib/tax_cloud/responses/cart_item.rb +6 -2
  35. data/lib/tax_cloud/responses/generic.rb +2 -0
  36. data/lib/tax_cloud/responses/lookup.rb +10 -8
  37. data/lib/tax_cloud/responses/ping.rb +3 -1
  38. data/lib/tax_cloud/responses/returned.rb +3 -1
  39. data/lib/tax_cloud/responses/tax_code_groups.rb +3 -1
  40. data/lib/tax_cloud/responses/tax_codes.rb +3 -1
  41. data/lib/tax_cloud/responses/tax_codes_by_group.rb +3 -1
  42. data/lib/tax_cloud/responses/verify_address.rb +3 -1
  43. data/lib/tax_cloud/tax_code.rb +2 -0
  44. data/lib/tax_cloud/tax_code_constants.rb +262 -260
  45. data/lib/tax_cloud/tax_code_group.rb +3 -1
  46. data/lib/tax_cloud/tax_code_group_constants.rb +2 -0
  47. data/lib/tax_cloud/tax_code_groups.rb +3 -1
  48. data/lib/tax_cloud/tax_codes.rb +3 -1
  49. data/lib/tax_cloud/transaction.rb +2 -0
  50. data/lib/tax_cloud/version.rb +3 -1
  51. data/tax_cloud.gemspec +16 -18
  52. data/test/cassettes/authorized.yml +6 -6
  53. data/test/cassettes/authorized_with_capture.yml +6 -6
  54. data/test/cassettes/authorized_with_localized_time.yml +6 -6
  55. data/test/cassettes/captured.yml +7 -7
  56. data/test/cassettes/get_tic_groups.yml +5 -5
  57. data/test/cassettes/get_tics.yml +5 -5
  58. data/test/cassettes/get_tics_by_group.yml +5 -5
  59. data/test/cassettes/invalid_soap_call.yml +5 -5
  60. data/test/cassettes/lookup.yml +5 -5
  61. data/test/cassettes/lookup_ny.yml +5 -5
  62. data/test/cassettes/ping.yml +5 -5
  63. data/test/cassettes/ping_with_invalid_credentials.yml +5 -5
  64. data/test/cassettes/ping_with_invalid_response.yml +5 -5
  65. data/test/cassettes/returned.yml +7 -7
  66. data/test/cassettes/verify_bad_address.yml +5 -5
  67. data/test/cassettes/verify_good_address.yml +5 -5
  68. data/test/helper.rb +3 -1
  69. data/test/test_address.rb +3 -1
  70. data/test/test_cart_item.rb +3 -1
  71. data/test/test_client.rb +4 -2
  72. data/test/test_configuration_optional_keys.rb +44 -0
  73. data/test/{test_configuration.rb → test_configuration_required_keys.rb} +6 -4
  74. data/test/test_lookup_response.rb +22 -0
  75. data/test/test_setup.rb +3 -1
  76. data/test/test_soap.rb +3 -1
  77. data/test/test_tax_code_groups.rb +4 -2
  78. data/test/test_tax_codes.rb +3 -1
  79. data/test/test_transaction.rb +3 -1
  80. data/test/test_transaction_ny.rb +3 -1
  81. data/test/vcr_setup.rb +2 -0
  82. metadata +28 -96
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://api.taxcloud.net/1.0/?wsdl
5
+ uri: https://asmx.taxcloud.com/1.0/?wsdl
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -719,17 +719,17 @@ http_interactions:
719
719
  part=\"Body\" />\r\n </wsdl:output>\r\n </wsdl:operation>\r\n </wsdl:binding>\r\n
720
720
  \ <wsdl:service name=\"TaxCloud\">\r\n <wsdl:documentation xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\">TaxCloud
721
721
  Web Service</wsdl:documentation>\r\n <wsdl:port name=\"TaxCloudSoap\" binding=\"tns:TaxCloudSoap\">\r\n
722
- \ <soap:address location=\"https://api.taxcloud.net/1.0/TaxCloud.asmx\"
722
+ \ <soap:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
723
723
  />\r\n </wsdl:port>\r\n <wsdl:port name=\"TaxCloudSoap12\" binding=\"tns:TaxCloudSoap12\">\r\n
724
- \ <soap12:address location=\"https://api.taxcloud.net/1.0/TaxCloud.asmx\"
724
+ \ <soap12:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
725
725
  />\r\n </wsdl:port>\r\n <wsdl:port name=\"TaxCloudHttpPost\" binding=\"tns:TaxCloudHttpPost\">\r\n
726
- \ <http:address location=\"https://api.taxcloud.net/1.0/TaxCloud.asmx\"
726
+ \ <http:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
727
727
  />\r\n </wsdl:port>\r\n </wsdl:service>\r\n</wsdl:definitions>"
728
728
  http_version:
729
729
  recorded_at: Thu, 09 Jan 2014 16:03:39 GMT
730
730
  - request:
731
731
  method: post
732
- uri: https://api.taxcloud.net/1.0/TaxCloud.asmx
732
+ uri: https://asmx.taxcloud.com/1.0/TaxCloud.asmx
733
733
  body:
734
734
  encoding: US-ASCII
735
735
  string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://api.taxcloud.net/1.0/?wsdl
5
+ uri: https://asmx.taxcloud.com/1.0/?wsdl
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -719,17 +719,17 @@ http_interactions:
719
719
  part=\"Body\" />\r\n </wsdl:output>\r\n </wsdl:operation>\r\n </wsdl:binding>\r\n
720
720
  \ <wsdl:service name=\"TaxCloud\">\r\n <wsdl:documentation xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\">TaxCloud
721
721
  Web Service</wsdl:documentation>\r\n <wsdl:port name=\"TaxCloudSoap\" binding=\"tns:TaxCloudSoap\">\r\n
722
- \ <soap:address location=\"https://api.taxcloud.net/1.0/TaxCloud.asmx\"
722
+ \ <soap:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
723
723
  />\r\n </wsdl:port>\r\n <wsdl:port name=\"TaxCloudSoap12\" binding=\"tns:TaxCloudSoap12\">\r\n
724
- \ <soap12:address location=\"https://api.taxcloud.net/1.0/TaxCloud.asmx\"
724
+ \ <soap12:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
725
725
  />\r\n </wsdl:port>\r\n <wsdl:port name=\"TaxCloudHttpPost\" binding=\"tns:TaxCloudHttpPost\">\r\n
726
- \ <http:address location=\"https://api.taxcloud.net/1.0/TaxCloud.asmx\"
726
+ \ <http:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
727
727
  />\r\n </wsdl:port>\r\n </wsdl:service>\r\n</wsdl:definitions>"
728
728
  http_version:
729
729
  recorded_at: Thu, 09 Jan 2014 16:03:39 GMT
730
730
  - request:
731
731
  method: post
732
- uri: https://api.taxcloud.net/1.0/TaxCloud.asmx
732
+ uri: https://asmx.taxcloud.com/1.0/TaxCloud.asmx
733
733
  body:
734
734
  encoding: US-ASCII
735
735
  string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://api.taxcloud.net/1.0/?wsdl
5
+ uri: https://asmx.taxcloud.com/1.0/?wsdl
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -719,17 +719,17 @@ http_interactions:
719
719
  part=\"Body\" />\r\n </wsdl:output>\r\n </wsdl:operation>\r\n </wsdl:binding>\r\n
720
720
  \ <wsdl:service name=\"TaxCloud\">\r\n <wsdl:documentation xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\">TaxCloud
721
721
  Web Service</wsdl:documentation>\r\n <wsdl:port name=\"TaxCloudSoap\" binding=\"tns:TaxCloudSoap\">\r\n
722
- \ <soap:address location=\"https://api.taxcloud.net/1.0/TaxCloud.asmx\"
722
+ \ <soap:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
723
723
  />\r\n </wsdl:port>\r\n <wsdl:port name=\"TaxCloudSoap12\" binding=\"tns:TaxCloudSoap12\">\r\n
724
- \ <soap12:address location=\"https://api.taxcloud.net/1.0/TaxCloud.asmx\"
724
+ \ <soap12:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
725
725
  />\r\n </wsdl:port>\r\n <wsdl:port name=\"TaxCloudHttpPost\" binding=\"tns:TaxCloudHttpPost\">\r\n
726
- \ <http:address location=\"https://api.taxcloud.net/1.0/TaxCloud.asmx\"
726
+ \ <http:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
727
727
  />\r\n </wsdl:port>\r\n </wsdl:service>\r\n</wsdl:definitions>"
728
728
  http_version:
729
729
  recorded_at: Thu, 09 Jan 2014 16:03:39 GMT
730
730
  - request:
731
731
  method: post
732
- uri: https://api.taxcloud.net/1.0/TaxCloud.asmx
732
+ uri: https://asmx.taxcloud.com/1.0/TaxCloud.asmx
733
733
  body:
734
734
  encoding: US-ASCII
735
735
  string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://api.taxcloud.net/1.0/?wsdl
5
+ uri: https://asmx.taxcloud.com/1.0/?wsdl
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -719,17 +719,17 @@ http_interactions:
719
719
  part=\"Body\" />\r\n </wsdl:output>\r\n </wsdl:operation>\r\n </wsdl:binding>\r\n
720
720
  \ <wsdl:service name=\"TaxCloud\">\r\n <wsdl:documentation xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\">TaxCloud
721
721
  Web Service</wsdl:documentation>\r\n <wsdl:port name=\"TaxCloudSoap\" binding=\"tns:TaxCloudSoap\">\r\n
722
- \ <soap:address location=\"https://api.taxcloud.net/1.0/TaxCloud.asmx\"
722
+ \ <soap:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
723
723
  />\r\n </wsdl:port>\r\n <wsdl:port name=\"TaxCloudSoap12\" binding=\"tns:TaxCloudSoap12\">\r\n
724
- \ <soap12:address location=\"https://api.taxcloud.net/1.0/TaxCloud.asmx\"
724
+ \ <soap12:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
725
725
  />\r\n </wsdl:port>\r\n <wsdl:port name=\"TaxCloudHttpPost\" binding=\"tns:TaxCloudHttpPost\">\r\n
726
- \ <http:address location=\"https://api.taxcloud.net/1.0/TaxCloud.asmx\"
726
+ \ <http:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
727
727
  />\r\n </wsdl:port>\r\n </wsdl:service>\r\n</wsdl:definitions>"
728
728
  http_version:
729
729
  recorded_at: Thu, 09 Jan 2014 16:03:39 GMT
730
730
  - request:
731
731
  method: post
732
- uri: https://api.taxcloud.net/1.0/TaxCloud.asmx
732
+ uri: https://asmx.taxcloud.com/1.0/TaxCloud.asmx
733
733
  body:
734
734
  encoding: US-ASCII
735
735
  string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
@@ -779,7 +779,7 @@ http_interactions:
779
779
  recorded_at: Fri, 01 Mar 2013 22:58:21 GMT
780
780
  - request:
781
781
  method: post
782
- uri: https://api.taxcloud.net/1.0/TaxCloud.asmx
782
+ uri: https://asmx.taxcloud.com/1.0/TaxCloud.asmx
783
783
  body:
784
784
  encoding: US-ASCII
785
785
  string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
@@ -825,7 +825,7 @@ http_interactions:
825
825
  recorded_at: Fri, 01 Mar 2013 22:58:21 GMT
826
826
  - request:
827
827
  method: post
828
- uri: https://api.taxcloud.net/1.0/TaxCloud.asmx
828
+ uri: https://asmx.taxcloud.com/1.0/TaxCloud.asmx
829
829
  body:
830
830
  encoding: US-ASCII
831
831
  string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://api.taxcloud.net/1.0/?wsdl
5
+ uri: https://asmx.taxcloud.com/1.0/?wsdl
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -719,17 +719,17 @@ http_interactions:
719
719
  part=\"Body\" />\r\n </wsdl:output>\r\n </wsdl:operation>\r\n </wsdl:binding>\r\n
720
720
  \ <wsdl:service name=\"TaxCloud\">\r\n <wsdl:documentation xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\">TaxCloud
721
721
  Web Service</wsdl:documentation>\r\n <wsdl:port name=\"TaxCloudSoap\" binding=\"tns:TaxCloudSoap\">\r\n
722
- \ <soap:address location=\"https://api.taxcloud.net/1.0/TaxCloud.asmx\"
722
+ \ <soap:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
723
723
  />\r\n </wsdl:port>\r\n <wsdl:port name=\"TaxCloudSoap12\" binding=\"tns:TaxCloudSoap12\">\r\n
724
- \ <soap12:address location=\"https://api.taxcloud.net/1.0/TaxCloud.asmx\"
724
+ \ <soap12:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
725
725
  />\r\n </wsdl:port>\r\n <wsdl:port name=\"TaxCloudHttpPost\" binding=\"tns:TaxCloudHttpPost\">\r\n
726
- \ <http:address location=\"https://api.taxcloud.net/1.0/TaxCloud.asmx\"
726
+ \ <http:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
727
727
  />\r\n </wsdl:port>\r\n </wsdl:service>\r\n</wsdl:definitions>"
728
728
  http_version:
729
729
  recorded_at: Thu, 09 Jan 2014 16:03:39 GMT
730
730
  - request:
731
731
  method: post
732
- uri: https://api.taxcloud.net/1.0/TaxCloud.asmx
732
+ uri: https://asmx.taxcloud.com/1.0/TaxCloud.asmx
733
733
  body:
734
734
  encoding: UTF-8
735
735
  string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://api.taxcloud.net/1.0/?wsdl
5
+ uri: https://asmx.taxcloud.com/1.0/?wsdl
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -719,17 +719,17 @@ http_interactions:
719
719
  part=\"Body\" />\r\n </wsdl:output>\r\n </wsdl:operation>\r\n </wsdl:binding>\r\n
720
720
  \ <wsdl:service name=\"TaxCloud\">\r\n <wsdl:documentation xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\">TaxCloud
721
721
  Web Service</wsdl:documentation>\r\n <wsdl:port name=\"TaxCloudSoap\" binding=\"tns:TaxCloudSoap\">\r\n
722
- \ <soap:address location=\"https://api.taxcloud.net/1.0/TaxCloud.asmx\"
722
+ \ <soap:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
723
723
  />\r\n </wsdl:port>\r\n <wsdl:port name=\"TaxCloudSoap12\" binding=\"tns:TaxCloudSoap12\">\r\n
724
- \ <soap12:address location=\"https://api.taxcloud.net/1.0/TaxCloud.asmx\"
724
+ \ <soap12:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
725
725
  />\r\n </wsdl:port>\r\n <wsdl:port name=\"TaxCloudHttpPost\" binding=\"tns:TaxCloudHttpPost\">\r\n
726
- \ <http:address location=\"https://api.taxcloud.net/1.0/TaxCloud.asmx\"
726
+ \ <http:address location=\"https://asmx.taxcloud.com/1.0/TaxCloud.asmx\"
727
727
  />\r\n </wsdl:port>\r\n </wsdl:service>\r\n</wsdl:definitions>"
728
728
  http_version:
729
729
  recorded_at: Thu, 09 Jan 2014 16:03:39 GMT
730
730
  - request:
731
731
  method: post
732
- uri: https://api.taxcloud.net/1.0/TaxCloud.asmx
732
+ uri: https://asmx.taxcloud.com/1.0/TaxCloud.asmx
733
733
  body:
734
734
  encoding: UTF-8
735
735
  string: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
@@ -1,4 +1,6 @@
1
- require 'test/unit'
1
+ # frozen_string_literal: true
2
+
3
+ require 'minitest/autorun'
2
4
  require 'tax_cloud'
3
5
  require 'json'
4
6
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'helper'
2
4
 
3
5
  class TestAddress < TestSetup
@@ -43,7 +45,7 @@ class TestAddress < TestSetup
43
45
  end
44
46
 
45
47
  def test_verify_bad_address
46
- e = assert_raise TaxCloud::Errors::ApiError do
48
+ e = assert_raises TaxCloud::Errors::ApiError do
47
49
  VCR.use_cassette('verify bad address') do
48
50
  bad_address = TaxCloud::Address.new address1: '10001 Test Street', city: 'New York', state: 'New York', zip5: '99999'
49
51
  bad_address.verify
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'helper'
2
4
 
3
- class TestCartItem < Test::Unit::TestCase
5
+ class TestCartItem < Minitest::Test
4
6
  def setup
5
7
  @cart_item = TaxCloud::CartItem.new index: 0, item_id: 'SKU-100', tic: '0000', price: 50.00, quantity: 3
6
8
  end
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'helper'
2
4
 
3
5
  class TestClient < TestSetup
4
6
  def test_ping_with_invalid_credentials
5
- assert_raise TaxCloud::Errors::ApiError do
7
+ assert_raises TaxCloud::Errors::ApiError do
6
8
  VCR.use_cassette('ping_with_invalid_credentials') do
7
9
  TaxCloud.client.ping
8
10
  end
@@ -10,7 +12,7 @@ class TestClient < TestSetup
10
12
  end
11
13
 
12
14
  def test_ping_with_invalid_response
13
- e = assert_raise TaxCloud::Errors::UnexpectedSoapResponse do
15
+ e = assert_raises TaxCloud::Errors::UnexpectedSoapResponse do
14
16
  VCR.use_cassette('ping_with_invalid_response') do
15
17
  TaxCloud.client.ping
16
18
  end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'helper'
4
+
5
+ describe 'TaxCloud::Configuration' do
6
+ def request
7
+ TaxCloud.client.instance_variable_get('@wsdl').request
8
+ end
9
+
10
+ def reset_and_configure(options = {})
11
+ TaxCloud.reset!
12
+ TaxCloud.configure do |config|
13
+ config.api_key = 'stubbed_api_key'
14
+ config.api_login_id = 'stubbed_api_login_id'
15
+ options.each do |key, value|
16
+ config.public_send("#{key}=", value)
17
+ end
18
+ end
19
+ end
20
+
21
+ describe 'open_timeout option' do
22
+ it 'has set default to 2' do
23
+ reset_and_configure
24
+ assert_equal 2, request.open_timeout
25
+ end
26
+
27
+ it 'can be changed via configuration' do
28
+ reset_and_configure(open_timeout: 3)
29
+ assert_equal 3, request.open_timeout
30
+ end
31
+ end
32
+
33
+ describe 'read_timeout option' do
34
+ it 'has set default to 2' do
35
+ reset_and_configure
36
+ assert_equal 2, request.read_timeout
37
+ end
38
+
39
+ it 'can be changed via configuration' do
40
+ reset_and_configure(read_timeout: 3)
41
+ assert_equal 3, request.read_timeout
42
+ end
43
+ end
44
+ end
@@ -1,12 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'helper'
2
4
 
3
- class TestConfiguration < Test::Unit::TestCase
5
+ class TestConfigurationRequiredKeys < Minitest::Test
4
6
  def setup
5
7
  TaxCloud.reset!
6
8
  end
7
9
 
8
10
  def test_missing_configuration
9
- assert_raise TaxCloud::Errors::MissingConfig do
11
+ assert_raises TaxCloud::Errors::MissingConfig do
10
12
  TaxCloud.client.request :dummy, body: {}
11
13
  end
12
14
  end
@@ -15,7 +17,7 @@ class TestConfiguration < Test::Unit::TestCase
15
17
  TaxCloud.configure do |config|
16
18
  config.api_key = 'taxcloud_api_key'
17
19
  end
18
- assert_raise TaxCloud::Errors::MissingConfigOption do
20
+ assert_raises TaxCloud::Errors::MissingConfigOption do
19
21
  TaxCloud.client.request :dummy, body: {}
20
22
  end
21
23
  end
@@ -24,7 +26,7 @@ class TestConfiguration < Test::Unit::TestCase
24
26
  TaxCloud.configure do |config|
25
27
  config.api_login_id = 'taxcloud_api_login_id'
26
28
  end
27
- assert_raise TaxCloud::Errors::MissingConfigOption do
29
+ assert_raises TaxCloud::Errors::MissingConfigOption do
28
30
  TaxCloud.client.request :dummy, body: {}
29
31
  end
30
32
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'helper'
4
+
5
+ class TestLookupResponse < TestSetup
6
+ class MockLookup < TaxCloud::Responses::Lookup
7
+ def initialize; end
8
+ end
9
+
10
+ def test_tax_amount_handles_decimal_addition_properly
11
+ response = TestLookupResponse::MockLookup.new
12
+
13
+ # `tax_amount`s chosen to provoke floating point arithmetic error
14
+ mock_savon_cart_items = [
15
+ { cart_item_index: '0', tax_amount: '0.35' },
16
+ { cart_item_index: '1', tax_amount: '0.7' }
17
+ ]
18
+ response.cart_items = mock_savon_cart_items.map { |i| TaxCloud::Responses::CartItem.new(i) }
19
+
20
+ assert_equal 1.05, response.tax_amount
21
+ end
22
+ end
@@ -1,4 +1,6 @@
1
- class TestSetup < Test::Unit::TestCase
1
+ # frozen_string_literal: true
2
+
3
+ class TestSetup < Minitest::Test
2
4
  def default_test
3
5
  # placeholder to avoid error under Ruby 1.8.7
4
6
  end
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'helper'
2
4
 
3
5
  class TestSoap < TestSetup
4
6
  def test_invalid_soap_call
5
- assert_raise Savon::UnknownOperationError do
7
+ assert_raises Savon::UnknownOperationError do
6
8
  VCR.use_cassette('invalid_soap_call') do
7
9
  TaxCloud.client.request :invalid, body: {}
8
10
  end
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'helper'
2
4
 
3
5
  class TestTaxCodeGroups < TestSetup
4
6
  def test_all
5
7
  VCR.use_cassette('get_tic_groups') do
6
- assert TaxCloud::TaxCode::Groups.all.count > 0
8
+ assert TaxCloud::TaxCode::Groups.all.count.positive?
7
9
  end
8
10
  end
9
11
 
@@ -20,7 +22,7 @@ class TestTaxCodeGroups < TestSetup
20
22
  TaxCloud::TaxCode::Groups[TaxCloud::TaxCode::Groups::SCHOOL_RELATED_PRODUCTS]
21
23
  end
22
24
  VCR.use_cassette('get_tics_by_group') do
23
- assert tax_code_group.tax_codes.count > 0
25
+ assert tax_code_group.tax_codes.count.positive?
24
26
  tax_code = tax_code_group[TaxCloud::TaxCodes::SCHOOL_INSTRUCTIONAL_MATERIAL]
25
27
  assert_equal TaxCloud::TaxCodes::SCHOOL_INSTRUCTIONAL_MATERIAL, tax_code.ticid
26
28
  assert_equal 'School instructional material', tax_code.description
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'helper'
2
4
 
3
5
  class TestTaxCode < TestSetup
4
6
  def test_all
5
7
  VCR.use_cassette('get_tics') do
6
- assert TaxCloud::TaxCodes.all.count > 0
8
+ assert TaxCloud::TaxCodes.all.count.positive?
7
9
  end
8
10
  end
9
11
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'helper'
2
4
 
3
5
  class TestTransaction < TestSetup
@@ -8,7 +10,7 @@ class TestTransaction < TestSetup
8
10
  cart_items = []
9
11
  cart_items << TaxCloud::CartItem.new(index: 0, item_id: 'SKU-TEST', tic: TaxCloud::TaxCodes::GENERAL, quantity: 1, price: 50.00)
10
12
  cart_items << TaxCloud::CartItem.new(index: 1, item_id: 'SKU-TEST1', tic: TaxCloud::TaxCodes::GENERAL, quantity: 1, price: 100.00)
11
- @transaction = TaxCloud::Transaction.new(customer_id: 42, cart_id: rand(18446744073709551616), order_id: rand(18446744073709551616), cart_items: cart_items, origin: origin, destination: destination)
13
+ @transaction = TaxCloud::Transaction.new(customer_id: 42, cart_id: rand(18_446_744_073_709_551_616), order_id: rand(18_446_744_073_709_551_616), cart_items: cart_items, origin: origin, destination: destination)
12
14
  end
13
15
 
14
16
  def test_lookup
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'helper'
2
4
 
3
5
  class TestTransactionNy < TestSetup
@@ -6,7 +8,7 @@ class TestTransactionNy < TestSetup
6
8
  origin = TaxCloud::Address.new address1: '888 6th Ave', city: 'New York', state: 'NY', zip5: '10001'
7
9
  destination = TaxCloud::Address.new address1: '888 6th Ave', city: 'New York', state: 'NY', zip5: '10001'
8
10
  cart_items = [TaxCloud::CartItem.new(index: 0, item_id: 'SKU-TEST', tic: TaxCloud::TaxCodes::GENERAL, quantity: 1, price: 50.00)]
9
- @transaction = TaxCloud::Transaction.new(customer_id: 42, cart_id: 708, order_id: rand(18446744073709551616), cart_items: cart_items, origin: origin, destination: destination)
11
+ @transaction = TaxCloud::Transaction.new(customer_id: 42, cart_id: 708, order_id: rand(18_446_744_073_709_551_616), cart_items: cart_items, origin: origin, destination: destination)
10
12
  end
11
13
 
12
14
  def test_lookup_non_ssuta_state