quinoa 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/Gemfile.lock +22 -16
- data/changelog +6 -1
- data/lib/quinoa/service.rb +48 -38
- data/lib/quinoa/version.rb +1 -1
- data/quinoa.gemspec +5 -4
- data/spec/core_spec.rb +65 -2
- data/spec/spec_helper.rb +5 -0
- metadata +24 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9134ab658e1dd3179dc1457e998629e11f2d854
|
4
|
+
data.tar.gz: 1686da5cbd70f796996f5b2b0f2260fbfe5d181a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e31a232a1511cd4d3e8108b322972e618874ead066b90a3d208ded964089741ebd3185a85801f7a3e3c016c53711936de953c9297135f57b8ce1c30af7541b8
|
7
|
+
data.tar.gz: 6f8cb0f6cbfe7580bf60098bf89bf7cf8fe427dcb5bedf6d0225db1ec1053d4e27602c68bc9f8988a98bb3ea4912c89caa8b64ee602464e4ba22d70326f4bc2b
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
quinoa (0.0.
|
4
|
+
quinoa (0.0.12)
|
5
5
|
rest-client (~> 2.0.0)
|
6
6
|
rspec (~> 3.5.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: http://rubygems.org/
|
10
10
|
specs:
|
11
|
-
addressable (2.
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
addressable (2.5.0)
|
12
|
+
public_suffix (~> 2.0, >= 2.0.2)
|
13
|
+
builder (3.2.3)
|
14
|
+
codeclimate-test-reporter (1.0.5)
|
15
|
+
simplecov
|
15
16
|
coderay (1.1.1)
|
16
17
|
crack (0.4.3)
|
17
18
|
safe_yaml (~> 1.0.0)
|
@@ -26,15 +27,15 @@ GEM
|
|
26
27
|
cucumber-core (1.5.0)
|
27
28
|
gherkin (~> 4.0)
|
28
29
|
cucumber-wire (0.0.1)
|
29
|
-
diff-lcs (1.
|
30
|
+
diff-lcs (1.3)
|
30
31
|
docile (1.1.5)
|
31
|
-
domain_name (0.5.
|
32
|
+
domain_name (0.5.20161129)
|
32
33
|
unf (>= 0.0.5, < 1.0.0)
|
33
34
|
gherkin (4.0.0)
|
34
|
-
hashdiff (0.3.
|
35
|
+
hashdiff (0.3.2)
|
35
36
|
http-cookie (1.0.3)
|
36
37
|
domain_name (~> 0.5)
|
37
|
-
json (2.0.
|
38
|
+
json (2.0.3)
|
38
39
|
method_source (0.8.2)
|
39
40
|
mime-types (3.1)
|
40
41
|
mime-types-data (~> 3.2015)
|
@@ -48,7 +49,8 @@ GEM
|
|
48
49
|
coderay (~> 1.1.0)
|
49
50
|
method_source (~> 0.8.1)
|
50
51
|
slop (~> 3.4)
|
51
|
-
|
52
|
+
public_suffix (2.0.5)
|
53
|
+
rake (12.0.0)
|
52
54
|
rest-client (2.0.0)
|
53
55
|
http-cookie (>= 1.0.2, < 2.0)
|
54
56
|
mime-types (>= 1.16, < 4.0)
|
@@ -67,16 +69,19 @@ GEM
|
|
67
69
|
rspec-support (~> 3.5.0)
|
68
70
|
rspec-support (3.5.0)
|
69
71
|
safe_yaml (1.0.4)
|
70
|
-
simplecov (0.
|
72
|
+
simplecov (0.13.0)
|
71
73
|
docile (~> 1.1.0)
|
72
74
|
json (>= 1.8, < 3)
|
73
75
|
simplecov-html (~> 0.10.0)
|
74
76
|
simplecov-html (0.10.0)
|
77
|
+
simplecov-json (0.2)
|
78
|
+
json
|
79
|
+
simplecov
|
75
80
|
slop (3.6.0)
|
76
81
|
unf (0.1.4)
|
77
82
|
unf_ext
|
78
83
|
unf_ext (0.0.7.2)
|
79
|
-
webmock (2.
|
84
|
+
webmock (2.3.2)
|
80
85
|
addressable (>= 2.3.6)
|
81
86
|
crack (>= 0.3.2)
|
82
87
|
hashdiff
|
@@ -85,14 +90,15 @@ PLATFORMS
|
|
85
90
|
ruby
|
86
91
|
|
87
92
|
DEPENDENCIES
|
88
|
-
codeclimate-test-reporter (~> 0.
|
93
|
+
codeclimate-test-reporter (~> 1.0.5)
|
89
94
|
cucumber (~> 2.4.0)
|
90
95
|
nyan-cat-formatter (~> 0.11)
|
91
96
|
pry (~> 0.10.4)
|
92
97
|
quinoa!
|
93
|
-
rake (~>
|
94
|
-
simplecov (~> 0.
|
95
|
-
|
98
|
+
rake (~> 12.0.0)
|
99
|
+
simplecov (~> 0.13.0)
|
100
|
+
simplecov-json (~> 0.2)
|
101
|
+
webmock (~> 2.3.2)
|
96
102
|
|
97
103
|
BUNDLED WITH
|
98
104
|
1.13.6
|
data/changelog
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.12: Adding put method
|
2
|
+
- adding put method
|
3
|
+
- small code improvements
|
4
|
+
- updating development dependencies
|
5
|
+
|
6
|
+
0.0.11: Adding first version of expectations and report api
|
2
7
|
- adding report
|
3
8
|
- adding expectations
|
4
9
|
|
data/lib/quinoa/service.rb
CHANGED
@@ -18,51 +18,31 @@ module Quinoa
|
|
18
18
|
self.url = url
|
19
19
|
end
|
20
20
|
|
21
|
+
def put! url=nil
|
22
|
+
p_methods("put", url)
|
23
|
+
end
|
24
|
+
|
21
25
|
def post! url=nil
|
22
|
-
|
23
|
-
if url == nil
|
24
|
-
get_time {
|
25
|
-
RestClient.post(
|
26
|
-
self.url + self.path,
|
27
|
-
self.body,
|
28
|
-
{:accept => self.accept,
|
29
|
-
:content_type => self.content_type,
|
30
|
-
:authorization => self.authorization}.merge!(self.custom_headers)
|
31
|
-
)
|
32
|
-
}
|
33
|
-
else
|
34
|
-
get_time {
|
35
|
-
RestClient.post(
|
36
|
-
url,
|
37
|
-
self.body,
|
38
|
-
{:accept => self.accept,
|
39
|
-
:content_type => self.content_type,
|
40
|
-
:authorization => self.authorization}.merge!(self.custom_headers)
|
41
|
-
)
|
42
|
-
}
|
43
|
-
end
|
44
|
-
rescue => e
|
45
|
-
self.response = e.response
|
46
|
-
end
|
26
|
+
p_methods("post", url)
|
47
27
|
end
|
48
28
|
|
49
29
|
def get! url=nil
|
50
30
|
begin
|
51
31
|
if url == nil
|
52
|
-
get_time {
|
32
|
+
get_time {
|
53
33
|
RestClient.get(
|
54
|
-
self.url + self.path,
|
55
|
-
{:accept => self.accept,
|
34
|
+
self.url + self.path,
|
35
|
+
{:accept => self.accept,
|
56
36
|
:authorization => self.authorization}.merge!(self.custom_headers)
|
57
|
-
)
|
37
|
+
)
|
58
38
|
}
|
59
39
|
else
|
60
|
-
get_time {
|
61
|
-
RestClient.get(
|
62
|
-
url,
|
63
|
-
{:accept => self.accept,
|
40
|
+
get_time {
|
41
|
+
RestClient.get(
|
42
|
+
url,
|
43
|
+
{:accept => self.accept,
|
64
44
|
:authorization => self.authorization}.merge!(self.custom_headers)
|
65
|
-
)
|
45
|
+
)
|
66
46
|
}
|
67
47
|
end
|
68
48
|
rescue => e
|
@@ -90,7 +70,7 @@ module Quinoa
|
|
90
70
|
self.response.headers[:location]
|
91
71
|
end
|
92
72
|
|
93
|
-
def add_custom_header custom_header_name, custom_header_value
|
73
|
+
def add_custom_header custom_header_name, custom_header_value
|
94
74
|
self.custom_headers.merge! custom_header_name.to_sym => custom_header_value.to_s
|
95
75
|
end
|
96
76
|
|
@@ -121,11 +101,11 @@ module Quinoa
|
|
121
101
|
|
122
102
|
self.assertions.merge! get_assertion_record(
|
123
103
|
assertion_item,
|
124
|
-
expectation_map[:value],
|
104
|
+
expectation_map[:value],
|
125
105
|
check_attribute?(
|
126
106
|
assertion_item,
|
127
|
-
expectation_map[:value],
|
128
|
-
expectation_map[:compare_using]),
|
107
|
+
expectation_map[:value],
|
108
|
+
expectation_map[:compare_using]),
|
129
109
|
expectation_map[:level])
|
130
110
|
end
|
131
111
|
end
|
@@ -143,6 +123,36 @@ module Quinoa
|
|
143
123
|
end
|
144
124
|
|
145
125
|
private
|
126
|
+
def p_methods method_name, url=nil
|
127
|
+
meth = RestClient.method(method_name)
|
128
|
+
begin
|
129
|
+
if url == nil
|
130
|
+
get_time {
|
131
|
+
meth.call(
|
132
|
+
self.url + self.path,
|
133
|
+
self.body,
|
134
|
+
{:accept => self.accept,
|
135
|
+
:content_type => self.content_type,
|
136
|
+
:authorization => self.authorization}.merge!(self.custom_headers)
|
137
|
+
)
|
138
|
+
}
|
139
|
+
else
|
140
|
+
get_time {
|
141
|
+
meth.call(
|
142
|
+
url,
|
143
|
+
self.body,
|
144
|
+
{:accept => self.accept,
|
145
|
+
:content_type => self.content_type,
|
146
|
+
:authorization => self.authorization}.merge!(self.custom_headers)
|
147
|
+
)
|
148
|
+
}
|
149
|
+
end
|
150
|
+
rescue => e
|
151
|
+
self.response = e.response
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
|
146
156
|
def add_expectation attribute, value, comparison = "eq", level = :warn
|
147
157
|
self.expectations.merge! attribute.to_sym => {:compare_using => comparison, :value => value, :level => level}
|
148
158
|
end
|
data/lib/quinoa/version.rb
CHANGED
data/quinoa.gemspec
CHANGED
@@ -21,13 +21,14 @@ Gem::Specification.new do |s|
|
|
21
21
|
|
22
22
|
s.require_paths = ["lib"]
|
23
23
|
|
24
|
-
s.add_development_dependency 'simplecov', '~> 0.
|
25
|
-
s.add_development_dependency '
|
24
|
+
s.add_development_dependency 'simplecov', '~> 0.13.0'
|
25
|
+
s.add_development_dependency 'simplecov-json', '~> 0.2'
|
26
|
+
s.add_development_dependency 'codeclimate-test-reporter', '~> 1.0.5'
|
26
27
|
s.add_development_dependency 'pry', '~> 0.10.4'
|
27
|
-
s.add_development_dependency 'rake', '~>
|
28
|
+
s.add_development_dependency 'rake', '~> 12.0.0'
|
28
29
|
s.add_development_dependency 'nyan-cat-formatter', '~> 0.11'
|
29
30
|
s.add_development_dependency 'cucumber', '~> 2.4.0'
|
30
|
-
s.add_development_dependency 'webmock', '~> 2.
|
31
|
+
s.add_development_dependency 'webmock', '~> 2.3.2'
|
31
32
|
|
32
33
|
s.add_dependency 'rest-client', '~> 2.0.0'
|
33
34
|
s.add_dependency 'rspec', '~> 3.5.0'
|
data/spec/core_spec.rb
CHANGED
@@ -101,7 +101,7 @@ describe Quinoa do
|
|
101
101
|
expect(@service.custom_headers).to eq Hash[:"my-company-custom-header" => "text", :"my-foo-custom-header" => "foo"]
|
102
102
|
end
|
103
103
|
|
104
|
-
["post", "get"].each do |method|
|
104
|
+
["post", "get", "put"].each do |method|
|
105
105
|
it "Should be present in the #{method} requests" do
|
106
106
|
# For this mock order matters
|
107
107
|
stub_request(:any, "http://www.camiloribeiro.com").
|
@@ -133,7 +133,7 @@ describe Quinoa do
|
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
|
-
describe "overwiting the entire url to post
|
136
|
+
describe "overwiting the entire url to post, put get" do
|
137
137
|
|
138
138
|
before(:each) do
|
139
139
|
stub_request(:any, "http://www.bugbang.com.br/foo").
|
@@ -168,6 +168,17 @@ describe Quinoa do
|
|
168
168
|
expect(@service.authorization).to eq "token !#€%&/()="
|
169
169
|
expect(@service.response.code).to eq(200)
|
170
170
|
end
|
171
|
+
|
172
|
+
it "should overwite for put" do
|
173
|
+
@service.put! "http://www.bugbang.com.br/foo"
|
174
|
+
|
175
|
+
# explicity
|
176
|
+
expect(@service.response.headers[:accept]).to eq("application/xml")
|
177
|
+
expect(@service.response.headers[:content_type]).to eq("application/json")
|
178
|
+
expect(@service.response.body).to eq("simple response")
|
179
|
+
expect(@service.authorization).to eq "token !#€%&/()="
|
180
|
+
expect(@service.response.code).to eq(200)
|
181
|
+
end
|
171
182
|
end
|
172
183
|
|
173
184
|
|
@@ -206,6 +217,24 @@ describe Quinoa do
|
|
206
217
|
expect(@service.response_code).to eq(200)
|
207
218
|
end
|
208
219
|
|
220
|
+
it "should put" do
|
221
|
+
@service.put!
|
222
|
+
|
223
|
+
# explicity
|
224
|
+
expect(@service.response.headers[:accept]).to eq("application/xml")
|
225
|
+
expect(@service.response.headers[:content_type]).to eq("application/json")
|
226
|
+
expect(@service.response.body).to eq("simple response")
|
227
|
+
expect(@service.authorization).to eq "token !#€%&/()="
|
228
|
+
expect(@service.response.code).to eq(200)
|
229
|
+
|
230
|
+
# natural
|
231
|
+
expect(@service.response_accept).to eq("application/xml")
|
232
|
+
expect(@service.response_content_type).to eq("application/json")
|
233
|
+
expect(@service.response_body).to eq("simple response")
|
234
|
+
expect(@service.authorization).to eq "token !#€%&/()="
|
235
|
+
expect(@service.response_code).to eq(200)
|
236
|
+
end
|
237
|
+
|
209
238
|
it "should get" do
|
210
239
|
@service.get!
|
211
240
|
|
@@ -261,6 +290,22 @@ describe Quinoa do
|
|
261
290
|
expect(@service.response_code).to eq(code)
|
262
291
|
end
|
263
292
|
|
293
|
+
it "should put" do
|
294
|
+
@service.put!
|
295
|
+
|
296
|
+
# explicity
|
297
|
+
expect(@service.response.headers[:accept]).to eq("application/xml")
|
298
|
+
expect(@service.response.headers[:content_type]).to eq("application/json")
|
299
|
+
expect(@service.response.body).to eq("simple response")
|
300
|
+
expect(@service.response.code).to eq(code)
|
301
|
+
|
302
|
+
# natural
|
303
|
+
expect(@service.response_accept).to eq("application/xml")
|
304
|
+
expect(@service.response_content_type).to eq("application/json")
|
305
|
+
expect(@service.response_body).to eq("simple response")
|
306
|
+
expect(@service.response_code).to eq(code)
|
307
|
+
end
|
308
|
+
|
264
309
|
it "should get" do
|
265
310
|
@service.get!
|
266
311
|
|
@@ -314,6 +359,24 @@ describe Quinoa do
|
|
314
359
|
expect(@service.response_code).to eq(code)
|
315
360
|
end
|
316
361
|
|
362
|
+
it "should put" do
|
363
|
+
@service.put!
|
364
|
+
|
365
|
+
# explicity
|
366
|
+
expect(@service.response.headers[:accept]).to eq("application/xml")
|
367
|
+
expect(@service.response.headers[:content_type]).to eq("application/json")
|
368
|
+
expect(@service.response.body).to eq("simple response")
|
369
|
+
expect(@service.response.headers[:location]).to eq("http://www.bugbang.com.br")
|
370
|
+
expect(@service.response.code).to eq(code)
|
371
|
+
|
372
|
+
# natural
|
373
|
+
expect(@service.response_accept).to eq("application/xml")
|
374
|
+
expect(@service.response_content_type).to eq("application/json")
|
375
|
+
expect(@service.response_body).to eq("simple response")
|
376
|
+
expect(@service.response_location).to eq("http://www.bugbang.com.br")
|
377
|
+
expect(@service.response_code).to eq(code)
|
378
|
+
end
|
379
|
+
|
317
380
|
it "should get" do
|
318
381
|
|
319
382
|
@service.get!
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quinoa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Camilo Ribeiro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simplecov
|
@@ -16,28 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.13.0
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.13.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: simplecov-json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.2'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.2'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: codeclimate-test-reporter
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
47
|
+
version: 1.0.5
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
54
|
+
version: 1.0.5
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: pry
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +72,14 @@ dependencies:
|
|
58
72
|
requirements:
|
59
73
|
- - "~>"
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
75
|
+
version: 12.0.0
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
82
|
+
version: 12.0.0
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: nyan-cat-formatter
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +114,14 @@ dependencies:
|
|
100
114
|
requirements:
|
101
115
|
- - "~>"
|
102
116
|
- !ruby/object:Gem::Version
|
103
|
-
version: 2.
|
117
|
+
version: 2.3.2
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
122
|
- - "~>"
|
109
123
|
- !ruby/object:Gem::Version
|
110
|
-
version: 2.
|
124
|
+
version: 2.3.2
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: rest-client
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|