quinoa 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/changelog +4 -0
- data/lib/quinoa/service.rb +2 -2
- data/lib/quinoa/version.rb +1 -1
- data/spec/service_object_spec.rb +47 -12
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ea50a27ad7bf9f9dbd190b0bb56a6c707e893f6
|
4
|
+
data.tar.gz: a7a6a5fb29923528ee4d247c49439896843ab065
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b18f5076b5e18a736106519e417d6dd4928cca22617c9280e527ca1d85de19d95d590e17e4d96dab43f8d5c6fa8b3a2002b062e20f6da7516e92080412f949d
|
7
|
+
data.tar.gz: 8301e4d16abde0584e2212310bf5396bed4f64ee6afe85e5763b292b4321e3fe48de2cd0e075764c98670e7502036308142595b0cb51fb4543d14aaa5bc7ea85
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
quinoa (0.0.
|
4
|
+
quinoa (0.0.7)
|
5
5
|
rest-client (~> 1.8.0)
|
6
6
|
rspec (~> 3.3.0)
|
7
7
|
|
@@ -23,7 +23,7 @@ GEM
|
|
23
23
|
term-ansicolor (>= 1.0.5)
|
24
24
|
diff-lcs (1.2.5)
|
25
25
|
docile (1.1.5)
|
26
|
-
domain_name (0.5.
|
26
|
+
domain_name (0.5.25)
|
27
27
|
unf (>= 0.0.5, < 1.0.0)
|
28
28
|
gherkin (2.4.21)
|
29
29
|
json (>= 1.4.6)
|
@@ -31,8 +31,8 @@ GEM
|
|
31
31
|
domain_name (~> 0.5)
|
32
32
|
json (1.8.3)
|
33
33
|
method_source (0.8.2)
|
34
|
-
mime-types (2.
|
35
|
-
netrc (0.
|
34
|
+
mime-types (2.99)
|
35
|
+
netrc (0.11.0)
|
36
36
|
nyan-cat-formatter (0.11)
|
37
37
|
rspec (>= 2.99, >= 2.14.2, < 4)
|
38
38
|
pry (0.10.1)
|
data/changelog
CHANGED
data/lib/quinoa/service.rb
CHANGED
@@ -27,9 +27,9 @@ module Quinoa
|
|
27
27
|
def get! url=nil
|
28
28
|
begin
|
29
29
|
if url == nil
|
30
|
-
self.response = RestClient.get self.url + self.path, :accept => self.accept, :authorization => self.authorization
|
30
|
+
self.response = RestClient.get self.url + self.path, {:accept => self.accept, :authorization => self.authorization}.merge!(self.custom_headers)
|
31
31
|
else
|
32
|
-
self.response = RestClient.get url, :accept => self.accept, :authorization => self.authorization
|
32
|
+
self.response = RestClient.get url, {:accept => self.accept, :authorization => self.authorization}.merge!(self.custom_headers)
|
33
33
|
end
|
34
34
|
rescue => e
|
35
35
|
self.response = e.response
|
data/lib/quinoa/version.rb
CHANGED
data/spec/service_object_spec.rb
CHANGED
@@ -39,23 +39,57 @@ describe Quinoa do
|
|
39
39
|
@service.body = "text"
|
40
40
|
expect(@service.body).to eq "text"
|
41
41
|
end
|
42
|
+
|
43
|
+
describe "Custom headers" do
|
42
44
|
|
43
|
-
|
44
|
-
expect(@service.custom_headers).to eq Hash[]
|
45
|
+
it "Should be able to add a single custom header" do
|
45
46
|
|
46
|
-
|
47
|
-
expect(@service.custom_headers).to eq Hash[:"my-company-custom-header" => "text"]
|
48
|
-
end
|
47
|
+
expect(@service.custom_headers).to eq Hash[]
|
49
48
|
|
50
|
-
|
51
|
-
|
49
|
+
@service.add_custom_header "my-company-custom-header", "text"
|
50
|
+
expect(@service.custom_headers).to eq Hash[:"my-company-custom-header" => "text"]
|
51
|
+
end
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
53
|
+
it "Should be able to add many custom headers" do
|
54
|
+
expect(@service.custom_headers).to eq Hash[]
|
55
|
+
|
56
|
+
@service.add_custom_header "my-company-custom-header", "text"
|
57
|
+
@service.add_custom_header "headerx", "bar"
|
58
|
+
@service.add_custom_header :"my-foo-custom-header", "foo"
|
59
|
+
|
60
|
+
expect(@service.custom_headers).to eq Hash[:"my-company-custom-header" => "text", :headerx => "bar", :"my-foo-custom-header" => "foo"]
|
61
|
+
end
|
62
|
+
|
63
|
+
["post", "get"].each do |method|
|
64
|
+
it "Should be present in the #{method} requests" do
|
65
|
+
# For this mock order matters
|
66
|
+
stub_request(:any, "http://www.camiloribeiro.com").
|
67
|
+
to_return(:status => 200, :body => "This request requires a 'my-company-custom-header' to work")
|
68
|
+
|
69
|
+
stub_request(:any, "http://www.camiloribeiro.com").
|
70
|
+
with(:headers => { 'my-company-custom-header' => "text" }).
|
71
|
+
to_return(:status => 200, :body => "This request works fine")
|
72
|
+
|
73
|
+
@other_service = Quinoa::Service.new "http://www.camiloribeiro.com"
|
58
74
|
|
75
|
+
expect(@service.custom_headers).to eq Hash[]
|
76
|
+
expect(@other_service.custom_headers).to eq Hash[]
|
77
|
+
|
78
|
+
@service.add_custom_header "my-company-custom-header", "text"
|
79
|
+
@service.add_custom_header "headerx", "bar"
|
80
|
+
@service.add_custom_header :"my-foo-custom-header", "foo"
|
81
|
+
|
82
|
+
expect(@service.custom_headers).to eq Hash[:"my-company-custom-header" => "text", :headerx => "bar", :"my-foo-custom-header" => "foo"]
|
83
|
+
expect(@other_service.custom_headers).to eq Hash[]
|
84
|
+
|
85
|
+
@service.send "#{method}!"
|
86
|
+
@other_service.send "#{method}!"
|
87
|
+
|
88
|
+
expect(@service.response.body).to eq("This request works fine")
|
89
|
+
expect(@other_service.response.body).to eq("This request requires a 'my-company-custom-header' to work")
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
59
93
|
end
|
60
94
|
|
61
95
|
describe "overwiting the entire url to post and get" do
|
@@ -240,6 +274,7 @@ describe Quinoa do
|
|
240
274
|
end
|
241
275
|
|
242
276
|
it "should get" do
|
277
|
+
|
243
278
|
@service.get!
|
244
279
|
|
245
280
|
# explicity
|