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 +4 -4
- data/lib/servme/stubber.rb +13 -1
- data/lib/servme/version.rb +1 -1
- data/spec/lib/servme/service_stubbing_spec.rb +13 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 424bbe9aa28cf64087e0b9371b948857e7c91f19
|
4
|
+
data.tar.gz: ccb5dd643593c7a52400701f46d01bde4ed8b718
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f63c77e8cba2797ed526b71c346f933ba6a1273d742e2997e9012ff0221ea68a9d7b250078667854d07b64f78f666570193488da9b50175b9e098dc34a0e6fff
|
7
|
+
data.tar.gz: 2b442e69eebc2abcc13071cf91111a27f3a32b61548f0a987e168fdf1d77faeec310221bf3855e1cee9e008d6f443b5edf0b0ffc417829e2021a76e43ee54ebe
|
data/lib/servme/stubber.rb
CHANGED
@@ -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 =>
|
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
|
data/lib/servme/version.rb
CHANGED
@@ -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.
|
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:
|
11
|
+
date: 2014-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|