-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
159 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
*.sublime* | ||
/vendor/bundle | ||
/coverage | ||
.coveralls.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require_relative '../../spec_helper' | ||
|
||
describe 'AxiomusApi::Base' do | ||
|
||
it 'should raise on wrong xml options' do | ||
expect do | ||
class C < AxiomusApi::Base | ||
xml_field :some_field, unknown_option: 21 | ||
end | ||
end.to raise_error | ||
end | ||
|
||
it 'should raise if no tag name' do | ||
|
||
class C < AxiomusApi::Base | ||
xml_field :value | ||
end | ||
|
||
c = C.new | ||
c.value = '32' | ||
|
||
expect{c.tag_name}.to raise_error | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require_relative '../../spec_helper' | ||
|
||
describe 'AxiomusApi::Serializable' do | ||
|
||
it 'should serialize value as text node' do | ||
|
||
class Node < AxiomusApi::Base | ||
xml_element :node | ||
xml_field :value, xml_type: :text | ||
xml_attribute :id | ||
end | ||
|
||
n = Node.new | ||
n.id = 1 | ||
n.value = 'Some value' | ||
|
||
expect(n.to_xml()).to eq('<node id="1">Some value</node>') | ||
|
||
end | ||
|
||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require_relative '../../spec_helper' | ||
|
||
describe 'AxiomusApi::Validated' do | ||
|
||
it 'should validate required fields' do | ||
address = build(:dpd_address, :without_region) | ||
expect(address).not_to be_valid | ||
expect(address.validation_errors).to have(1).items | ||
end | ||
|
||
it 'should validate empty fields' do | ||
order = build(:order, :with_empty_address) | ||
expect(order).not_to be_valid | ||
expect(order.validation_errors).to have(1).items | ||
end | ||
|
||
it 'should validate wrong type fields' do | ||
order = build(:post_order, :with_region_services) | ||
expect(order).not_to be_valid | ||
expect(order.validation_errors).to have(1).items | ||
end | ||
|
||
it 'should validate nested fields' do | ||
order = build(:dpd_order) | ||
order.address.region = nil | ||
expect(order).not_to be_valid | ||
expect(order.validation_errors).to have(1).items | ||
end | ||
|
||
it 'should validate correct items' do | ||
order = build(:post_order) | ||
expect(order).to be_valid | ||
expect(order.validation_errors).to have(0).items | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
require_relative '../spec_helper' | ||
|
||
describe 'AxiomusApi' do | ||
|
||
it 'should assign logger' do | ||
AxiomusApi.logger = Logger.new($stdout) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters