qbwc_requests 0.0.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 +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/Gemfile +8 -0
- data/LICENSE +22 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/qbwc_requests/qbwc/ordered_fields.rb +35 -0
- data/lib/qbwc_requests/qbwc/qbwc.rb +2 -0
- data/lib/qbwc_requests/qbwc/request/base.rb +61 -0
- data/lib/qbwc_requests/qbwc/request/v07/account.rb +13 -0
- data/lib/qbwc_requests/qbwc/request/v07/customer.rb +29 -0
- data/lib/qbwc_requests/qbwc/request/v07/estimate.rb +14 -0
- data/lib/qbwc_requests/qbwc/request/v07/invoice.rb +15 -0
- data/lib/qbwc_requests/qbwc/request/v07/item.rb +11 -0
- data/lib/qbwc_requests/qbwc/request/v07/item_discount.rb +15 -0
- data/lib/qbwc_requests/qbwc/request/v07/item_group.rb +14 -0
- data/lib/qbwc_requests/qbwc/request/v07/item_non_inventory.rb +15 -0
- data/lib/qbwc_requests/qbwc/request/v07/item_other_charge.rb +16 -0
- data/lib/qbwc_requests/qbwc/request/v07/item_payment.rb +14 -0
- data/lib/qbwc_requests/qbwc/request/v07/item_service.rb +15 -0
- data/lib/qbwc_requests/qbwc/request/v07/item_subtotal.rb +15 -0
- data/lib/qbwc_requests/qbwc/request/v07/purchase_order.rb +12 -0
- data/lib/qbwc_requests/qbwc/request/v07/vendor.rb +25 -0
- data/lib/qbwc_requests/qbwc/xml_actions.rb +31 -0
- data/lib/qbwc_requests/version.rb +3 -0
- data/lib/qbwc_requests.rb +7 -0
- data/qbwc_requests.gemspec +23 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/AccountQueryRq.xml +31 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/BillQueryRq.xml +28 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/CheckQueryRq.xml +28 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/CompanyQueryRq.xml +28 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/EmployeeQueryRq.xml +28 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/EntityQueryRq.xml +29 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/HostQueryRq.xml +29 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/InvoiceQueryRq.xml +29 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/ItemInventoryQueryRq.xml +29 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/ItemSalesTaxQueryRq.xml +30 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/ItemServiceQueryRq.xml +30 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/PayrollItemWageQueryRq.xml +29 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/PreferencesQueryRq.xml +29 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/ReceivePaymentQueryRq.xml +32 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/SalesRepQueryRq.xml +29 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/AccountAddRq.xml +41 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/AccountQueryRq_1.xml +31 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/AccountQueryRq_2.xml +31 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/AccountQueryRq_3.xml +31 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/AccountQueryRq_4.xml +31 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/AccountQueryRq_5.xml +31 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/AccountQueryRq_6.xml +31 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/AccountQueryRq_7.xml +31 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/AddInvoiceSpecifyTemplate.xml +47 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/CustomDetailReport.xml +37 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/CustomFieldAddValue.xml +42 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/CustomFieldDelValue.xml +41 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/CustomFieldModValue.xml +42 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/CustomerAddRq.xml +71 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/CustomerQuery.xml +29 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/CustomerQuery_metadata.xml +30 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/DepositAddRq.xml +36 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/DisplayList.xml +38 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/DisplayTxn.xml +46 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/ErrRecovery1.xml +50 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/ErrRecovery2.xml +28 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/ErrRecovery3.xml +27 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/HostQuery.xml +27 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/ItemServiceAddRq.xml +39 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/ItemsAddRq.xml +80 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/JournalEntryAddRq.xml +55 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/ProfitAndLossStdReport.xml +35 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/QueryFilterRq.xml +46 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/ReceivePaymentAddRq.xml +49 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/ReceivePaymentToDepositQueryRq.xml +27 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/TemplateQuery.xml +37 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/TxnDisplayAdd_Invoice.xml +35 -0
- data/quickbook/xml/qbxml/examples/xmlfiles/legacy/VendorAddRq.xml +63 -0
- data/quickbook/xml/qbxmlops130.xml +35788 -0
- data/quickbook/xml/qbxmlops70.xml +29844 -0
- data/spec/qbwc/request/v07/account_spec.rb +32 -0
- data/spec/qbwc/request/v07/customer_spec.rb +32 -0
- data/spec/qbwc/request/v07/estimate_spec.rb +39 -0
- data/spec/qbwc/request/v07/invoice_spec.rb +39 -0
- data/spec/qbwc/request/v07/item_discount_spec.rb +32 -0
- data/spec/qbwc/request/v07/item_group_spec.rb +31 -0
- data/spec/qbwc/request/v07/item_non_inventory_spec.rb +31 -0
- data/spec/qbwc/request/v07/item_other_charge_spec.rb +39 -0
- data/spec/qbwc/request/v07/item_payment_spec.rb +29 -0
- data/spec/qbwc/request/v07/item_service_spec.rb +32 -0
- data/spec/qbwc/request/v07/item_spec.rb +7 -0
- data/spec/qbwc/request/v07/item_subtotal_spec.rb +52 -0
- data/spec/qbwc/request/v07/purchase_orders_spec.rb +36 -0
- data/spec/qbwc/request/v07/vendor_spec.rb +31 -0
- data/spec/spec_helper.rb +98 -0
- data/spec/support/expectations/field_validations.rb +13 -0
- data/spec/support/expectations/xml_equal.rb +15 -0
- data/spec/support/shared_examples_for_xml_requests.rb +24 -0
- metadata +186 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe Qbwc::Request::V07::Account do
|
|
4
|
+
|
|
5
|
+
it_behaves_like 'queryable'
|
|
6
|
+
|
|
7
|
+
it { is_expected.to validate_field_presence_of :name }
|
|
8
|
+
|
|
9
|
+
describe "add" do
|
|
10
|
+
|
|
11
|
+
let(:account){ Qbwc::Request::V07::Account.new(name: 'a') }
|
|
12
|
+
|
|
13
|
+
it "should create an add account xml" do
|
|
14
|
+
xml = <<-XML
|
|
15
|
+
<?xml version='1.0' encoding='utf-8'?>
|
|
16
|
+
<?qbxml version="7.0"?>
|
|
17
|
+
<QBXML>
|
|
18
|
+
<QBXMLMsgsRq onError="stopOnError">
|
|
19
|
+
<AccountAddRq requestID="2">
|
|
20
|
+
<AccountAdd>
|
|
21
|
+
<Name>a</Name>
|
|
22
|
+
</AccountAdd>
|
|
23
|
+
</AccountAddRq>
|
|
24
|
+
</QBXMLMsgsRq>
|
|
25
|
+
</QBXML>
|
|
26
|
+
XML
|
|
27
|
+
expect( account.add ).to be_xml_equal_to xml
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe Qbwc::Request::V07::Customer do
|
|
4
|
+
|
|
5
|
+
it_behaves_like 'queryable'
|
|
6
|
+
|
|
7
|
+
it { is_expected.to validate_field_presence_of :name }
|
|
8
|
+
|
|
9
|
+
describe "add" do
|
|
10
|
+
|
|
11
|
+
let(:customer){ Qbwc::Request::V07::Customer.new(name: 'a') }
|
|
12
|
+
|
|
13
|
+
it "should create an add customer xml" do
|
|
14
|
+
xml = <<-XML
|
|
15
|
+
<?xml version='1.0' encoding='utf-8'?>
|
|
16
|
+
<?qbxml version="7.0"?>
|
|
17
|
+
<QBXML>
|
|
18
|
+
<QBXMLMsgsRq onError="stopOnError">
|
|
19
|
+
<CustomerAddRq requestID="2">
|
|
20
|
+
<CustomerAdd>
|
|
21
|
+
<Name>a</Name>
|
|
22
|
+
</CustomerAdd>
|
|
23
|
+
</CustomerAddRq>
|
|
24
|
+
</QBXMLMsgsRq>
|
|
25
|
+
</QBXML>
|
|
26
|
+
XML
|
|
27
|
+
expect( customer.add ).to be_xml_equal_to xml
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe Qbwc::Request::V07::Estimate do
|
|
4
|
+
|
|
5
|
+
it_behaves_like 'queryable'
|
|
6
|
+
|
|
7
|
+
it{ is_expected.to validate_field_presence_of :customer_ref }
|
|
8
|
+
it{ is_expected.to validate_field_presence_of :estimate_line_add }
|
|
9
|
+
|
|
10
|
+
describe "add" do
|
|
11
|
+
|
|
12
|
+
let(:estimate){ Qbwc::Request::V07::Estimate.new(customer_ref: {full_name: 'Some customer name'}, estimate_line_add: {item_ref: {full_name: 'Some intem name'}}) }
|
|
13
|
+
|
|
14
|
+
it "should create an add estimate xml" do
|
|
15
|
+
xml = <<-XML
|
|
16
|
+
<?xml version='1.0' encoding='utf-8'?>
|
|
17
|
+
<?qbxml version="7.0"?>
|
|
18
|
+
<QBXML>
|
|
19
|
+
<QBXMLMsgsRq onError="stopOnError">
|
|
20
|
+
<EstimateAddRq requestID="2">
|
|
21
|
+
<EstimateAdd>
|
|
22
|
+
<CustomerRef>
|
|
23
|
+
<FullName>Some customer name</FullName>
|
|
24
|
+
</CustomerRef>
|
|
25
|
+
<EstimateLineAdd>
|
|
26
|
+
<ItemRef>
|
|
27
|
+
<FullName>Some intem name</FullName>
|
|
28
|
+
</ItemRef>
|
|
29
|
+
</EstimateLineAdd>
|
|
30
|
+
</EstimateAdd>
|
|
31
|
+
</EstimateAddRq>
|
|
32
|
+
</QBXMLMsgsRq>
|
|
33
|
+
</QBXML>
|
|
34
|
+
XML
|
|
35
|
+
expect( estimate.add ).to be_xml_equal_to xml
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe Qbwc::Request::V07::Invoice do
|
|
4
|
+
|
|
5
|
+
it_behaves_like 'queryable'
|
|
6
|
+
|
|
7
|
+
it{ is_expected.to validate_field_presence_of :customer_ref }
|
|
8
|
+
it{ is_expected.to validate_field_presence_of :invoice_line_add }
|
|
9
|
+
|
|
10
|
+
describe "add" do
|
|
11
|
+
|
|
12
|
+
let(:invoice){ Qbwc::Request::V07::Invoice.new(customer_ref: {full_name: 'Some customer name'}, invoice_line_add: {item_ref: {full_name: 'Some item name'}}) }
|
|
13
|
+
|
|
14
|
+
it "should create an add invoice xml" do
|
|
15
|
+
xml = <<-XML
|
|
16
|
+
<?xml version='1.0' encoding='utf-8'?>
|
|
17
|
+
<?qbxml version="7.0"?>
|
|
18
|
+
<QBXML>
|
|
19
|
+
<QBXMLMsgsRq onError="stopOnError">
|
|
20
|
+
<InvoiceAddRq requestID="2">
|
|
21
|
+
<InvoiceAdd>
|
|
22
|
+
<CustomerRef>
|
|
23
|
+
<FullName>Some customer name</FullName>
|
|
24
|
+
</CustomerRef>
|
|
25
|
+
<InvoiceLineAdd>
|
|
26
|
+
<ItemRef>
|
|
27
|
+
<FullName>Some item name</FullName>
|
|
28
|
+
</ItemRef>
|
|
29
|
+
</InvoiceLineAdd>
|
|
30
|
+
</InvoiceAdd>
|
|
31
|
+
</InvoiceAddRq>
|
|
32
|
+
</QBXMLMsgsRq>
|
|
33
|
+
</QBXML>
|
|
34
|
+
XML
|
|
35
|
+
expect( invoice.add ).to be_xml_equal_to xml
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Qbwc::Request::V07::ItemDiscount do
|
|
4
|
+
|
|
5
|
+
it_behaves_like 'queryable'
|
|
6
|
+
|
|
7
|
+
it{ is_expected.to validate_field_presence_of :name }
|
|
8
|
+
|
|
9
|
+
describe "add" do
|
|
10
|
+
|
|
11
|
+
let(:item_discount) { Qbwc::Request::V07::ItemDiscount.new(name: 'discount item name') }
|
|
12
|
+
|
|
13
|
+
it "should create an add Discount Item xml" do
|
|
14
|
+
xml = <<-XML
|
|
15
|
+
<?xml version='1.0' encoding='utf-8'?>
|
|
16
|
+
<?qbxml version=\"7.0\"?>
|
|
17
|
+
<QBXML>
|
|
18
|
+
<QBXMLMsgsRq onError=\"stopOnError\">
|
|
19
|
+
<ItemDiscountAddRq requestID=\"2\">
|
|
20
|
+
<ItemDiscountAdd>
|
|
21
|
+
<Name>discount item name</Name>
|
|
22
|
+
</ItemDiscountAdd>
|
|
23
|
+
</ItemDiscountAddRq>
|
|
24
|
+
</QBXMLMsgsRq>
|
|
25
|
+
</QBXML>
|
|
26
|
+
XML
|
|
27
|
+
expect( item_discount.add ).to be_xml_equal_to xml
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Qbwc::Request::V07::ItemGroup do
|
|
4
|
+
|
|
5
|
+
it_behaves_like 'queryable'
|
|
6
|
+
|
|
7
|
+
it{ is_expected.to validate_field_presence_of :name }
|
|
8
|
+
|
|
9
|
+
describe "add" do
|
|
10
|
+
|
|
11
|
+
it "should create an add Item Group xml" do
|
|
12
|
+
item = Qbwc::Request::V07::ItemGroup.new(name: 'Group item name')
|
|
13
|
+
xml = <<-XML
|
|
14
|
+
<?xml version='1.0' encoding='utf-8'?>
|
|
15
|
+
<?qbxml version="7.0"?>
|
|
16
|
+
<QBXML>
|
|
17
|
+
<QBXMLMsgsRq onError="stopOnError">
|
|
18
|
+
<ItemGroupAddRq requestID="2">
|
|
19
|
+
<ItemGroupAdd>
|
|
20
|
+
<Name>Group item name</Name>
|
|
21
|
+
</ItemGroupAdd>
|
|
22
|
+
</ItemGroupAddRq>
|
|
23
|
+
</QBXMLMsgsRq>
|
|
24
|
+
</QBXML>
|
|
25
|
+
XML
|
|
26
|
+
expect( item.add ).to be_xml_equal_to xml
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Qbwc::Request::V07::ItemNonInventory do
|
|
4
|
+
|
|
5
|
+
it_behaves_like 'queryable'
|
|
6
|
+
|
|
7
|
+
it{ is_expected.to validate_field_presence_of :name }
|
|
8
|
+
|
|
9
|
+
describe "add" do
|
|
10
|
+
|
|
11
|
+
it "should create an add Item Non Invetory xml" do
|
|
12
|
+
item = Qbwc::Request::V07::ItemNonInventory.new(name: 'NonInventory item name')
|
|
13
|
+
xml = <<-XML
|
|
14
|
+
<?xml version='1.0' encoding='utf-8'?>
|
|
15
|
+
<?qbxml version="7.0"?>
|
|
16
|
+
<QBXML>
|
|
17
|
+
<QBXMLMsgsRq onError="stopOnError">
|
|
18
|
+
<ItemNonInventoryAddRq requestID="2">
|
|
19
|
+
<ItemNonInventoryAdd>
|
|
20
|
+
<Name>NonInventory item name</Name>
|
|
21
|
+
</ItemNonInventoryAdd>
|
|
22
|
+
</ItemNonInventoryAddRq>
|
|
23
|
+
</QBXMLMsgsRq>
|
|
24
|
+
</QBXML>
|
|
25
|
+
XML
|
|
26
|
+
expect( item.add ).to be_xml_equal_to xml
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Qbwc::Request::V07::ItemOtherCharge do
|
|
4
|
+
|
|
5
|
+
it_behaves_like 'queryable'
|
|
6
|
+
|
|
7
|
+
it{ is_expected.to validate_field_presence_of :name }
|
|
8
|
+
it{ is_expected.to validate_field_presence_of :sales_or_purchase }
|
|
9
|
+
|
|
10
|
+
describe "add" do
|
|
11
|
+
|
|
12
|
+
let(:item){ Qbwc::Request::V07::ItemOtherCharge.new(name: 'OtherCharge item name', sales_or_purchase: {price: "10.00", account_ref: {full_name: 'Some Account Name'}} ) }
|
|
13
|
+
|
|
14
|
+
it "should create an add Item Other Charge xml" do
|
|
15
|
+
xml = <<-XML
|
|
16
|
+
<?xml version='1.0' encoding='utf-8'?>
|
|
17
|
+
<?qbxml version=\"7.0\"?>
|
|
18
|
+
<QBXML>
|
|
19
|
+
<QBXMLMsgsRq onError=\"stopOnError\">
|
|
20
|
+
<ItemOtherChargeAddRq requestID=\"2\">
|
|
21
|
+
<ItemOtherChargeAdd>
|
|
22
|
+
<Name>OtherCharge item name</Name>
|
|
23
|
+
<SalesOrPurchase>
|
|
24
|
+
<Price>10.00</Price>
|
|
25
|
+
<AccountRef>
|
|
26
|
+
<FullName>Some Account Name</FullName>
|
|
27
|
+
</AccountRef>
|
|
28
|
+
</SalesOrPurchase>
|
|
29
|
+
</ItemOtherChargeAdd>
|
|
30
|
+
</ItemOtherChargeAddRq>
|
|
31
|
+
</QBXMLMsgsRq>
|
|
32
|
+
</QBXML>
|
|
33
|
+
XML
|
|
34
|
+
expect( item.add ).to be_xml_equal_to xml
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Qbwc::Request::V07::ItemPayment do
|
|
4
|
+
|
|
5
|
+
it_behaves_like 'queryable'
|
|
6
|
+
|
|
7
|
+
it { is_expected.to validate_field_presence_of :name }
|
|
8
|
+
|
|
9
|
+
describe "add" do
|
|
10
|
+
it "should create an add Item Payment xml" do
|
|
11
|
+
item = Qbwc::Request::V07::ItemPayment.new(name: 'Payment item name')
|
|
12
|
+
xml = <<-XML
|
|
13
|
+
<?xml version='1.0' encoding='utf-8'?>
|
|
14
|
+
<?qbxml version=\"7.0\"?>
|
|
15
|
+
<QBXML>
|
|
16
|
+
<QBXMLMsgsRq onError=\"stopOnError\">
|
|
17
|
+
<ItemPaymentAddRq requestID=\"2\">
|
|
18
|
+
<ItemPaymentAdd>
|
|
19
|
+
<Name>Payment item name</Name>
|
|
20
|
+
</ItemPaymentAdd>
|
|
21
|
+
</ItemPaymentAddRq>
|
|
22
|
+
</QBXMLMsgsRq>
|
|
23
|
+
</QBXML>
|
|
24
|
+
XML
|
|
25
|
+
expect( item.add ).to be_xml_equal_to xml
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Qbwc::Request::V07::ItemService do
|
|
4
|
+
|
|
5
|
+
it_behaves_like 'queryable'
|
|
6
|
+
|
|
7
|
+
it { is_expected.to validate_field_presence_of :name }
|
|
8
|
+
|
|
9
|
+
describe "add" do
|
|
10
|
+
|
|
11
|
+
let(:item) {Qbwc::Request::V07::ItemService.new(name: 'Service item name')}
|
|
12
|
+
|
|
13
|
+
it "should create an add Item Service xml" do
|
|
14
|
+
xml = <<-XML
|
|
15
|
+
<?xml version='1.0' encoding='utf-8'?>
|
|
16
|
+
<?qbxml version="7.0"?>
|
|
17
|
+
<QBXML>
|
|
18
|
+
<QBXMLMsgsRq onError="stopOnError">
|
|
19
|
+
<ItemServiceAddRq requestID="2">
|
|
20
|
+
<ItemServiceAdd>
|
|
21
|
+
<Name>Service item name</Name>
|
|
22
|
+
</ItemServiceAdd>
|
|
23
|
+
</ItemServiceAddRq>
|
|
24
|
+
</QBXMLMsgsRq>
|
|
25
|
+
</QBXML>
|
|
26
|
+
XML
|
|
27
|
+
expect( item.add ).to be_xml_equal_to xml
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Qbwc::Request::V07::ItemSubtotal do
|
|
4
|
+
|
|
5
|
+
it_behaves_like 'queryable'
|
|
6
|
+
|
|
7
|
+
it { is_expected.to validate_field_presence_of :name }
|
|
8
|
+
|
|
9
|
+
describe "add" do
|
|
10
|
+
|
|
11
|
+
let(:item) { Qbwc::Request::V07::ItemSubtotal.new(name: 'Subtotal item name') }
|
|
12
|
+
let(:item_with_bar_code) { Qbwc::Request::V07::ItemSubtotal.new(name: 'Subtotal item name', bar_code: { bar_code_value: 'some bar code value' } ) }
|
|
13
|
+
|
|
14
|
+
it "should create an add Item Subtotal xml" do
|
|
15
|
+
xml = <<-XML
|
|
16
|
+
<?xml version='1.0' encoding='utf-8'?>
|
|
17
|
+
<?qbxml version="7.0"?>
|
|
18
|
+
<QBXML>
|
|
19
|
+
<QBXMLMsgsRq onError="stopOnError">
|
|
20
|
+
<ItemSubtotalAddRq requestID="2">
|
|
21
|
+
<ItemSubtotalAdd>
|
|
22
|
+
<Name>Subtotal item name</Name>
|
|
23
|
+
</ItemSubtotalAdd>
|
|
24
|
+
</ItemSubtotalAddRq>
|
|
25
|
+
</QBXMLMsgsRq>
|
|
26
|
+
</QBXML>
|
|
27
|
+
XML
|
|
28
|
+
expect( item.add ).to be_xml_equal_to xml
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "should create an add Item Subtotal with the bar_code" do
|
|
32
|
+
xml = <<-XML
|
|
33
|
+
<?xml version='1.0' encoding='utf-8'?>
|
|
34
|
+
<?qbxml version="7.0"?>
|
|
35
|
+
<QBXML>
|
|
36
|
+
<QBXMLMsgsRq onError="stopOnError">
|
|
37
|
+
<ItemSubtotalAddRq requestID="2">
|
|
38
|
+
<ItemSubtotalAdd>
|
|
39
|
+
<Name>Subtotal item name</Name>
|
|
40
|
+
<BarCode>
|
|
41
|
+
<BarCodeValue>some bar code value</BarCodeValue>
|
|
42
|
+
</BarCode>
|
|
43
|
+
</ItemSubtotalAdd>
|
|
44
|
+
</ItemSubtotalAddRq>
|
|
45
|
+
</QBXMLMsgsRq>
|
|
46
|
+
</QBXML>
|
|
47
|
+
XML
|
|
48
|
+
expect( item_with_bar_code.add ).to be_xml_equal_to xml
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe Qbwc::Request::V07::PurchaseOrder do
|
|
4
|
+
|
|
5
|
+
it_behaves_like 'queryable'
|
|
6
|
+
|
|
7
|
+
describe "add" do
|
|
8
|
+
|
|
9
|
+
let(:purchase_order){ Qbwc::Request::V07::PurchaseOrder.new(vendor_ref: {full_name: "Vendor full name"}, purchase_order_line_add: {item_ref: {full_name: 'Some item ref full name'}}) }
|
|
10
|
+
|
|
11
|
+
it "should create an add purchase order xml" do
|
|
12
|
+
xml = <<-XML
|
|
13
|
+
<?xml version='1.0' encoding='utf-8'?>
|
|
14
|
+
<?qbxml version="7.0"?>
|
|
15
|
+
<QBXML>
|
|
16
|
+
<QBXMLMsgsRq onError="stopOnError">
|
|
17
|
+
<PurchaseOrderAddRq requestID="2">
|
|
18
|
+
<PurchaseOrderAdd>
|
|
19
|
+
<VendorRef>
|
|
20
|
+
<FullName>Vendor full name</FullName>
|
|
21
|
+
</VendorRef>
|
|
22
|
+
<PurchaseOrderLineAdd>
|
|
23
|
+
<ItemRef>
|
|
24
|
+
<FullName>Some item ref full name</FullName>
|
|
25
|
+
</ItemRef>
|
|
26
|
+
</PurchaseOrderLineAdd>
|
|
27
|
+
</PurchaseOrderAdd>
|
|
28
|
+
</PurchaseOrderAddRq>
|
|
29
|
+
</QBXMLMsgsRq>
|
|
30
|
+
</QBXML>
|
|
31
|
+
XML
|
|
32
|
+
expect( purchase_order.add ).to be_xml_equal_to xml
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
RSpec.describe Qbwc::Request::V07::Vendor do
|
|
4
|
+
|
|
5
|
+
it_behaves_like 'queryable'
|
|
6
|
+
|
|
7
|
+
it { is_expected.to validate_field_presence_of :name }
|
|
8
|
+
|
|
9
|
+
describe "add" do
|
|
10
|
+
|
|
11
|
+
let(:vendor){ Qbwc::Request::V07::Vendor.new(name: 'a') }
|
|
12
|
+
|
|
13
|
+
it "should create an add vendor xml" do
|
|
14
|
+
xml = <<-XML
|
|
15
|
+
<?xml version='1.0' encoding='utf-8'?>
|
|
16
|
+
<?qbxml version="7.0"?>
|
|
17
|
+
<QBXML>
|
|
18
|
+
<QBXMLMsgsRq onError="stopOnError">
|
|
19
|
+
<VendorAddRq requestID="2">
|
|
20
|
+
<VendorAdd>
|
|
21
|
+
<Name>a</Name>
|
|
22
|
+
</VendorAdd>
|
|
23
|
+
</VendorAddRq>
|
|
24
|
+
</QBXMLMsgsRq>
|
|
25
|
+
</QBXML>
|
|
26
|
+
XML
|
|
27
|
+
expect( vendor.add ).to be_xml_equal_to xml
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
require 'i18n'
|
|
4
|
+
|
|
5
|
+
I18n.config.enforce_available_locales = true
|
|
6
|
+
Bundler.require :default
|
|
7
|
+
|
|
8
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
|
9
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
|
10
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
|
11
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
|
12
|
+
#
|
|
13
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
|
14
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
|
15
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
|
16
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
|
17
|
+
# a separate helper file that requires the additional dependencies and performs
|
|
18
|
+
# the additional setup, and require it from the spec files that actually need it.
|
|
19
|
+
#
|
|
20
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
|
21
|
+
# users commonly want.
|
|
22
|
+
#
|
|
23
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
|
24
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
|
25
|
+
|
|
26
|
+
RSpec.configure do |config|
|
|
27
|
+
# rspec-expectations config goes here. You can use an alternate
|
|
28
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
|
29
|
+
# assertions if you prefer.
|
|
30
|
+
config.expect_with :rspec do |expectations|
|
|
31
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
|
32
|
+
# and `failure_message` of custom matchers include text for helper methods
|
|
33
|
+
# defined using `chain`, e.g.:
|
|
34
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
|
35
|
+
# # => "be bigger than 2 and smaller than 4"
|
|
36
|
+
# ...rather than:
|
|
37
|
+
# # => "be bigger than 2"
|
|
38
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
|
42
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
|
43
|
+
config.mock_with :rspec do |mocks|
|
|
44
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
|
45
|
+
# a real object. This is generally recommended, and will default to
|
|
46
|
+
# `true` in RSpec 4.
|
|
47
|
+
mocks.verify_partial_doubles = true
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# The settings below are suggested to provide a good initial experience
|
|
51
|
+
# with RSpec, but feel free to customize to your heart's content.
|
|
52
|
+
=begin
|
|
53
|
+
# These two settings work together to allow you to limit a spec run
|
|
54
|
+
# to individual examples or groups you care about by tagging them with
|
|
55
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
|
56
|
+
# get run.
|
|
57
|
+
config.filter_run :focus
|
|
58
|
+
config.run_all_when_everything_filtered = true
|
|
59
|
+
|
|
60
|
+
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
|
61
|
+
# For more details, see:
|
|
62
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
|
63
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
|
64
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
|
65
|
+
config.disable_monkey_patching!
|
|
66
|
+
|
|
67
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
|
68
|
+
# be too noisy due to issues in dependencies.
|
|
69
|
+
config.warnings = true
|
|
70
|
+
|
|
71
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
|
72
|
+
# file, and it's useful to allow more verbose output when running an
|
|
73
|
+
# individual spec file.
|
|
74
|
+
if config.files_to_run.one?
|
|
75
|
+
# Use the documentation formatter for detailed output,
|
|
76
|
+
# unless a formatter has already been configured
|
|
77
|
+
# (e.g. via a command-line flag).
|
|
78
|
+
config.default_formatter = 'doc'
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Print the 10 slowest examples and example groups at the
|
|
82
|
+
# end of the spec run, to help surface which specs are running
|
|
83
|
+
# particularly slow.
|
|
84
|
+
config.profile_examples = 10
|
|
85
|
+
|
|
86
|
+
# Run specs in random order to surface order dependencies. If you find an
|
|
87
|
+
# order dependency and want to debug it, you can fix the order by providing
|
|
88
|
+
# the seed, which is printed after each run.
|
|
89
|
+
# --seed 1234
|
|
90
|
+
config.order = :random
|
|
91
|
+
|
|
92
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
|
93
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
|
94
|
+
# test failures related to randomization by passing the same `--seed` value
|
|
95
|
+
# as the one that triggered the failure.
|
|
96
|
+
Kernel.srand config.seed
|
|
97
|
+
=end
|
|
98
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
RSpec::Matchers.define :validate_field_presence_of do |expected|
|
|
2
|
+
|
|
3
|
+
match do |actual|
|
|
4
|
+
object = described_class.new()
|
|
5
|
+
object.valid?
|
|
6
|
+
object.errors.include? expected
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
failure_message do |actual|
|
|
10
|
+
"Expected model to include validation errors for #{expected}"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
RSpec::Matchers.define :be_xml_equal_to do |expected|
|
|
2
|
+
|
|
3
|
+
def clean xml
|
|
4
|
+
xml.gsub(/>\s+</,"><").strip
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
match do |actual|
|
|
8
|
+
clean(actual) == clean(expected)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
failure_message do |actual|
|
|
12
|
+
"expected that: \n#{clean(actual)} to be the same xml as \n#{clean(expected)}"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
RSpec.shared_examples 'queryable' do
|
|
2
|
+
|
|
3
|
+
describe 'query method' do
|
|
4
|
+
|
|
5
|
+
let(:xml) do
|
|
6
|
+
<<-XML
|
|
7
|
+
<?xml version='1.0' encoding='utf-8'?><?qbxml version="7.0"?>
|
|
8
|
+
<QBXML>
|
|
9
|
+
<QBXMLMsgsRq onError="stopOnError">
|
|
10
|
+
<#{described_class.name.demodulize}QueryRq>
|
|
11
|
+
<MaxReturned>2000</MaxReturned>
|
|
12
|
+
</#{described_class.name.demodulize}QueryRq>
|
|
13
|
+
</QBXMLMsgsRq>
|
|
14
|
+
</QBXML>
|
|
15
|
+
XML
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'should create a query xml' do
|
|
19
|
+
expect(described_class.query_all).to be_xml_equal_to xml
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|