oshpark 0.0.7 → 0.0.10
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/.gitignore +1 -0
- data/Gemfile.lock +13 -17
- data/Guardfile +0 -7
- data/lib/oshpark.rb +2 -0
- data/lib/oshpark/address.rb +8 -1
- data/lib/oshpark/client.rb +20 -4
- data/lib/oshpark/connection.rb +6 -2
- data/lib/oshpark/import.rb +1 -0
- data/lib/oshpark/model.rb +14 -35
- data/lib/oshpark/order.rb +12 -5
- data/lib/oshpark/panel.rb +1 -0
- data/lib/oshpark/price.rb +15 -0
- data/lib/oshpark/project.rb +2 -1
- data/lib/oshpark/remote_model.rb +41 -0
- data/lib/oshpark/shipping_rate.rb +1 -1
- data/lib/oshpark/token.rb +15 -5
- data/lib/oshpark/upload.rb +1 -0
- data/lib/oshpark/version.rb +1 -1
- data/oshpark.gemspec +2 -1
- data/spec/acceptance/authentication_spec.rb +51 -0
- data/spec/acceptance/workflow_spec.rb +71 -0
- data/spec/fixtures/2-Layer.brd +0 -0
- data/spec/fixtures/cassettes/RSpec_ExampleGroups_APIWorkflow.yml +16416 -0
- data/spec/fixtures/cassettes/RSpec_ExampleGroups_APIWorkflow_WhenPayingByInvoice.yml +13438 -0
- data/spec/lib/oshpark/address_spec.rb +1 -1
- data/spec/lib/oshpark/client_spec.rb +15 -4
- data/spec/lib/oshpark/model_spec.rb +3 -0
- data/spec/lib/oshpark/price_spec.rb +28 -0
- data/spec/support/helper.rb +17 -0
- data/spec/support/vcr.rb +26 -0
- metadata +44 -12
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Oshpark::Address do
|
4
4
|
describe ".initialize" do
|
5
|
-
let(:args) { {name: "Bob", address_line_1: "8 Nelson Street", address_line_2: "Petone", city: "Lower Hutt", country: "New Zealand"} }
|
5
|
+
let(:args) { {"address" => {name: "Bob", address_line_1: "8 Nelson Street", address_line_2: "Petone", city: "Lower Hutt", country: "New Zealand"}} }
|
6
6
|
|
7
7
|
subject { Oshpark::Address.new args }
|
8
8
|
it "creates an address" do
|
@@ -54,6 +54,17 @@ describe Oshpark::Client do
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
+
describe "#pricing" do
|
58
|
+
let(:width) { 1000 }
|
59
|
+
let(:height) { 1000 }
|
60
|
+
let(:layers) { 2 }
|
61
|
+
|
62
|
+
it "return pricing information" do
|
63
|
+
subject.pricing width, height, layers
|
64
|
+
expect(connection.requests.last).to eq([:post, "pricing", {width_in_mils: 1000, height_in_mils: 1000, pcb_layers: 2, quantity: nil}])
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
57
68
|
describe '#orders' do
|
58
69
|
it 'retrieves a list of orders from the API' do
|
59
70
|
subject.orders
|
@@ -82,7 +93,7 @@ describe Oshpark::Client do
|
|
82
93
|
let(:quantity) { 6 }
|
83
94
|
it "add an order item to an order" do
|
84
95
|
subject.add_order_item token, project_id, quantity
|
85
|
-
expect(connection.requests.last).to eq([:
|
96
|
+
expect(connection.requests.last).to eq([:post, "orders/#{token}/add_item", {order: {:project_id=>"1234abcd", :quantity=>6}}])
|
86
97
|
end
|
87
98
|
end
|
88
99
|
|
@@ -91,7 +102,7 @@ describe Oshpark::Client do
|
|
91
102
|
let(:address) { {"name" => "Bob", "company_name" => nil, "address_line_1" => "8 Nelson Street", "address_line_2" => "Petone", "city" => "Lower Hutt", "state" => nil, "zip_or_postal_code" => nil, "country" => "New Zealand", "phone_number" => nil, "is_business" => nil} }
|
92
103
|
it "set the delivery address for an order" do
|
93
104
|
subject.set_order_address token, address
|
94
|
-
expect(connection.requests.last).to eq([:
|
105
|
+
expect(connection.requests.last).to eq([:post, "orders/#{token}/set_address", {order: {address: {"name" => "Bob", "company_name" => nil, "address_line_1" => "8 Nelson Street", "address_line_2" => "Petone", "city" => "Lower Hutt", "state" => nil, "zip_or_postal_code" => nil, "country" => "New Zealand", "phone_number" => nil, "is_business" => nil}}}])
|
95
106
|
end
|
96
107
|
end
|
97
108
|
|
@@ -110,7 +121,7 @@ describe Oshpark::Client do
|
|
110
121
|
let(:service_name) { 'Overnight Delivery' }
|
111
122
|
it "sets the shipping rate for an order" do
|
112
123
|
subject.set_order_shipping_rate token, service_provider, service_name
|
113
|
-
expect(connection.requests.last).to eq([:
|
124
|
+
expect(connection.requests.last).to eq([:post, "orders/#{token}/set_shipping_rate", {order: {shipping_rate: {carrier_name: "Bobs Mail", service_name: "Overnight Delivery"}}}])
|
114
125
|
end
|
115
126
|
end
|
116
127
|
|
@@ -118,7 +129,7 @@ describe Oshpark::Client do
|
|
118
129
|
let(:token) { 'abcd1234' }
|
119
130
|
it "checks out an order" do
|
120
131
|
subject.checkout_order token
|
121
|
-
expect(connection.requests.last).to eq([:
|
132
|
+
expect(connection.requests.last).to eq([:post, "orders/#{token}/checkout", {}])
|
122
133
|
end
|
123
134
|
end
|
124
135
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Oshpark::Price do
|
4
|
+
before do
|
5
|
+
Oshpark::client url: 'blarg', connection: FakeClient.new("foo")
|
6
|
+
end
|
7
|
+
|
8
|
+
subject { Oshpark::Price.new({}) }
|
9
|
+
it { should be_an Oshpark::Model }
|
10
|
+
|
11
|
+
describe 'price_for' do
|
12
|
+
let(:width) { 1000 }
|
13
|
+
let(:height) { 1000 }
|
14
|
+
let(:layers) { 2 }
|
15
|
+
subject { Oshpark::Price.price_for width, height, layers }
|
16
|
+
|
17
|
+
before do
|
18
|
+
expect(Oshpark::client).to receive(:pricing).
|
19
|
+
with(1000, 1000, 2, nil).
|
20
|
+
and_return({'pricing' => {batch_cost: "5.00", subtotal: "10.00"}})
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns a price" do
|
24
|
+
expect(subject).to be_an Oshpark::Price
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Helper
|
2
|
+
def cleanup
|
3
|
+
Oshpark.client.authenticate ENV['USERNAME'], with_api_secret: ENV['API_SECRET']
|
4
|
+
|
5
|
+
Oshpark.client.projects['projects'].each do |project|
|
6
|
+
Oshpark.client.destroy_project project['id']
|
7
|
+
end
|
8
|
+
|
9
|
+
Oshpark.client.orders['orders'].each do |order|
|
10
|
+
Oshpark.client.cancel_order order['id']
|
11
|
+
end
|
12
|
+
|
13
|
+
rescue
|
14
|
+
ensure
|
15
|
+
Oshpark.client.abandon
|
16
|
+
end
|
17
|
+
end
|
data/spec/support/vcr.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'dotenv'
|
2
|
+
Dotenv.load
|
3
|
+
|
4
|
+
require 'vcr'
|
5
|
+
|
6
|
+
VCR.configure do |config|
|
7
|
+
config.cassette_library_dir = File.expand_path('../../fixtures/cassettes/', __FILE__)
|
8
|
+
config.hook_into :webmock
|
9
|
+
|
10
|
+
config.filter_sensitive_data('USERNAME') { ENV['USERNAME'] }
|
11
|
+
config.filter_sensitive_data('PASSWORD') { ENV['PASSWORD'] }
|
12
|
+
end
|
13
|
+
|
14
|
+
module SwitchCassette
|
15
|
+
def self.extended base
|
16
|
+
base.around(:each) do |example|
|
17
|
+
opts = { preserve_exact_body_bytes: true }
|
18
|
+
opts[:record] = if ENV['CI']
|
19
|
+
:all
|
20
|
+
else
|
21
|
+
:none
|
22
|
+
end
|
23
|
+
VCR.use_cassette example.example_group.name.strip, opts, &example
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oshpark
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Harton
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-12-
|
12
|
+
date: 2014-12-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '1.6'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: rspec-core
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name: rspec-
|
43
|
+
name: rspec-mocks
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - ">="
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
name: rspec-
|
57
|
+
name: rspec-its
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - ">="
|
@@ -68,7 +68,7 @@ dependencies:
|
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
|
-
name: rspec
|
71
|
+
name: guard-rspec
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - ">="
|
@@ -82,7 +82,7 @@ dependencies:
|
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
|
-
name: guard-
|
85
|
+
name: guard-bundler
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
88
|
- - ">="
|
@@ -96,7 +96,7 @@ dependencies:
|
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
|
-
name:
|
99
|
+
name: pry
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
102
|
- - ">="
|
@@ -110,7 +110,7 @@ dependencies:
|
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
|
-
name:
|
113
|
+
name: rake
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
116
|
- - ">="
|
@@ -124,7 +124,7 @@ dependencies:
|
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
|
-
name:
|
127
|
+
name: byebug
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
130
|
- - ">="
|
@@ -138,7 +138,7 @@ dependencies:
|
|
138
138
|
- !ruby/object:Gem::Version
|
139
139
|
version: '0'
|
140
140
|
- !ruby/object:Gem::Dependency
|
141
|
-
name:
|
141
|
+
name: vcr
|
142
142
|
requirement: !ruby/object:Gem::Requirement
|
143
143
|
requirements:
|
144
144
|
- - ">="
|
@@ -152,7 +152,21 @@ dependencies:
|
|
152
152
|
- !ruby/object:Gem::Version
|
153
153
|
version: '0'
|
154
154
|
- !ruby/object:Gem::Dependency
|
155
|
-
name:
|
155
|
+
name: webmock
|
156
|
+
requirement: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
type: :development
|
162
|
+
prerelease: false
|
163
|
+
version_requirements: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - ">="
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
- !ruby/object:Gem::Dependency
|
169
|
+
name: dotenv
|
156
170
|
requirement: !ruby/object:Gem::Requirement
|
157
171
|
requirements:
|
158
172
|
- - ">="
|
@@ -225,7 +239,9 @@ files:
|
|
225
239
|
- lib/oshpark/order_item_option_selection.rb
|
226
240
|
- lib/oshpark/order_option.rb
|
227
241
|
- lib/oshpark/panel.rb
|
242
|
+
- lib/oshpark/price.rb
|
228
243
|
- lib/oshpark/project.rb
|
244
|
+
- lib/oshpark/remote_model.rb
|
229
245
|
- lib/oshpark/rubymotion.rb
|
230
246
|
- lib/oshpark/shipping_rate.rb
|
231
247
|
- lib/oshpark/stateful.rb
|
@@ -234,6 +250,11 @@ files:
|
|
234
250
|
- lib/oshpark/user.rb
|
235
251
|
- lib/oshpark/version.rb
|
236
252
|
- oshpark.gemspec
|
253
|
+
- spec/acceptance/authentication_spec.rb
|
254
|
+
- spec/acceptance/workflow_spec.rb
|
255
|
+
- spec/fixtures/2-Layer.brd
|
256
|
+
- spec/fixtures/cassettes/RSpec_ExampleGroups_APIWorkflow.yml
|
257
|
+
- spec/fixtures/cassettes/RSpec_ExampleGroups_APIWorkflow_WhenPayingByInvoice.yml
|
237
258
|
- spec/lib/oshpark/address_spec.rb
|
238
259
|
- spec/lib/oshpark/client_spec.rb
|
239
260
|
- spec/lib/oshpark/image_spec.rb
|
@@ -242,11 +263,14 @@ files:
|
|
242
263
|
- spec/lib/oshpark/model_spec.rb
|
243
264
|
- spec/lib/oshpark/order_spec.rb
|
244
265
|
- spec/lib/oshpark/panel_spec.rb
|
266
|
+
- spec/lib/oshpark/price_spec.rb
|
245
267
|
- spec/lib/oshpark/project_spec.rb
|
246
268
|
- spec/lib/oshpark/shipping_rate_spec.rb
|
247
269
|
- spec/lib/oshpark/upload_spec.rb
|
248
270
|
- spec/spec_helper.rb
|
271
|
+
- spec/support/helper.rb
|
249
272
|
- spec/support/http_client.rb
|
273
|
+
- spec/support/vcr.rb
|
250
274
|
homepage: ''
|
251
275
|
licenses:
|
252
276
|
- MIT
|
@@ -272,6 +296,11 @@ signing_key:
|
|
272
296
|
specification_version: 4
|
273
297
|
summary: API and command line client for oshpark.com
|
274
298
|
test_files:
|
299
|
+
- spec/acceptance/authentication_spec.rb
|
300
|
+
- spec/acceptance/workflow_spec.rb
|
301
|
+
- spec/fixtures/2-Layer.brd
|
302
|
+
- spec/fixtures/cassettes/RSpec_ExampleGroups_APIWorkflow.yml
|
303
|
+
- spec/fixtures/cassettes/RSpec_ExampleGroups_APIWorkflow_WhenPayingByInvoice.yml
|
275
304
|
- spec/lib/oshpark/address_spec.rb
|
276
305
|
- spec/lib/oshpark/client_spec.rb
|
277
306
|
- spec/lib/oshpark/image_spec.rb
|
@@ -280,8 +309,11 @@ test_files:
|
|
280
309
|
- spec/lib/oshpark/model_spec.rb
|
281
310
|
- spec/lib/oshpark/order_spec.rb
|
282
311
|
- spec/lib/oshpark/panel_spec.rb
|
312
|
+
- spec/lib/oshpark/price_spec.rb
|
283
313
|
- spec/lib/oshpark/project_spec.rb
|
284
314
|
- spec/lib/oshpark/shipping_rate_spec.rb
|
285
315
|
- spec/lib/oshpark/upload_spec.rb
|
286
316
|
- spec/spec_helper.rb
|
317
|
+
- spec/support/helper.rb
|
287
318
|
- spec/support/http_client.rb
|
319
|
+
- spec/support/vcr.rb
|