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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e9e2963793d9613b5cd69cbbcccc993a788b291
4
- data.tar.gz: f5f189e9874bb3d49355467f39a2f1b0fa55e504
3
+ metadata.gz: 2ea50a27ad7bf9f9dbd190b0bb56a6c707e893f6
4
+ data.tar.gz: a7a6a5fb29923528ee4d247c49439896843ab065
5
5
  SHA512:
6
- metadata.gz: 7c702d708f6ca12a1627c2067e46ddf5b2b9f9e69238e5721a51a800ee40ad67b10f3399e71cd3b4cbb8ab4dafa99d784c1334716d8186616fcb231f20d4fd8b
7
- data.tar.gz: 30a42aeb7558abe4bd63a96f2867d352f0c9556c7c203ef4a8f4482ec2ba55385a3a70b27eeaad7b7ac7393092c3a6c738583c5f13c965f1cd4aeebca7b0c112
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.6)
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.24)
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.6.1)
35
- netrc (0.10.3)
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
@@ -1,3 +1,7 @@
1
+ 0.0.8: Adding support to custom headers also to get requests
2
+ - Now you can send custom headers in the get requests
3
+ - Imporving tests for custom headers
4
+
1
5
  0.0.7: Adding support to custom headers
2
6
  - Now you can send custom headers in the requests
3
7
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Quinoa
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -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
- it "Should be able to add a single custom header" do
44
- expect(@service.custom_headers).to eq Hash[]
45
+ it "Should be able to add a single custom header" do
45
46
 
46
- @service.add_custom_header :"my-company-custom-header", "text"
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
- it "Should be able to add many custom headers" do
51
- expect(@service.custom_headers).to eq Hash[]
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
- @service.add_custom_header "my-company-custom-header", "text"
54
- @service.add_custom_header "headerx", "bar"
55
- @service.add_custom_header :"my-foo-custom-header", "foo"
56
- expect(@service.custom_headers).to eq Hash[:"my-company-custom-header" => "text", :headerx => "bar", :"my-foo-custom-header" => "foo"]
57
- end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quinoa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Camilo Ribeiro