constructorio 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 34e9a8ea3bf35db06ddd9babd3b610c1c2222d88
4
- data.tar.gz: b5ca5cf81af66a4e345477e444392bdd2a1045f1
3
+ metadata.gz: 7bdcf14c279f86ef947463344dd6cb458b3076f6
4
+ data.tar.gz: 14df82b63a070e166fe17e2163090c2e10df17cb
5
5
  SHA512:
6
- metadata.gz: 70f50cf84af5eff9ed010663445fc0a17a801d8fc9fcaa8e55a2b8454ac4c2559d35182f5e2600059cdffa70ff0b93ee04fb2287207d2d947ed85a69cab22d30
7
- data.tar.gz: 8e1f0c827e18f970b9e6abe085f354d3fda650037966b8cc606b98f31aa46040cd537f632cf4edb40b892ce9fa293c917d29acc32c5350dcf4c33e8701b4a494
6
+ metadata.gz: c578be95fc55ac3a23928ce990aad9bb36de2c5dff53bf557f2561f4799e2ba0e5f3a7f88ca28814255d2c27fec8275af5be1f01733fac4075bf7e53f9f48d8f
7
+ data.tar.gz: 9f16bb3302e75a4f98f32e6a6784da8e96251de5f5e84d6ce52df838707157844b4cfd1658a5bf02260a9196a01a21eca2ff1c396df258f28a1d01ff1f7134cc
@@ -24,4 +24,6 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency 'pry', '~> 0.10', '>= 0.10.1'
25
25
  spec.add_development_dependency 'mocha', '~> 1.1', '>= 1.1.0'
26
26
  spec.add_development_dependency 'minitest', '~> 5.5', '>= 5.5.1'
27
+ spec.add_development_dependency 'vcr'
28
+ spec.add_development_dependency 'webmock'
27
29
  end
@@ -48,11 +48,7 @@ module ConstructorIO
48
48
  request.headers['Content-Type'] = 'application/json'
49
49
  request.body = params.to_json
50
50
  end
51
- if response.status.to_s =~ /^2/
52
- return nil
53
- else
54
- return response.status
55
- end
51
+ response
56
52
  end
57
53
  end
58
54
  end
@@ -1,3 +1,3 @@
1
1
  module ConstructorIO
2
- VERSION = "2.0.1"
2
+ VERSION = "2.0.2"
3
3
  end
@@ -0,0 +1,42 @@
1
+ require_relative 'test_helper'
2
+ require 'vcr'
3
+
4
+ VCR.configure do |config|
5
+ config.cassette_library_dir = "test/fixtures/vcr_cassettes"
6
+ config.hook_into :webmock
7
+ end
8
+
9
+ class ConstructorIOVCRTest < MiniTest::Test
10
+ def test_add_item
11
+ c = ConstructorIO::Client.new
12
+
13
+ VCR.use_cassette("add_item") do
14
+ response = c.add(
15
+ { item_name: "power_drill", autocomplete_section: "standard" }
16
+ )
17
+ assert_equal response.status, 204
18
+ end
19
+ end
20
+
21
+ def test_remove_item
22
+ c = ConstructorIO::Client.new
23
+
24
+ VCR.use_cassette("remove_item") do
25
+ response = c.remove(
26
+ { item_name: "power_drill", autocomplete_section: "standard" }
27
+ )
28
+ assert_equal response.status, 204
29
+ end
30
+ end
31
+
32
+ def test_modify_item
33
+ c = ConstructorIO::Client.new
34
+
35
+ VCR.use_cassette("modify_item") do
36
+ response = c.remove(
37
+ { item_name: "power_drill", autocomplete_section: "standard", suggested_score: 10 }
38
+ )
39
+ assert_equal response.status, 204
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,30 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/unit'
3
+ require 'mocha/mini_test'
4
+ require_relative '../lib/constructorio'
5
+ require 'vcr'
6
+
7
+ VCR.configure do |config|
8
+ config.cassette_library_dir = "test/fixtures/vcr_cassettes"
9
+ config.hook_into :webmock
10
+ end
11
+
12
+ class ConstructorIOVCRTestErrors < MiniTest::Test
13
+ def test_add_item_error
14
+ ConstructorIO.configure do |config|
15
+ config.api_token = "Bad token"
16
+ config.autocomplete_key = ENV['CONSTRUCTORIO_AUTOCOMPLETE_KEY'] || "example_autocomplete_key"
17
+ config.api_url = "http://dev.ac.cnstrc.com"
18
+ end
19
+
20
+ c = ConstructorIO::Client.new
21
+
22
+ VCR.use_cassette("add_item_error") do
23
+ response = c.add(
24
+ { item_name: "power_drill", autocomplete_section: "standard" }
25
+ )
26
+ assert_equal 401, response.status
27
+ assert_match /Invalid auth_token. If you've forgotten your token, you can generate a new one in the admin dashboard/, response.body
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,49 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://IC9WGYro9O8o5orJW7p2:@dev.ac.cnstrc.com/v1/item?autocomplete_key=Du08voCN2t3IKdUhSepw
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"item_name":"power_drill","autocomplete_section":"standard"}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.1
12
+ Content-Type:
13
+ - application/json
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 204
21
+ message: NO CONTENT
22
+ headers:
23
+ Server:
24
+ - nginx/1.4.6 (Ubuntu)
25
+ Content-Type:
26
+ - text/html; charset=utf-8
27
+ Content-Length:
28
+ - '0'
29
+ Set-Cookie:
30
+ - session=eyJwd19oYXNoIjp7IiBiIjoiSkRKaEpEQTRKRkpQY1RkNGJGSnlOeTlzWXpaVFYzWkNjbFYyUkM1YVZqQXlZMjlUVVM5b05DNVZhRlJUVG5Bek5XSlZVVFZ0UXpobWNrd3kifX0.CLlrcA.PcmF6orlyXrxZhE4eQQPN6Q4hn4;
31
+ HttpOnly; Path=/
32
+ Accept-Ranges:
33
+ - bytes
34
+ Date:
35
+ - Sat, 22 Aug 2015 02:09:52 GMT
36
+ X-Varnish:
37
+ - '1173375154'
38
+ Age:
39
+ - '0'
40
+ Via:
41
+ - 1.1 varnish
42
+ Connection:
43
+ - keep-alive
44
+ body:
45
+ encoding: UTF-8
46
+ string: ''
47
+ http_version:
48
+ recorded_at: Sat, 22 Aug 2015 02:09:52 GMT
49
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,49 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://Bad%20token:@dev.ac.cnstrc.com/v1/item?autocomplete_key=Du08voCN2t3IKdUhSepw
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"item_name":"power_drill","autocomplete_section":"standard"}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.1
12
+ Content-Type:
13
+ - application/json
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 401
21
+ message: UNAUTHORIZED
22
+ headers:
23
+ Server:
24
+ - nginx/1.4.6 (Ubuntu)
25
+ Content-Type:
26
+ - application/json
27
+ Content-Length:
28
+ - '120'
29
+ Accept-Ranges:
30
+ - bytes
31
+ Date:
32
+ - Sat, 22 Aug 2015 02:50:30 GMT
33
+ X-Varnish:
34
+ - '1173375167'
35
+ Age:
36
+ - '0'
37
+ Via:
38
+ - 1.1 varnish
39
+ Connection:
40
+ - keep-alive
41
+ body:
42
+ encoding: UTF-8
43
+ string: |-
44
+ {
45
+ "message": "Invalid auth_token. If you've forgotten your token, you can generate a new one in the admin dashboard"
46
+ }
47
+ http_version:
48
+ recorded_at: Sat, 22 Aug 2015 02:50:31 GMT
49
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,49 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: delete
5
+ uri: http://IC9WGYro9O8o5orJW7p2:@dev.ac.cnstrc.com/v1/item?autocomplete_key=Du08voCN2t3IKdUhSepw
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"item_name":"power_drill","autocomplete_section":"standard","suggested_score":10}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.1
12
+ Content-Type:
13
+ - application/json
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 204
21
+ message: NO CONTENT
22
+ headers:
23
+ Server:
24
+ - nginx/1.4.6 (Ubuntu)
25
+ Content-Type:
26
+ - text/html; charset=utf-8
27
+ Content-Length:
28
+ - '0'
29
+ Set-Cookie:
30
+ - session=eyJwd19oYXNoIjp7IiBiIjoiSkRKaEpEQTRKRkpQY1RkNGJGSnlOeTlzWXpaVFYzWkNjbFYyUkM1YVZqQXlZMjlUVVM5b05DNVZhRlJUVG5Bek5XSlZVVFZ0UXpobWNrd3kifX0.CLlsOQ.-AKI1lmN4lNo6I5A2d1mKjswwik;
31
+ HttpOnly; Path=/
32
+ Accept-Ranges:
33
+ - bytes
34
+ Date:
35
+ - Sat, 22 Aug 2015 02:13:13 GMT
36
+ X-Varnish:
37
+ - '1173375164'
38
+ Age:
39
+ - '0'
40
+ Via:
41
+ - 1.1 varnish
42
+ Connection:
43
+ - keep-alive
44
+ body:
45
+ encoding: UTF-8
46
+ string: ''
47
+ http_version:
48
+ recorded_at: Sat, 22 Aug 2015 02:13:14 GMT
49
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,49 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: delete
5
+ uri: http://IC9WGYro9O8o5orJW7p2:@dev.ac.cnstrc.com/v1/item?autocomplete_key=Du08voCN2t3IKdUhSepw
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"item_name":"power_drill","autocomplete_section":"standard"}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.1
12
+ Content-Type:
13
+ - application/json
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 204
21
+ message: NO CONTENT
22
+ headers:
23
+ Server:
24
+ - nginx/1.4.6 (Ubuntu)
25
+ Content-Type:
26
+ - text/html; charset=utf-8
27
+ Content-Length:
28
+ - '0'
29
+ Set-Cookie:
30
+ - session=eyJwd19oYXNoIjp7IiBiIjoiSkRKaEpEQTRKRkpQY1RkNGJGSnlOeTlzWXpaVFYzWkNjbFYyUkM1YVZqQXlZMjlUVVM5b05DNVZhRlJUVG5Bek5XSlZVVFZ0UXpobWNrd3kifX0.CLlr-g.sNGaLdVDC52vovPDfy1tOxSuNfc;
31
+ HttpOnly; Path=/
32
+ Accept-Ranges:
33
+ - bytes
34
+ Date:
35
+ - Sat, 22 Aug 2015 02:12:10 GMT
36
+ X-Varnish:
37
+ - '1173375163'
38
+ Age:
39
+ - '0'
40
+ Via:
41
+ - 1.1 varnish
42
+ Connection:
43
+ - keep-alive
44
+ body:
45
+ encoding: UTF-8
46
+ string: ''
47
+ http_version:
48
+ recorded_at: Sat, 22 Aug 2015 02:12:10 GMT
49
+ recorded_with: VCR 2.9.3
data/test/test_helper.rb CHANGED
@@ -4,7 +4,7 @@ require 'mocha/mini_test'
4
4
  require_relative '../lib/constructorio'
5
5
 
6
6
  ConstructorIO.configure do |config|
7
- config.api_token = "example_api_token"
8
- config.autocomplete_key = "example_autocomplete_key"
9
- config.api_url = "http://example.constructor.io"
7
+ config.api_token = ENV['CONSTRUCTORIO_API_TOKEN'] || "example_api_token"
8
+ config.autocomplete_key = ENV['CONSTRUCTORIO_AUTOCOMPLETE_KEY'] || "example_autocomplete_key"
9
+ config.api_url = "http://dev.ac.cnstrc.com"
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: constructorio
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan McCormick
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-21 00:00:00.000000000 Z
11
+ date: 2015-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -118,6 +118,34 @@ dependencies:
118
118
  - - ">="
119
119
  - !ruby/object:Gem::Version
120
120
  version: 5.5.1
121
+ - !ruby/object:Gem::Dependency
122
+ name: vcr
123
+ requirement: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ type: :development
129
+ prerelease: false
130
+ version_requirements: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ - !ruby/object:Gem::Dependency
136
+ name: webmock
137
+ requirement: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ type: :development
143
+ prerelease: false
144
+ version_requirements: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
121
149
  description: Ruby gem for Constructor.io's autocomplete service.
122
150
  email:
123
151
  - dan@constructor.io
@@ -139,6 +167,12 @@ files:
139
167
  - lib/constructorio/version.rb
140
168
  - test/configuration_test.rb
141
169
  - test/constructorio_test.rb
170
+ - test/constructorio_vcr_test.rb
171
+ - test/constructorio_vcr_test_errors.rb
172
+ - test/fixtures/vcr_cassettes/add_item.yml
173
+ - test/fixtures/vcr_cassettes/add_item_error.yml
174
+ - test/fixtures/vcr_cassettes/modify_item.yml
175
+ - test/fixtures/vcr_cassettes/remove_item.yml
142
176
  - test/test_helper.rb
143
177
  homepage: http://constructor.io
144
178
  licenses:
@@ -167,4 +201,10 @@ summary: Ruby gem for Constructor.io
167
201
  test_files:
168
202
  - test/configuration_test.rb
169
203
  - test/constructorio_test.rb
204
+ - test/constructorio_vcr_test.rb
205
+ - test/constructorio_vcr_test_errors.rb
206
+ - test/fixtures/vcr_cassettes/add_item.yml
207
+ - test/fixtures/vcr_cassettes/add_item_error.yml
208
+ - test/fixtures/vcr_cassettes/modify_item.yml
209
+ - test/fixtures/vcr_cassettes/remove_item.yml
170
210
  - test/test_helper.rb