usps-imis-api 0.6.9 → 0.6.11

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 95cf7f953251bafc2de9622adb504b164b64560f6d069f7d2f43add89d138fc6
4
- data.tar.gz: 10f98facbfe76b78203c6afab20bd4ec1fbe83217a89c582bc28c45942e757a4
3
+ metadata.gz: cd7f53417285bbe15766b1e79e88448807a1e481f13cb20a16d1bfb791a96f15
4
+ data.tar.gz: fb6c040f10270293db091bd20c25de73679de83fd24bf1253cbd50f82e53c1e3
5
5
  SHA512:
6
- metadata.gz: 5921548e9fa41787c2b28a2ab7310afb02d8f4379369974e6165c2af3adc4a92b10e0753448e54bb01232de61114b203e277f36db1133df744c57a2fbcc1bc98
7
- data.tar.gz: 9a6247a5ddee4672e2fb116e4b18ccff763130d92816e85e228c6a1bdcf7d41ad71df6f504ebebba457741a7ec8d86c1accee105ead4261c5f62a0c06b061885
6
+ metadata.gz: e65d398030e74648c5c0ceadcc1ab9bd3b94e481d5c20c14761d30e3efa4dcb6a3293e1b4d2d5de2f3678acd8cac80f0051074cff86c99386023e097ce3e2b4e
7
+ data.tar.gz: f436a6c796ffef704e7fd73ceb59e9352b77bb1a35efa0cbf96909e47a3ee7c24fbf4288cbe413941da49e6bf69c8b88aa2a952c0426523ec4ff9b5ae8f2c3df
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- usps-imis-api (0.6.9)
4
+ usps-imis-api (0.6.11)
5
5
  activesupport (~> 8.0)
6
6
 
7
7
  GEM
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Usps
4
+ module Imis
5
+ # Mock data response for testing
6
+ #
7
+ class BusinessObjectMock
8
+ attr_reader :fields
9
+
10
+ def initialize(**fields)
11
+ @fields = fields.transform_keys(&:to_s)
12
+ end
13
+
14
+ def get_field(name) = fields[name]
15
+
16
+ def get
17
+ Usps::Imis::Properties.build do |props|
18
+ fields.each { |name, value| props.add(name, value) }
19
+ end
20
+ end
21
+
22
+ def put_fields(data)
23
+ Usps::Imis::Properties.build do |props|
24
+ fields.merge(data.transform_keys(&:to_s)).each { |name, value| props.add(name, value) }
25
+ end
26
+ end
27
+
28
+ def put(data) = data
29
+
30
+ def post(data) = data
31
+
32
+ def delete = ''
33
+ end
34
+ end
35
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- VERSION = '0.6.9'
5
+ VERSION = '0.6.11'
6
6
  end
7
7
  end
data/lib/usps/imis.rb CHANGED
@@ -23,6 +23,7 @@ require_relative 'imis/business_object'
23
23
  require_relative 'imis/api'
24
24
  require_relative 'imis/mapper'
25
25
  require_relative 'imis/properties'
26
+ require_relative 'imis/business_object_mock'
26
27
  require_relative 'imis/panel/base_panel'
27
28
  require_relative 'imis/panel/vsc'
28
29
  require_relative 'imis/panel/education'
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Usps::Imis::BusinessObjectMock do
6
+ let(:mock) { described_class.new(**fields) }
7
+ let(:fields) { { TotMMS: 2 } }
8
+
9
+ let(:data) do
10
+ Usps::Imis::Properties.build do |props|
11
+ props.add 'TotMMS', 2
12
+ end
13
+ end
14
+
15
+ describe 'get' do
16
+ it 'returns the correct data' do
17
+ expect(mock.get).to eq(data)
18
+ end
19
+ end
20
+
21
+ describe 'get_field' do
22
+ it 'returns the correct field value' do
23
+ expect(mock.get_field('TotMMS')).to eq(2)
24
+ end
25
+ end
26
+
27
+ describe 'put_fields' do
28
+ let(:combined_data) do
29
+ Usps::Imis::Properties.build do |props|
30
+ props.add 'TotMMS', 2
31
+ props.add 'SomethingElse', 'interesting'
32
+ end
33
+ end
34
+
35
+ it 'returns the correct data' do
36
+ expect(mock.put_fields(SomethingElse: 'interesting')).to eq(combined_data)
37
+ end
38
+ end
39
+
40
+ describe 'put' do
41
+ it 'returns the correct data' do
42
+ expect(mock.put(data)).to eq(data)
43
+ end
44
+ end
45
+
46
+ describe 'post' do
47
+ it 'returns the correct data' do
48
+ expect(mock.post(data)).to eq(data)
49
+ end
50
+ end
51
+
52
+ describe 'delete' do
53
+ it 'returns the correct data' do
54
+ expect(mock.delete).to eq('')
55
+ end
56
+ end
57
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usps-imis-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.9
4
+ version: 0.6.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander
@@ -45,6 +45,7 @@ files:
45
45
  - lib/usps/imis.rb
46
46
  - lib/usps/imis/api.rb
47
47
  - lib/usps/imis/business_object.rb
48
+ - lib/usps/imis/business_object_mock.rb
48
49
  - lib/usps/imis/config.rb
49
50
  - lib/usps/imis/error/api_error.rb
50
51
  - lib/usps/imis/error/mapper_error.rb
@@ -57,6 +58,7 @@ files:
57
58
  - lib/usps/imis/requests.rb
58
59
  - lib/usps/imis/version.rb
59
60
  - spec/lib/usps/imis/api_spec.rb
61
+ - spec/lib/usps/imis/business_object_mock_spec.rb
60
62
  - spec/lib/usps/imis/business_object_spec.rb
61
63
  - spec/lib/usps/imis/config_spec.rb
62
64
  - spec/lib/usps/imis/error/api_error_spec.rb