servme 0.1.1 → 0.2.0

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: 1d935b7679782e29a83c4f21bbe7e378247a4ccf
4
- data.tar.gz: f19b3ecc4294ddd56e56ea6872f4e5447a7db798
3
+ metadata.gz: 424bbe9aa28cf64087e0b9371b948857e7c91f19
4
+ data.tar.gz: ccb5dd643593c7a52400701f46d01bde4ed8b718
5
5
  SHA512:
6
- metadata.gz: 596ba826c0b4f03f0ae2d5005e501aac204c39679e6d729756da4cad6e9fbd6478c32da30437dc2e00f3423cc9b4510b85a4fb8c5cfe055f48011e40139b86e3
7
- data.tar.gz: d0c2063852e880e307ec2d3433f424202758823297d6df8dd725fc31baf2704bf924542aa7f323201e280bdaae1a7565aa3b85fb1bcae3fa48022c2c8af88793
6
+ metadata.gz: f63c77e8cba2797ed526b71c346f933ba6a1273d742e2997e9012ff0221ea68a9d7b250078667854d07b64f78f666570193488da9b50175b9e098dc34a0e6fff
7
+ data.tar.gz: 2b442e69eebc2abcc13071cf91111a27f3a32b61548f0a987e168fdf1d77faeec310221bf3855e1cee9e008d6f443b5edf0b0ffc417829e2021a76e43ee54ebe
@@ -16,13 +16,25 @@ module Servme
16
16
  (urls[config[:method] || :get] ||= {}).tap do |methods|
17
17
  methods[stringify_keys(config[:params] || {})] = {
18
18
  :data => config[:response],
19
- :headers => Responder::DEFAULT_HEADERS.merge(config[:headers] || {}),
19
+ :headers => get_headers(config),
20
20
  :status_code => config[:status_code] || 200
21
21
  }
22
22
  end
23
23
  end
24
24
  end
25
25
 
26
+ def get_headers(config)
27
+ response = config[:response]
28
+
29
+ headers = if response.is_a?(Hash)
30
+ response.delete(:headers)
31
+ end || {}
32
+
33
+ headers.merge!(config[:headers] || {})
34
+
35
+ Responder::DEFAULT_HEADERS.merge(headers)
36
+ end
37
+
26
38
  def stub_for_request(req)
27
39
  method = req.request_method.downcase.to_sym
28
40
  begin
@@ -1,3 +1,3 @@
1
1
  module Servme
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -111,5 +111,18 @@ module Servme
111
111
  Then { last_response.headers['Content-Type'].should == "application/html" }
112
112
  end
113
113
 
114
+ describe "passing in another header option" do
115
+ Given do
116
+ ServiceStubbing.new({
117
+ :url => "/index",
118
+ :method => :get,
119
+ }).respond_with({:body => 'check out my body!', :headers => {'set-cookie' => 'logged_in=true'}})
120
+ end
121
+ When { get('/index') }
122
+ Then { last_response.body.should be_json :body => "check out my body!" }
123
+ Then { last_response.headers['set-cookie'].should == 'logged_in=true' }
124
+
125
+ end
126
+
114
127
  end
115
128
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Searls
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-26 00:00:00.000000000 Z
11
+ date: 2014-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json