fishbowl 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. data/.travis.yml +9 -4
  2. data/Gemfile +10 -1
  3. data/Guardfile +13 -0
  4. data/lib/fishbowl.rb +13 -15
  5. data/lib/fishbowl/ext.rb +15 -0
  6. data/lib/fishbowl/objects.rb +5 -0
  7. data/lib/fishbowl/objects/account.rb +24 -2
  8. data/lib/fishbowl/objects/address.rb +86 -0
  9. data/lib/fishbowl/objects/base_object.rb +34 -5
  10. data/lib/fishbowl/objects/carrier.rb +15 -0
  11. data/lib/fishbowl/objects/carton.rb +54 -0
  12. data/lib/fishbowl/objects/uom.rb +47 -0
  13. data/lib/fishbowl/objects/user.rb +15 -0
  14. data/lib/fishbowl/requests.rb +6 -0
  15. data/lib/fishbowl/requests/add_inventory.rb +34 -0
  16. data/lib/fishbowl/requests/add_sales_order_item.rb +42 -0
  17. data/lib/fishbowl/requests/adjust_inventory.rb +28 -0
  18. data/lib/fishbowl/requests/get_carrier_list.rb +12 -0
  19. data/lib/fishbowl/version.rb +1 -1
  20. data/spec/examples/account.xml +6 -0
  21. data/spec/examples/address.xml +30 -0
  22. data/spec/examples/carrier.xml +3 -0
  23. data/spec/examples/carton.xml +93 -0
  24. data/spec/examples/contact_information.xml +5 -0
  25. data/spec/examples/contacts.xml +7 -0
  26. data/spec/examples/credit_card.xml +10 -0
  27. data/spec/examples/customer.xml +54 -0
  28. data/spec/examples/location.xml +14 -0
  29. data/spec/examples/location_group.xml +5 -0
  30. data/spec/examples/location_group_string.xml +1 -0
  31. data/spec/examples/order_history.xml +8 -0
  32. data/spec/examples/part.xml +105 -0
  33. data/spec/examples/payment.xml +6 -0
  34. data/spec/examples/pick.xml +265 -0
  35. data/spec/examples/pick_item.xml +236 -0
  36. data/spec/examples/product.xml +159 -0
  37. data/spec/examples/purchase_order.xml +53 -0
  38. data/spec/examples/receipt.xml +146 -0
  39. data/spec/examples/report.xml +10 -0
  40. data/spec/examples/report_tree.xml +7 -0
  41. data/spec/examples/sales_order.xml +47 -0
  42. data/spec/examples/sales_order_item.xml +32 -0
  43. data/spec/examples/shipping.xml +127 -0
  44. data/spec/examples/tag.xml +28 -0
  45. data/spec/examples/tax_rate.xml +10 -0
  46. data/spec/examples/tracking.xml +14 -0
  47. data/spec/examples/tracking_item.xml +12 -0
  48. data/spec/examples/transfer_order.xml +257 -0
  49. data/spec/examples/transfer_order_item.xml +147 -0
  50. data/spec/examples/uom.xml +26 -0
  51. data/spec/examples/uom_conversion.xml +8 -0
  52. data/spec/examples/user.xml +8 -0
  53. data/spec/examples/vendor.xml +19 -0
  54. data/spec/examples/vendor_part_number.xml +3 -0
  55. data/spec/examples/work_order.xml +228 -0
  56. data/spec/examples/work_order_item.xml +172 -0
  57. data/spec/objects/account_spec.rb +53 -6
  58. data/spec/objects/address_information_spec.rb +18 -0
  59. data/spec/objects/address_spec.rb +36 -0
  60. data/spec/objects/base_object_spec.rb +67 -23
  61. data/spec/objects/carrier_spec.rb +15 -0
  62. data/spec/objects/carton_spec.rb +23 -0
  63. data/spec/objects/country_spec.rb +16 -0
  64. data/spec/objects/shipping_item_spec.rb +21 -0
  65. data/spec/objects/state_spec.rb +17 -0
  66. data/spec/objects/uom_conversion_spec.rb +20 -0
  67. data/spec/objects/uom_spec.rb +20 -0
  68. data/spec/objects/user_spec.rb +20 -0
  69. data/spec/requests/add_inventory_spec.rb +79 -0
  70. data/spec/requests/add_sales_order_item_spec.rb +85 -0
  71. data/spec/requests/adjust_inventory_spec.rb +62 -0
  72. data/spec/requests/get_carrier_list_spec.rb +54 -0
  73. data/spec/spec_helper.rb +41 -11
  74. data/spec/support/examples_loader.rb +5 -0
  75. data/spec/support/response_mocks.rb +27 -0
  76. metadata +122 -6
  77. data/spec/support/fake_login.rb +0 -15
@@ -0,0 +1,85 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fishbowl::Requests do
4
+ describe "#add_sales_order_item" do
5
+ before :each do
6
+ mock_tcp_connection
7
+ mock_login_response
8
+ Fishbowl::Connection.connect(host: 'localhost')
9
+ Fishbowl::Connection.login(username: 'johndoe', password: 'secret')
10
+ end
11
+
12
+ let(:connection) { FakeTCPSocket.instance }
13
+
14
+ let(:valid_options) {
15
+ {
16
+ order_number: 1,
17
+ id: -1,
18
+ product_number: 'BTY100-Core',
19
+ sales_order_id: 94,
20
+ description: 'Battery Pack',
21
+ taxable: true,
22
+ quantity: 1,
23
+ product_price: 95.00,
24
+ total_price: 95.00,
25
+ uom_code: 'ea',
26
+ item_type: 20,
27
+ status: 10,
28
+ quickbooks_class_name: 'Salt Lake City',
29
+ new_item_flag: false
30
+ }
31
+ }
32
+
33
+ it "requires valid options" do
34
+ lambda {
35
+ Fishbowl::Requests.add_sales_order_item(valid_options)
36
+ }.should_not raise_error(ArgumentError)
37
+
38
+ valid_options.each do |excluded_key, excluded_value|
39
+ invalid_options = valid_options.keep_if {|k,v| k != excluded_key}
40
+
41
+ lambda {
42
+ Fishbowl::Requests.add_sales_order_item(invalid_options)
43
+ }.should raise_error(ArgumentError)
44
+ end
45
+ end
46
+
47
+ it "sends proper request" do
48
+ mock_the_response('AddSOItemRs')
49
+ Fishbowl::Requests.add_sales_order_item(valid_options)
50
+ connection.last_write.should be_equivalent_to(expected_request)
51
+ end
52
+
53
+ def expected_request(options = {})
54
+ options = valid_options.merge(options)
55
+
56
+ request = Nokogiri::XML::Builder.new do |xml|
57
+ xml.FbiXml {
58
+ xml.Ticket
59
+ xml.FbiMsgsRq {
60
+ xml.AddSOItemRq {
61
+ xml.OrderNum options[:order_number]
62
+ xml.SalesOrderItem {
63
+ xml.ID options[:id]
64
+ xml.ProductNumber options[:product_number]
65
+ xml.SOID options[:sales_order_id]
66
+ xml.Description options[:description]
67
+ xml.Taxable options[:taxable]
68
+ xml.Quantity options[:quantity]
69
+ xml.ProductPrice options[:product_price]
70
+ xml.TotalPrice options[:total_price]
71
+ xml.UOMCode options[:uom_code]
72
+ xml.ItemType options[:item_type]
73
+ xml.Status options[:status]
74
+ xml.QuickBooksClassName options[:quickbooks_class_name]
75
+ xml.NewItemFlag options[:new_item_flag]
76
+ }
77
+ }
78
+ }
79
+ }
80
+ end
81
+
82
+ request.to_xml
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fishbowl::Requests do
4
+ describe "#adjust_inventory" do
5
+ before :each do
6
+ mock_tcp_connection
7
+ mock_login_response
8
+ Fishbowl::Connection.connect(host: 'localhost')
9
+ Fishbowl::Connection.login(username: 'johndoe', password: 'secret')
10
+ end
11
+
12
+ let(:connection) { FakeTCPSocket.instance }
13
+
14
+ let(:valid_options) {
15
+ {
16
+ tag_number: 1,
17
+ quantity: 5
18
+ }
19
+ }
20
+
21
+ it "requires valid options" do
22
+ lambda {
23
+ Fishbowl::Requests.adjust_inventory(valid_options)
24
+ }.should_not raise_error(ArgumentError)
25
+
26
+ valid_options.each do |excluded_key, excluded_value|
27
+ invalid_options = valid_options.keep_if {|k,v| k != excluded_key}
28
+
29
+ lambda {
30
+ Fishbowl::Requests.adjust_inventory(invalid_options)
31
+ }.should raise_error(ArgumentError)
32
+ end
33
+ end
34
+
35
+ it "sends proper request" do
36
+ mock_the_response('AdjustInventoryRs')
37
+ Fishbowl::Requests.adjust_inventory(valid_options)
38
+ connection.last_write.should be_equivalent_to(expected_request)
39
+ end
40
+
41
+ it "includes tracking when provided"
42
+
43
+ def expected_request(options = {})
44
+ options = valid_options.merge(options)
45
+
46
+ request = Nokogiri::XML::Builder.new do |xml|
47
+ xml.FbiXml {
48
+ xml.Ticket
49
+ xml.FbiMsgsRq {
50
+ xml.AdjustInventoryRq {
51
+ xml.TagNum valid_options[:tag_number]
52
+ xml.Quantity valid_options[:quantity]
53
+ xml.Tracking options[:tracking] unless options[:tracking].nil?
54
+ }
55
+ }
56
+ }
57
+ end
58
+
59
+ request.to_xml
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,54 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fishbowl::Requests do
4
+ describe "#get_carrier_list" do
5
+ before :each do
6
+ mock_tcp_connection
7
+ mock_login_response
8
+ Fishbowl::Connection.connect(host: 'localhost')
9
+ Fishbowl::Connection.login(username: 'johndoe', password: 'secret')
10
+ end
11
+
12
+ let(:connection) { FakeTCPSocket.instance }
13
+
14
+ it "sends proper request" do
15
+ mock_the_response(expected_response)
16
+ Fishbowl::Requests.get_carrier_list
17
+ connection.last_write.should be_equivalent_to(expected_request)
18
+ end
19
+
20
+ it "returns array of carriers" do
21
+ mock_the_response(expected_response)
22
+ response = Fishbowl::Requests.get_carrier_list
23
+
24
+ response.should be_an(Array)
25
+ response.first.should be_a(Fishbowl::Objects::Carrier)
26
+ end
27
+
28
+ def expected_request
29
+ request = Nokogiri::XML::Builder.new do |xml|
30
+ xml.FbiXml {
31
+ xml.Ticket
32
+ xml.FbiMsgsRq {
33
+ xml.CarrierListRq
34
+ }
35
+ }
36
+ end
37
+
38
+ request.to_xml
39
+ end
40
+
41
+ def expected_response
42
+ Nokogiri::XML::Builder.new do |xml|
43
+ xml.response {
44
+ xml.CarrierListRs(statusCode: '1000', statusMessage: "Success!") {
45
+ xml.Carrier { xml.Name "Will Call" }
46
+ xml.Carrier { xml.Name "UPS" }
47
+ xml.Carrier { xml.Name "FedEx" }
48
+ xml.Carrier { xml.Name "USPS" }
49
+ }
50
+ }
51
+ end
52
+ end
53
+ end
54
+ end
@@ -1,18 +1,48 @@
1
1
  require 'rubygems'
2
- require 'bundler/setup'
2
+ require 'rspec'
3
3
 
4
- require 'simplecov'
5
- SimpleCov.start do
6
- add_filter "/spec/"
7
- end
4
+ if ENV['CI'] != 'true'
5
+ require 'spork'
6
+
7
+ Spork.prefork do
8
+ unless ENV['DRB']
9
+ require 'simplecov'
10
+ SimpleCov.start do
11
+ add_filter "/spec/"
12
+ end
13
+ end
14
+
15
+ require 'fishbowl'
16
+
17
+ require 'equivalent-xml/rspec_matchers'
18
+
19
+ require 'support/examples_loader'
20
+ require 'support/fake_socket'
21
+ require 'support/response_mocks'
22
+
23
+ RSpec.configure do |config|
24
+ # some (optional) config here
25
+ end
26
+ end
8
27
 
9
- require 'equivalent-xml/rspec_matchers'
28
+ Spork.each_run do
29
+ if ENV['DRB']
30
+ require 'simplecov'
31
+ SimpleCov.start do
32
+ add_filter "/spec/"
33
+ end
34
+ end
35
+ end
36
+ else
37
+ require 'fishbowl'
10
38
 
11
- require 'fishbowl'
39
+ require 'equivalent-xml/rspec_matchers'
12
40
 
13
- require 'support/fake_socket'
14
- require 'support/fake_login'
41
+ require 'support/examples_loader'
42
+ require 'support/fake_socket'
43
+ require 'support/response_mocks'
15
44
 
16
- RSpec.configure do |config|
17
- # some (optional) config here
45
+ RSpec.configure do |config|
46
+ # some (optional) config here
47
+ end
18
48
  end
@@ -0,0 +1,5 @@
1
+ def example_file(filename)
2
+ example_path = File.expand_path('../../examples', __FILE__)
3
+ example_file = File.join(example_path, filename)
4
+ File.open(example_file)
5
+ end
@@ -0,0 +1,27 @@
1
+ require 'support/fake_socket'
2
+
3
+ def mock_response(response = 'SampleRs')
4
+ Nokogiri::XML::Builder.new do |xml|
5
+ xml.FbiXml {
6
+ xml.Ticket
7
+
8
+ xml.FbiMsgsRs(statusCode: '1000', statusMessage: "Success!") {
9
+ if response.respond_to?(:to_xml)
10
+ xml << response.doc.xpath("response/*").to_xml
11
+ else
12
+ xml.send(response, {statusCode: '1000', statusMessage: "Success!"})
13
+ end
14
+ }
15
+ }
16
+ end
17
+ end
18
+
19
+ def mock_the_response(response = 'SampleRs')
20
+ fake_response = mock_response(response)
21
+ FakeTCPSocket.instance.set_canned(fake_response.to_xml)
22
+ end
23
+
24
+ def mock_login_response
25
+ fake_response = mock_response('LoginRs')
26
+ FakeTCPSocket.instance.set_canned(fake_response.to_xml)
27
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fishbowl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-09 00:00:00.000000000 Z
12
+ date: 2012-11-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -39,23 +39,87 @@ files:
39
39
  - .rvmrc
40
40
  - .travis.yml
41
41
  - Gemfile
42
+ - Guardfile
42
43
  - LICENSE.txt
43
44
  - README.md
44
45
  - Rakefile
45
46
  - fishbowl.gemspec
46
47
  - lib/fishbowl.rb
47
48
  - lib/fishbowl/errors.rb
49
+ - lib/fishbowl/ext.rb
48
50
  - lib/fishbowl/objects.rb
49
51
  - lib/fishbowl/objects/account.rb
52
+ - lib/fishbowl/objects/address.rb
50
53
  - lib/fishbowl/objects/base_object.rb
54
+ - lib/fishbowl/objects/carrier.rb
55
+ - lib/fishbowl/objects/carton.rb
56
+ - lib/fishbowl/objects/uom.rb
57
+ - lib/fishbowl/objects/user.rb
58
+ - lib/fishbowl/requests.rb
59
+ - lib/fishbowl/requests/add_inventory.rb
60
+ - lib/fishbowl/requests/add_sales_order_item.rb
61
+ - lib/fishbowl/requests/adjust_inventory.rb
62
+ - lib/fishbowl/requests/get_carrier_list.rb
51
63
  - lib/fishbowl/version.rb
52
64
  - spec/connection_spec.rb
53
65
  - spec/errors_spec.rb
66
+ - spec/examples/account.xml
67
+ - spec/examples/address.xml
68
+ - spec/examples/carrier.xml
69
+ - spec/examples/carton.xml
70
+ - spec/examples/contact_information.xml
71
+ - spec/examples/contacts.xml
72
+ - spec/examples/credit_card.xml
73
+ - spec/examples/customer.xml
74
+ - spec/examples/location.xml
75
+ - spec/examples/location_group.xml
76
+ - spec/examples/location_group_string.xml
77
+ - spec/examples/order_history.xml
78
+ - spec/examples/part.xml
79
+ - spec/examples/payment.xml
80
+ - spec/examples/pick.xml
81
+ - spec/examples/pick_item.xml
82
+ - spec/examples/product.xml
83
+ - spec/examples/purchase_order.xml
84
+ - spec/examples/receipt.xml
85
+ - spec/examples/report.xml
86
+ - spec/examples/report_tree.xml
87
+ - spec/examples/sales_order.xml
88
+ - spec/examples/sales_order_item.xml
89
+ - spec/examples/shipping.xml
90
+ - spec/examples/tag.xml
91
+ - spec/examples/tax_rate.xml
92
+ - spec/examples/tracking.xml
93
+ - spec/examples/tracking_item.xml
94
+ - spec/examples/transfer_order.xml
95
+ - spec/examples/transfer_order_item.xml
96
+ - spec/examples/uom.xml
97
+ - spec/examples/uom_conversion.xml
98
+ - spec/examples/user.xml
99
+ - spec/examples/vendor.xml
100
+ - spec/examples/vendor_part_number.xml
101
+ - spec/examples/work_order.xml
102
+ - spec/examples/work_order_item.xml
54
103
  - spec/objects/account_spec.rb
104
+ - spec/objects/address_information_spec.rb
105
+ - spec/objects/address_spec.rb
55
106
  - spec/objects/base_object_spec.rb
107
+ - spec/objects/carrier_spec.rb
108
+ - spec/objects/carton_spec.rb
109
+ - spec/objects/country_spec.rb
110
+ - spec/objects/shipping_item_spec.rb
111
+ - spec/objects/state_spec.rb
112
+ - spec/objects/uom_conversion_spec.rb
113
+ - spec/objects/uom_spec.rb
114
+ - spec/objects/user_spec.rb
115
+ - spec/requests/add_inventory_spec.rb
116
+ - spec/requests/add_sales_order_item_spec.rb
117
+ - spec/requests/adjust_inventory_spec.rb
118
+ - spec/requests/get_carrier_list_spec.rb
56
119
  - spec/spec_helper.rb
57
- - spec/support/fake_login.rb
120
+ - spec/support/examples_loader.rb
58
121
  - spec/support/fake_socket.rb
122
+ - spec/support/response_mocks.rb
59
123
  homepage: https://github.com/readyproject/fishbowl
60
124
  licenses: []
61
125
  post_install_message:
@@ -70,7 +134,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
70
134
  version: '0'
71
135
  segments:
72
136
  - 0
73
- hash: -3228914196506736409
137
+ hash: -4607466373779507217
74
138
  required_rubygems_version: !ruby/object:Gem::Requirement
75
139
  none: false
76
140
  requirements:
@@ -79,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
143
  version: '0'
80
144
  segments:
81
145
  - 0
82
- hash: -3228914196506736409
146
+ hash: -4607466373779507217
83
147
  requirements: []
84
148
  rubyforge_project:
85
149
  rubygems_version: 1.8.24
@@ -89,8 +153,60 @@ summary: Fishbowl Inventory API
89
153
  test_files:
90
154
  - spec/connection_spec.rb
91
155
  - spec/errors_spec.rb
156
+ - spec/examples/account.xml
157
+ - spec/examples/address.xml
158
+ - spec/examples/carrier.xml
159
+ - spec/examples/carton.xml
160
+ - spec/examples/contact_information.xml
161
+ - spec/examples/contacts.xml
162
+ - spec/examples/credit_card.xml
163
+ - spec/examples/customer.xml
164
+ - spec/examples/location.xml
165
+ - spec/examples/location_group.xml
166
+ - spec/examples/location_group_string.xml
167
+ - spec/examples/order_history.xml
168
+ - spec/examples/part.xml
169
+ - spec/examples/payment.xml
170
+ - spec/examples/pick.xml
171
+ - spec/examples/pick_item.xml
172
+ - spec/examples/product.xml
173
+ - spec/examples/purchase_order.xml
174
+ - spec/examples/receipt.xml
175
+ - spec/examples/report.xml
176
+ - spec/examples/report_tree.xml
177
+ - spec/examples/sales_order.xml
178
+ - spec/examples/sales_order_item.xml
179
+ - spec/examples/shipping.xml
180
+ - spec/examples/tag.xml
181
+ - spec/examples/tax_rate.xml
182
+ - spec/examples/tracking.xml
183
+ - spec/examples/tracking_item.xml
184
+ - spec/examples/transfer_order.xml
185
+ - spec/examples/transfer_order_item.xml
186
+ - spec/examples/uom.xml
187
+ - spec/examples/uom_conversion.xml
188
+ - spec/examples/user.xml
189
+ - spec/examples/vendor.xml
190
+ - spec/examples/vendor_part_number.xml
191
+ - spec/examples/work_order.xml
192
+ - spec/examples/work_order_item.xml
92
193
  - spec/objects/account_spec.rb
194
+ - spec/objects/address_information_spec.rb
195
+ - spec/objects/address_spec.rb
93
196
  - spec/objects/base_object_spec.rb
197
+ - spec/objects/carrier_spec.rb
198
+ - spec/objects/carton_spec.rb
199
+ - spec/objects/country_spec.rb
200
+ - spec/objects/shipping_item_spec.rb
201
+ - spec/objects/state_spec.rb
202
+ - spec/objects/uom_conversion_spec.rb
203
+ - spec/objects/uom_spec.rb
204
+ - spec/objects/user_spec.rb
205
+ - spec/requests/add_inventory_spec.rb
206
+ - spec/requests/add_sales_order_item_spec.rb
207
+ - spec/requests/adjust_inventory_spec.rb
208
+ - spec/requests/get_carrier_list_spec.rb
94
209
  - spec/spec_helper.rb
95
- - spec/support/fake_login.rb
210
+ - spec/support/examples_loader.rb
96
211
  - spec/support/fake_socket.rb
212
+ - spec/support/response_mocks.rb