axiomus_api 0.5 → 0.5.1
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 +4 -4
- data/.travis.yml +1 -1
- data/Gemfile +1 -0
- data/Gemfile.lock +22 -15
- data/lib/axiomus_api/templates/labels.html.erb +5 -1
- data/lib/axiomus_api/version.rb +1 -1
- data/spec/factories.rb +5 -0
- data/spec/lib/axiomus_api/base_spec.rb +3 -6
- data/spec/lib/axiomus_api/{delivest_spec.rb → delivset_spec.rb} +1 -1
- data/spec/lib/axiomus_api/label_spec.rb +9 -3
- data/spec/lib/axiomus_api/order/base_order_spec.rb +5 -5
- data/spec/lib/axiomus_api/serializable_spec.rb +1 -1
- data/spec/lib/axiomus_api/session_spec.rb +21 -9
- data/spec/lib/axiomus_api/validated_spec.rb +8 -8
- data/spec/lib/axiomus_api_spec.rb +2 -2
- data/spec/spec_helper.rb +2 -2
- metadata +3 -4
- data/spec/support/http_mocking.rb +0 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 50bd78448890d4337232f0593a2cbe90dabe7f76
|
|
4
|
+
data.tar.gz: 325644e61718e860092725ac7dcd9f78e9497186
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c30d1fc0199217f475d7c8baff0e711b4df9727d75a972c80798a4d8fe7b59385197d8e4dc6378c786d2e8f5dbb0e43c49bfc94527c889ca55fad9e771fb48ce
|
|
7
|
+
data.tar.gz: d5d2d4afb48b2bf91afdc115111ed61846b3d762e6ac4d82545f9c18d38c3f71cf303455534c538e45d91ac18c0cea4de498b4e4512b8020268019c04fc9fd49
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -15,7 +15,7 @@ GEM
|
|
|
15
15
|
minitest (~> 5.1)
|
|
16
16
|
thread_safe (~> 0.1)
|
|
17
17
|
tzinfo (~> 1.1)
|
|
18
|
-
barby (0.
|
|
18
|
+
barby (0.6.1)
|
|
19
19
|
chunky_png (1.3.1)
|
|
20
20
|
coveralls (0.7.0)
|
|
21
21
|
multi_json (~> 1.3)
|
|
@@ -24,29 +24,35 @@ GEM
|
|
|
24
24
|
term-ansicolor
|
|
25
25
|
thor
|
|
26
26
|
diff-lcs (1.2.5)
|
|
27
|
-
docile (1.1.
|
|
27
|
+
docile (1.1.5)
|
|
28
28
|
factory_girl (4.4.0)
|
|
29
29
|
activesupport (>= 3.0.0)
|
|
30
30
|
faker (1.3.0)
|
|
31
31
|
i18n (~> 0.5)
|
|
32
32
|
i18n (0.6.9)
|
|
33
33
|
json (1.8.1)
|
|
34
|
-
mime-types (2.
|
|
34
|
+
mime-types (2.3)
|
|
35
35
|
mini_portile (0.6.0)
|
|
36
|
-
minitest (5.3.
|
|
37
|
-
multi_json (1.10.
|
|
36
|
+
minitest (5.3.5)
|
|
37
|
+
multi_json (1.10.1)
|
|
38
38
|
nokogiri (1.6.2.1)
|
|
39
39
|
mini_portile (= 0.6.0)
|
|
40
40
|
rest-client (1.6.7)
|
|
41
41
|
mime-types (>= 1.16)
|
|
42
|
-
rspec (
|
|
43
|
-
rspec-core (~>
|
|
44
|
-
rspec-expectations (~>
|
|
45
|
-
rspec-mocks (~>
|
|
46
|
-
rspec-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
42
|
+
rspec (3.0.0)
|
|
43
|
+
rspec-core (~> 3.0.0)
|
|
44
|
+
rspec-expectations (~> 3.0.0)
|
|
45
|
+
rspec-mocks (~> 3.0.0)
|
|
46
|
+
rspec-collection_matchers (1.0.0)
|
|
47
|
+
rspec-expectations (>= 2.99.0.beta1)
|
|
48
|
+
rspec-core (3.0.1)
|
|
49
|
+
rspec-support (~> 3.0.0)
|
|
50
|
+
rspec-expectations (3.0.1)
|
|
51
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
52
|
+
rspec-support (~> 3.0.0)
|
|
53
|
+
rspec-mocks (3.0.1)
|
|
54
|
+
rspec-support (~> 3.0.0)
|
|
55
|
+
rspec-support (3.0.0)
|
|
50
56
|
simplecov (0.8.2)
|
|
51
57
|
docile (~> 1.1.0)
|
|
52
58
|
multi_json
|
|
@@ -55,9 +61,9 @@ GEM
|
|
|
55
61
|
term-ansicolor (1.3.0)
|
|
56
62
|
tins (~> 1.0)
|
|
57
63
|
thor (0.19.1)
|
|
58
|
-
thread_safe (0.3.
|
|
64
|
+
thread_safe (0.3.4)
|
|
59
65
|
tins (1.3.0)
|
|
60
|
-
tzinfo (1.1
|
|
66
|
+
tzinfo (1.2.1)
|
|
61
67
|
thread_safe (~> 0.1)
|
|
62
68
|
|
|
63
69
|
PLATFORMS
|
|
@@ -69,3 +75,4 @@ DEPENDENCIES
|
|
|
69
75
|
factory_girl (~> 4.0)
|
|
70
76
|
faker
|
|
71
77
|
rspec
|
|
78
|
+
rspec-collection_matchers
|
|
@@ -76,7 +76,11 @@
|
|
|
76
76
|
<div class="d9"><b><i><%= label.weight.round(1) %></i></b><span class="cu"> кг</span></div>
|
|
77
77
|
<div class="d5"><%= label.type %></div>
|
|
78
78
|
<div class="d6"><%= label.city %></div>
|
|
79
|
-
<div class="d7"
|
|
79
|
+
<div class="d7">
|
|
80
|
+
<% if label.place && label.places %>
|
|
81
|
+
<%= label.place %>/<%= label.places %>
|
|
82
|
+
<% end %>
|
|
83
|
+
</div>
|
|
80
84
|
</div>
|
|
81
85
|
</div>
|
|
82
86
|
<% end %>
|
data/lib/axiomus_api/version.rb
CHANGED
data/spec/factories.rb
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
require_relative '../../spec_helper'
|
|
2
2
|
|
|
3
|
-
describe
|
|
3
|
+
describe AxiomusApi::Base do
|
|
4
4
|
|
|
5
5
|
it 'should raise on wrong xml options' do
|
|
6
6
|
expect do
|
|
7
|
-
class C <
|
|
7
|
+
class C < described_class
|
|
8
8
|
xml_field :some_field, unknown_option: 21
|
|
9
9
|
end
|
|
10
10
|
end.to raise_error
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
it 'should raise if no tag name' do
|
|
14
|
-
|
|
15
|
-
class C < AxiomusApi::Base
|
|
14
|
+
class C < described_class
|
|
16
15
|
xml_field :value
|
|
17
16
|
end
|
|
18
17
|
|
|
19
18
|
c = C.new
|
|
20
19
|
c.value = '32'
|
|
21
|
-
|
|
22
20
|
expect{c.tag_name}.to raise_error
|
|
23
|
-
|
|
24
21
|
end
|
|
25
22
|
|
|
26
23
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require_relative '../../spec_helper'
|
|
2
2
|
|
|
3
|
-
describe
|
|
3
|
+
describe AxiomusApi::Label do
|
|
4
4
|
it 'should generate barcode' do
|
|
5
5
|
@label = build(:label)
|
|
6
6
|
expect{barcode = @label_barcode64}.not_to raise_error
|
|
@@ -8,11 +8,17 @@ describe 'AxiomusApi::Label' do
|
|
|
8
8
|
|
|
9
9
|
it 'should render single label' do
|
|
10
10
|
@label = build(:label)
|
|
11
|
-
expect{html =
|
|
11
|
+
expect{html = described_class.render(@label)}.not_to raise_error
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
it 'should render multiple labels' do
|
|
15
15
|
@labels = (1..10).map{build(:label)}
|
|
16
|
-
expect{html =
|
|
16
|
+
expect{html = described_class.render(@labels)}.not_to raise_error
|
|
17
17
|
end
|
|
18
|
+
|
|
19
|
+
it 'renders label without places' do
|
|
20
|
+
@label = build(:label_without_places)
|
|
21
|
+
expect{html = described_class.render(@label)}.not_to raise_error
|
|
22
|
+
end
|
|
23
|
+
|
|
18
24
|
end
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
require_relative '../../../spec_helper'
|
|
2
2
|
|
|
3
|
-
describe
|
|
3
|
+
describe AxiomusApi::BaseOrder do
|
|
4
4
|
|
|
5
5
|
it 'should build order by mode' do
|
|
6
6
|
ORDER_MODES.each do |mode|
|
|
7
|
-
order =
|
|
7
|
+
order = described_class.create_by_mode(mode)
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
it 'should create item' do
|
|
12
12
|
ORDER_MODES.each do |mode|
|
|
13
|
-
order =
|
|
13
|
+
order = described_class.create_by_mode(mode)
|
|
14
14
|
item = order.items.add_item
|
|
15
15
|
item.quantity = 21
|
|
16
16
|
expect(order.items.item.first.quantity).to eq(21)
|
|
17
17
|
|
|
18
18
|
if [:new_export, :update_export, :new_self_export, :update_self_export].include?(mode)
|
|
19
|
-
expect(item.is_a?(AxiomusApi::ExportItem)).to
|
|
19
|
+
expect(item.is_a?(AxiomusApi::ExportItem)).to be_truthy
|
|
20
20
|
else
|
|
21
|
-
expect(item.is_a?(AxiomusApi::Item)).to
|
|
21
|
+
expect(item.is_a?(AxiomusApi::Item)).to be_truthy
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
end
|
|
@@ -1,24 +1,36 @@
|
|
|
1
1
|
require_relative '../../spec_helper'
|
|
2
2
|
|
|
3
|
-
describe
|
|
3
|
+
describe AxiomusApi::Session do
|
|
4
4
|
before(:all) do
|
|
5
5
|
AxiomusApi.logger.level = Logger::UNKNOWN
|
|
6
6
|
|
|
7
7
|
@session = AxiomusApi.test_session
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
+
def enqueue_response(response_body, code = '200', msg='OK')
|
|
11
|
+
@responses ||= []
|
|
12
|
+
@responses.push([response_body, code, msg])
|
|
13
|
+
|
|
14
|
+
allow_any_instance_of(Net::HTTP).to receive(:request) do |req|
|
|
15
|
+
next_response = @responses.shift
|
|
16
|
+
response = Net::HTTPResponse.new(1.0, next_response[1], next_response[2])
|
|
17
|
+
allow(response).to receive(:body) {next_response[0]}
|
|
18
|
+
response
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
10
22
|
ORDER_MODES.each do |method|
|
|
11
23
|
order_class = order_factory_name(method)
|
|
12
24
|
|
|
13
25
|
describe "##{method}" do
|
|
14
26
|
it 'should handle successful request' do
|
|
15
|
-
|
|
27
|
+
enqueue_response(DummyData.order_success_response(method))
|
|
16
28
|
response = @session.send(method, build(order_class))
|
|
17
29
|
expect(response.code).to eq 0
|
|
18
30
|
end
|
|
19
31
|
|
|
20
32
|
it 'should raise on error' do
|
|
21
|
-
|
|
33
|
+
enqueue_response(DummyData.order_error_response(method))
|
|
22
34
|
expect{@session.send(method, build(order_class))}.to raise_error(AxiomusApi::Errors::RequestError)
|
|
23
35
|
end
|
|
24
36
|
end
|
|
@@ -26,7 +38,7 @@ describe 'AxiomusApi::Session' do
|
|
|
26
38
|
|
|
27
39
|
describe '#get_regions' do
|
|
28
40
|
it 'should handle successfull request' do
|
|
29
|
-
|
|
41
|
+
enqueue_response(DummyData::REGIONS_SUCCESS_RESPONSE)
|
|
30
42
|
z = @session.get_regions()
|
|
31
43
|
expect(z.regions.count).to eq 1
|
|
32
44
|
expect(z.regions.first.code).to eq '21'
|
|
@@ -35,7 +47,7 @@ describe 'AxiomusApi::Session' do
|
|
|
35
47
|
|
|
36
48
|
describe '#status' do
|
|
37
49
|
it 'should handle successfull request' do
|
|
38
|
-
|
|
50
|
+
enqueue_response(DummyData::STATUS_SUCCESS_RESPONSE)
|
|
39
51
|
z = @session.status('2e3023c3e78f4f0c8cbb81257743c2d7')
|
|
40
52
|
expect(z.order.id).to eq('1013')
|
|
41
53
|
expect(z.order.inner_id).to eq('16777')
|
|
@@ -48,21 +60,21 @@ describe 'AxiomusApi::Session' do
|
|
|
48
60
|
|
|
49
61
|
describe '#status_list' do
|
|
50
62
|
it 'should handle successfull request' do
|
|
51
|
-
|
|
63
|
+
enqueue_response(DummyData::STATUS_LIST_SUCCESS_RESPONSE)
|
|
52
64
|
z = @session.status_list(['7bbf66349060b723bba20ef687ee4ebf', 'f2c2635a00310d39cf26b7cc1db6fab2'])
|
|
53
65
|
end
|
|
54
66
|
end
|
|
55
67
|
|
|
56
68
|
describe '#get_version' do
|
|
57
69
|
it 'should handle successfull request' do
|
|
58
|
-
|
|
70
|
+
enqueue_response(DummyData::GET_VERSION_SUCCESS_RESPONSE)
|
|
59
71
|
z = @session.get_version
|
|
60
72
|
expect(z).to eq('2.12')
|
|
61
73
|
end
|
|
62
74
|
end
|
|
63
75
|
|
|
64
76
|
it 'should accept a block' do
|
|
65
|
-
|
|
77
|
+
enqueue_response(DummyData::REGIONS_SUCCESS_RESPONSE)
|
|
66
78
|
res = nil
|
|
67
79
|
|
|
68
80
|
AxiomusApi.test_session do |s|
|
|
@@ -76,7 +88,7 @@ describe 'AxiomusApi::Session' do
|
|
|
76
88
|
describe '#send_order_request' do
|
|
77
89
|
it 'should raise on invalid order' do
|
|
78
90
|
order = build(:dpd_order, :without_address)
|
|
79
|
-
|
|
91
|
+
enqueue_response(DummyData.order_success_response(:new_dpd))
|
|
80
92
|
expect{@session.send_order_request(:new_dpd, order)}.to raise_error(AxiomusApi::Errors::ValidationError)
|
|
81
93
|
end
|
|
82
94
|
end
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
require_relative '../../spec_helper'
|
|
2
2
|
|
|
3
|
-
describe
|
|
3
|
+
describe AxiomusApi::Validated do
|
|
4
4
|
|
|
5
5
|
it 'should validate required fields' do
|
|
6
6
|
address = build(:dpd_address, :without_region)
|
|
7
7
|
expect(address).not_to be_valid
|
|
8
|
-
expect(address.validation_errors).to
|
|
8
|
+
expect(address.validation_errors).to have_exactly(1).items
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
it 'should validate empty fields' do
|
|
12
12
|
order = build(:order, :with_empty_address)
|
|
13
13
|
expect(order).not_to be_valid
|
|
14
|
-
expect(order.validation_errors).to
|
|
14
|
+
expect(order.validation_errors).to have_exactly(1).items
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
it 'should validate wrong type fields' do
|
|
18
18
|
order = build(:post_order, :with_region_services)
|
|
19
19
|
expect(order).not_to be_valid
|
|
20
|
-
expect(order.validation_errors).to
|
|
20
|
+
expect(order.validation_errors).to have_exactly(1).items
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
it 'should validate nested fields' do
|
|
24
24
|
order = build(:dpd_order)
|
|
25
25
|
order.address.region = nil
|
|
26
26
|
expect(order).not_to be_valid
|
|
27
|
-
expect(order.validation_errors).to
|
|
27
|
+
expect(order.validation_errors).to have_exactly(1).items
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
it 'should validate correct items' do
|
|
31
31
|
order = build(:post_order)
|
|
32
32
|
expect(order).to be_valid
|
|
33
|
-
expect(order.validation_errors).to
|
|
33
|
+
expect(order.validation_errors).to have_exactly(0).items
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
it 'should validate array items' do
|
|
@@ -41,7 +41,7 @@ describe 'AxiomusApi::Validated' do
|
|
|
41
41
|
order.delivset.above_sum = 12
|
|
42
42
|
order.delivset.above_price = 12
|
|
43
43
|
expect(order).not_to be_valid
|
|
44
|
-
expect(order.validation_errors).to
|
|
44
|
+
expect(order.validation_errors).to have_exactly(1).items
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
it 'should validate max occurs' do
|
|
@@ -56,7 +56,7 @@ describe 'AxiomusApi::Validated' do
|
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
expect(order).not_to be_valid
|
|
59
|
-
expect(order.validation_errors).to
|
|
59
|
+
expect(order.validation_errors).to have_exactly(1).items
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
it 'should validate optional arrays' do
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
require 'coveralls'
|
|
2
2
|
Coveralls.wear!
|
|
3
|
-
|
|
3
|
+
require 'rspec/collection_matchers'
|
|
4
4
|
require 'factory_girl'
|
|
5
5
|
|
|
6
6
|
RSpec.configure do |config|
|
|
7
7
|
config.include FactoryGirl::Syntax::Methods
|
|
8
|
+
config.mock_with :rspec
|
|
8
9
|
end
|
|
9
10
|
|
|
10
11
|
ORDER_MODES = [:new, :update, :new_carry, :update_carry, :new_export, :update_export,
|
|
@@ -24,5 +25,4 @@ end
|
|
|
24
25
|
|
|
25
26
|
require_relative '../lib/axiomus_api.rb'
|
|
26
27
|
require_relative 'support/dummy_data.rb'
|
|
27
|
-
require_relative 'support/http_mocking.rb'
|
|
28
28
|
require_relative 'factories.rb'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: axiomus_api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 0.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kinderly LTD
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-
|
|
11
|
+
date: 2014-06-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: nokogiri
|
|
@@ -120,7 +120,7 @@ files:
|
|
|
120
120
|
- spec/factories.rb
|
|
121
121
|
- spec/integration/lib/axiomus_api/session_spec.rb
|
|
122
122
|
- spec/lib/axiomus_api/base_spec.rb
|
|
123
|
-
- spec/lib/axiomus_api/
|
|
123
|
+
- spec/lib/axiomus_api/delivset_spec.rb
|
|
124
124
|
- spec/lib/axiomus_api/label_spec.rb
|
|
125
125
|
- spec/lib/axiomus_api/order/base_order_spec.rb
|
|
126
126
|
- spec/lib/axiomus_api/serializable_spec.rb
|
|
@@ -129,7 +129,6 @@ files:
|
|
|
129
129
|
- spec/lib/axiomus_api_spec.rb
|
|
130
130
|
- spec/spec_helper.rb
|
|
131
131
|
- spec/support/dummy_data.rb
|
|
132
|
-
- spec/support/http_mocking.rb
|
|
133
132
|
homepage: https://github.com/kinderly/axiomus_api
|
|
134
133
|
licenses:
|
|
135
134
|
- MIT
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
require 'net/http'
|
|
2
|
-
|
|
3
|
-
module HttpMocking
|
|
4
|
-
|
|
5
|
-
def self.enqueue_response(response_body, code = '200', msg='OK')
|
|
6
|
-
@responses ||= []
|
|
7
|
-
@responses.push([response_body, code, msg])
|
|
8
|
-
|
|
9
|
-
Net::HTTP.any_instance.stub(:request) do |req|
|
|
10
|
-
next_response = @responses.shift
|
|
11
|
-
response = Net::HTTPResponse.new(1.0, next_response[1], next_response[2])
|
|
12
|
-
response.stub(:body => next_response[0])
|
|
13
|
-
response
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
end
|