suretax 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 219c714ae131b08b8baf222151f95fa177096d3cdc382713e513b504e2a25ec4
4
- data.tar.gz: e09da2a4482a0710b0b128148d6f69ae066e849bea49d92fae2cfccaf6873e1b
3
+ metadata.gz: 620a9d4fb40588a041c883da4f0ebeba65d78a03b1b215808c1ad92b8d5cd48d
4
+ data.tar.gz: 1070aa9064d87eddfa9e541e75cfd45413f95fb9baff06718ae4505b108a76a3
5
5
  SHA512:
6
- metadata.gz: c802a77252ee299ffd0094ecceb7e23313d0bf69acb66b48ce55036b1d9d8f3fafa4ebd158a414ada32b8ab1dd29f97e6e95ff334729a48a29ef665e7faa3a33
7
- data.tar.gz: c704deb4f9b7492aa0a742881b89c9409a896b4bc8c26b39942432336cf66559a754010b42bfa82ebb0151be7c46397e3719ec1cb6561c2611b8cb93dd23f57d
6
+ metadata.gz: 38ded09d6aa2104b5aa384669a6f5a51ee18178844b0a1e08909cefc9cb8ba549d6a46ce12d167786c872990bf83158e62b33d5274fd696e8bb0f1d977f4792d
7
+ data.tar.gz: c6931fb4060cb38e409f6b9adead8a81c5b8eb30c6f1af566c678afecb70008dd1ab96b7dce02be95107b481dfc5de8c18f287955cd371cb1e106e11662804e3
@@ -1,35 +1,44 @@
1
1
  version: 2
2
2
  jobs:
3
3
  build:
4
- working_directory: ~/suretax
5
4
  docker:
6
- - image: circleci/ruby:2.6.3
7
- environment:
8
- RAILS_ENV: test
9
- RAKE_ENV: test
10
- SURETAX_BASE_URL: "https://testapi.taxrating.net"
11
- SURETAX_VALIDATION_KEY: "xxxxxxxxxx"
12
- SURETAX_CLIENT_NUMBER: "000000000"
13
- SURETAX_POST_PATH: "/Services/V01/SureTax.asmx/PostRequest"
14
- SURETAX_CANCEL_PATH: "/Services/V01/SureTax.asmx/CancelPostRequest"
15
-
5
+ - image: circleci/ruby:2.7.0
6
+ environment:
7
+ RAILS_ENV: test
8
+ RAKE_ENV: test
9
+ SURETAX_BASE_URL: "https://testapi.taxrating.net"
10
+ SURETAX_VALIDATION_KEY: "xxxxxxxxxx"
11
+ SURETAX_CLIENT_NUMBER: "000000000"
12
+ SURETAX_POST_PATH: "/Services/V01/SureTax.asmx/PostRequest"
13
+ SURETAX_CANCEL_PATH: "/Services/V01/SureTax.asmx/CancelPostRequest"
14
+ working_directory: ~/suretax
16
15
  steps:
17
16
  - checkout
18
-
19
17
  - restore_cache:
20
18
  keys:
21
- - suretax-{{ checksum "Gemfile.lock" }}
22
- - run: bundle check --path vendor/bundle || bundle install --path=vendor/bundle --jobs 4 --retry 3
19
+ - v1-dependencies-{{ checksum "Gemfile.lock" }}
20
+ # fallback to using the latest cache if no exact match is found
21
+ - v1-dependencies-
22
+ - run:
23
+ name: install dependencies
24
+ command: |
25
+ bundle install --jobs=4 --retry=3 --path vendor/bundle
23
26
  - save_cache:
24
- key: suretax-{{ checksum "Gemfile.lock" }}
25
- paths: vendor/bundle
26
-
27
- - type: shell
28
- command: |
29
- bundle exec rspec --color \
30
- spec \
31
- --out /tmp/test-results/rspec.xml \
32
- --format progress
33
-
34
- - type: store_test_results
35
- path: /tmp/test-results
27
+ paths:
28
+ - ./vendor/bundle
29
+ key: v1-dependencies-{{ checksum "Gemfile.lock" }}
30
+ - run:
31
+ name: run tests
32
+ command: |
33
+ mkdir /tmp/test-results
34
+ TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
35
+ bundle exec rspec --format progress \
36
+ --format RspecJunitFormatter \
37
+ --out /tmp/test-results/rspec.xml \
38
+ --format progress \
39
+ $TEST_FILES
40
+ - store_test_results:
41
+ path: /tmp/test-results
42
+ - store_artifacts:
43
+ path: /tmp/test-results
44
+ destination: test-results
@@ -0,0 +1,4 @@
1
+ SURETAX_VALIDATION_KEY=885aa2c6-1a61-4ec6-9aa6-296120572b5e
2
+ SURETAX_CLIENT_NUMBER=000000123
3
+ SURETAX_BASE_URL=https://testapi.taxrating.net
4
+ SURETAX_REQUEST_VERSION=02
@@ -1 +1 @@
1
- 2.6.3
1
+ 2.7.0
data/Gemfile CHANGED
@@ -1,13 +1,12 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in suretax.gemspec
4
3
  gemspec
5
4
 
6
5
  group :development, :test do
7
6
  gem "dotenv"
8
- gem "pry-byebug", "~> 3.6.0"
9
- gem "rspec", "~> 3.8.0"
10
- gem "rspec-its", "~> 1.3"
11
- gem "rspec_junit_formatter", "~> 0.4.1"
12
- gem "webmock", "> 2.3"
7
+ gem "pry-byebug"
8
+ gem "rspec", "~> 3.9.0"
9
+ gem "rspec-its"
10
+ gem "rspec_junit_formatter"
11
+ gem "webmock"
13
12
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- suretax (1.1.1)
4
+ suretax (1.1.2)
5
5
  excon
6
6
  monetize
7
7
  money (~> 6.13)
@@ -9,51 +9,51 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- addressable (2.6.0)
13
- public_suffix (>= 2.0.2, < 4.0)
14
- byebug (10.0.2)
12
+ addressable (2.7.0)
13
+ public_suffix (>= 2.0.2, < 5.0)
14
+ byebug (11.1.3)
15
15
  coderay (1.1.2)
16
- concurrent-ruby (1.1.5)
16
+ concurrent-ruby (1.1.6)
17
17
  crack (0.4.3)
18
18
  safe_yaml (~> 1.0.0)
19
19
  diff-lcs (1.3)
20
- dotenv (2.7.2)
21
- excon (0.64.0)
22
- hashdiff (0.4.0)
23
- i18n (1.6.0)
20
+ dotenv (2.7.5)
21
+ excon (0.73.0)
22
+ hashdiff (1.0.1)
23
+ i18n (1.8.2)
24
24
  concurrent-ruby (~> 1.0)
25
- method_source (0.9.2)
26
- monetize (1.9.1)
25
+ method_source (1.0.0)
26
+ monetize (1.9.4)
27
27
  money (~> 6.12)
28
- money (6.13.4)
28
+ money (6.13.7)
29
29
  i18n (>= 0.6.4, <= 2)
30
- pry (0.12.2)
31
- coderay (~> 1.1.0)
32
- method_source (~> 0.9.0)
33
- pry-byebug (3.6.0)
34
- byebug (~> 10.0)
35
- pry (~> 0.10)
36
- public_suffix (3.1.0)
37
- rspec (3.8.0)
38
- rspec-core (~> 3.8.0)
39
- rspec-expectations (~> 3.8.0)
40
- rspec-mocks (~> 3.8.0)
41
- rspec-core (3.8.1)
42
- rspec-support (~> 3.8.0)
43
- rspec-expectations (3.8.4)
30
+ pry (0.13.1)
31
+ coderay (~> 1.1)
32
+ method_source (~> 1.0)
33
+ pry-byebug (3.9.0)
34
+ byebug (~> 11.0)
35
+ pry (~> 0.13.0)
36
+ public_suffix (4.0.5)
37
+ rspec (3.9.0)
38
+ rspec-core (~> 3.9.0)
39
+ rspec-expectations (~> 3.9.0)
40
+ rspec-mocks (~> 3.9.0)
41
+ rspec-core (3.9.2)
42
+ rspec-support (~> 3.9.3)
43
+ rspec-expectations (3.9.2)
44
44
  diff-lcs (>= 1.2.0, < 2.0)
45
- rspec-support (~> 3.8.0)
45
+ rspec-support (~> 3.9.0)
46
46
  rspec-its (1.3.0)
47
47
  rspec-core (>= 3.0.0)
48
48
  rspec-expectations (>= 3.0.0)
49
- rspec-mocks (3.8.1)
49
+ rspec-mocks (3.9.1)
50
50
  diff-lcs (>= 1.2.0, < 2.0)
51
- rspec-support (~> 3.8.0)
52
- rspec-support (3.8.2)
51
+ rspec-support (~> 3.9.0)
52
+ rspec-support (3.9.3)
53
53
  rspec_junit_formatter (0.4.1)
54
54
  rspec-core (>= 2, < 4, != 2.12.0)
55
55
  safe_yaml (1.0.5)
56
- webmock (3.6.0)
56
+ webmock (3.8.3)
57
57
  addressable (>= 2.3.6)
58
58
  crack (>= 0.3.2)
59
59
  hashdiff (>= 0.4.0, < 2.0.0)
@@ -63,12 +63,12 @@ PLATFORMS
63
63
 
64
64
  DEPENDENCIES
65
65
  dotenv
66
- pry-byebug (~> 3.6.0)
67
- rspec (~> 3.8.0)
68
- rspec-its (~> 1.3)
69
- rspec_junit_formatter (~> 0.4.1)
66
+ pry-byebug
67
+ rspec (~> 3.9.0)
68
+ rspec-its
69
+ rspec_junit_formatter
70
70
  suretax!
71
- webmock (> 2.3)
71
+ webmock
72
72
 
73
73
  BUNDLED WITH
74
- 1.17.2
74
+ 2.1.2
data/README.md CHANGED
@@ -1,6 +1,5 @@
1
1
  # Suretax
2
- [![Code Climate](https://codeclimate.com/github/bqsoft/suretax.png)](https://codeclimate.com/github/bqsoft/suretax)
3
-
2
+ [![Code Climate](https://codeclimate.com/github/hello-labs/suretax.png)](https://codeclimate.com/github/hello-labs/suretax)
4
3
 
5
4
  ## Synopsis
6
5
 
@@ -28,17 +27,14 @@ Suretax transactions. The validation_key, client_number, and
28
27
  base_url may be overridden by supplying the key when instantiating
29
28
  a Suretax::Api::Request object.
30
29
 
31
-
32
- If not supplied, the base_url will default to the Suretax test
30
+ If not supplied, the base_url will default to the Suretax test
33
31
  host (https://testapi.taxrating.net) and the request version
34
32
  and cancel version will default to the latest versions available
35
33
  (currently V03 and V01 respectively).
36
34
 
37
-
38
35
  You can peek inside the tests for more examples and to see what data
39
36
  methods are available.
40
37
 
41
-
42
38
  ## Development Environment
43
39
 
44
40
  Suretax uses [dotenv] to easily switch between development/test environments
@@ -8,6 +8,8 @@ require "suretax/api"
8
8
  require "money"
9
9
 
10
10
  Money.locale_backend = :currency
11
+ Money.default_currency = Money::Currency.new("USD")
12
+ Money.rounding_mode = BigDecimal::ROUND_HALF_EVEN
11
13
 
12
14
  module Suretax
13
15
  class << self
@@ -1,6 +1,7 @@
1
1
  module Suretax
2
2
  module Api
3
3
  class ValidationError < StandardError; end
4
+ class ConnectionError < StandardError; end
4
5
 
5
6
  class Request
6
7
  include Suretax::Concerns::Validatable
@@ -27,6 +27,8 @@ module Suretax
27
27
  @status = map_response_code_to_http_status(api.status)
28
28
  log_response
29
29
  self
30
+ rescue JSON::ParserError => e
31
+ raise(Suretax::Api::ConnectionError, "Failed to parse response from SureTax: #{e.inspect}")
30
32
  end
31
33
 
32
34
  def invalid_request_response(sanitized_body)
@@ -1,3 +1,3 @@
1
1
  module Suretax
2
- VERSION = "1.1.1".freeze
2
+ VERSION = "1.1.2".freeze
3
3
  end
@@ -129,4 +129,12 @@ describe Suretax::Response do
129
129
  expect(client_response).to_not be_success
130
130
  end
131
131
  end
132
+
133
+ context "when posting fails with a html error" do
134
+ let(:response_body) { suretax_wrap_response("html error") }
135
+
136
+ it "should raise connection error" do
137
+ expect { client_response }.to raise_error(Suretax::Api::ConnectionError)
138
+ end
139
+ end
132
140
  end
@@ -1,5 +1,5 @@
1
- require "dotenv" # First line of spec_helper
2
- Dotenv.load # Second line of spec_helper
1
+ require "dotenv"
2
+ Dotenv.load(".env.test")
3
3
 
4
4
  require "pry"
5
5
  require "rspec"
@@ -15,8 +15,8 @@ end
15
15
  RSpec.configure do |config|
16
16
  config.before(:each) do
17
17
  Suretax.configure do |c|
18
- c.validation_key = ENV["SURETAX_VALIDATION_KEY"]
19
- c.client_number = ENV["SURETAX_CLIENT_NUMBER"]
18
+ c.validation_key = ENV["SURETAX_VALIDATION_KEY"]
19
+ c.client_number = ENV["SURETAX_CLIENT_NUMBER"]
20
20
  end
21
21
  end
22
22
 
@@ -351,4 +351,22 @@ module RequestSpecHelper
351
351
  common_carrier: nil
352
352
  }
353
353
  end
354
+
355
+ def suretax_html_error
356
+ "<html xmlns='http://www.w3.org/1999/xhtml'>
357
+ <head>
358
+ <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
359
+ <title>502 - Web server received an invalid response while acting as a gateway or proxy server.</title>
360
+ </head>
361
+ <body>
362
+ <div id='header'><h1>Server Error</h1></div>
363
+ <div id='content'>
364
+ <div class='content-container'><fieldset>
365
+ <h2>502 - Web server received an invalid response while acting as a gateway or proxy server.</h2>
366
+ <h3>There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.</h3>
367
+ </fieldset></div>
368
+ </div>
369
+ </body>
370
+ </html>"
371
+ end
354
372
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: suretax
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damon Davison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-14 00:00:00.000000000 Z
11
+ date: 2020-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -61,6 +61,7 @@ extra_rdoc_files: []
61
61
  files:
62
62
  - ".circleci/config.yml"
63
63
  - ".env.example"
64
+ - ".env.test"
64
65
  - ".gitignore"
65
66
  - ".rspec"
66
67
  - ".rubocop.yml"
@@ -68,7 +69,6 @@ files:
68
69
  - Gemfile
69
70
  - Gemfile.lock
70
71
  - LICENSE.txt
71
- - NOTES.md
72
72
  - README.md
73
73
  - Rakefile
74
74
  - lib/suretax.rb
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  - !ruby/object:Gem::Version
133
133
  version: '0'
134
134
  requirements: []
135
- rubygems_version: 3.0.3
135
+ rubygems_version: 3.1.2
136
136
  signing_key:
137
137
  specification_version: 4
138
138
  summary: This gem will allow Ruby developers to easily integrate SureTax into their
data/NOTES.md DELETED
@@ -1,3 +0,0 @@
1
- # Suretax gem notes
2
-
3
- - Deal with post failures and parse errors in Response.