rest_shifter 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +4 -0
- data/lib/rest_shifter/commands/create.rb +2 -1
- data/lib/rest_shifter/commands/main.rb +4 -6
- data/lib/rest_shifter/shifter.rb +2 -0
- data/lib/rest_shifter/version.rb +1 -1
- data/spec/flavors/location_get.flavor +9 -0
- data/spec/flavors/location_post.flavor +9 -0
- data/spec/flavors/notfound_get.flavor +1 -0
- data/spec/flavors/notfound_get_accept.flavor +1 -0
- data/spec/flavors/notfound_post.flavor +1 -0
- data/spec/flavors/notfound_post_accept.flavor +1 -0
- data/spec/flavors/sleep_get.flavor +1 -0
- data/spec/flavors/sleep_post.flavor +1 -0
- data/spec/flavors/success_delete.flavor +1 -0
- data/spec/flavors/success_get.flavor +1 -0
- data/spec/flavors/success_post.flavor +1 -0
- data/spec/flavors/success_put.flavor +1 -0
- data/spec/service_spec.rb +32 -14
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ce74ac48d14e2bccaa1aaa7ca8f0538f44158db
|
4
|
+
data.tar.gz: f6d0a5b1de3931a0c3e4ea028e25fe18c2722cb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 872091083cb523758a40f6795466519fad06b40c5c92b02ecc5fb872bc1f63c56b5ee2d3608a8a76dae2a97995fbb2250527f8ae12a308dd0e2ff52cec60e087
|
7
|
+
data.tar.gz: 2eb1d413adc9656b68718644ccf6bfa126b5e7dce5bb8bd43831a1eaa15b11895de29ab11cb59abe99d5210620aa259385b5dd2b6ec9910dd8f1f013bf0c2a75
|
data/CHANGES
CHANGED
@@ -14,7 +14,8 @@ request_content_type = ""
|
|
14
14
|
response_sleep = 0
|
15
15
|
response_status = "200"
|
16
16
|
response_body = "{ \"hello_world\" : \"Your service is working fine. :D\" }"
|
17
|
-
response_content_type = "application/json"
|
17
|
+
response_content_type = "application/json"
|
18
|
+
response_location = ""') }
|
18
19
|
end
|
19
20
|
end
|
20
21
|
end
|
@@ -7,12 +7,10 @@ class RestShifter::Commands::Main
|
|
7
7
|
|
8
8
|
case cmd
|
9
9
|
when "-s", "--start", "start"
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
RestShifter::Commands::Start.run "8080"
|
15
|
-
end
|
10
|
+
port = args.shift
|
11
|
+
port = "8080" unless !port.to_s.empty?
|
12
|
+
RestShifter::Commands::Start.run port
|
13
|
+
exit 0
|
16
14
|
when "-S", "--start-secure", "start-secure"
|
17
15
|
RestShifter::Commands::Start.run_secure
|
18
16
|
exit 0
|
data/lib/rest_shifter/shifter.rb
CHANGED
@@ -38,6 +38,7 @@ class Shifter < Sinatra::Base
|
|
38
38
|
operation.each do |service|
|
39
39
|
if service.request_accept.to_s == ''
|
40
40
|
send(service.method_used.to_sym, service.path) do
|
41
|
+
response['Location'] = service.response_location unless service.response_location.to_s.empty?
|
41
42
|
sleep service.response_sleep
|
42
43
|
status service.response_status
|
43
44
|
content_type service.response_content_type
|
@@ -45,6 +46,7 @@ class Shifter < Sinatra::Base
|
|
45
46
|
end
|
46
47
|
else
|
47
48
|
send(service.method_used.to_sym, service.path, :provides => service.request_accept.to_s == '' ? "" : service.request_accept) do
|
49
|
+
response['Location'] = service.response_location unless service.response_location.to_s.empty?
|
48
50
|
sleep service.response_sleep
|
49
51
|
status service.response_status
|
50
52
|
content_type service.response_content_type
|
data/lib/rest_shifter/version.rb
CHANGED
@@ -0,0 +1,9 @@
|
|
1
|
+
method_used = "post"
|
2
|
+
path = "/location"
|
3
|
+
request_accept = ""
|
4
|
+
request_content_type = ""
|
5
|
+
response_sleep = 0
|
6
|
+
response_status = "200"
|
7
|
+
response_body = "success"
|
8
|
+
response_content_type = "application/json"
|
9
|
+
response_location = "http://www.camiloribeiro.com"
|
data/spec/service_spec.rb
CHANGED
@@ -91,21 +91,39 @@ describe RestShifter do
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
describe "Special behaviours" do
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
94
|
+
describe "Slowliness for timeouts" do
|
95
|
+
it "GET: Service should sleep for a second" do
|
96
|
+
time = Time.now
|
97
|
+
get '/sleep'
|
98
|
+
expect(Time.now - time).to be > 1
|
99
|
+
expect(last_response.status).to eq(200)
|
100
|
+
expect(last_response.body).to eq("This should sleep for one second")
|
101
|
+
expect(last_response.headers['Content-Type']).to eq("application/json")
|
102
|
+
end
|
103
|
+
it "POST: Service should sleep for a second" do
|
104
|
+
time = Time.now
|
105
|
+
post '/sleep'
|
106
|
+
expect(Time.now - time).to be > 1
|
107
|
+
expect(last_response.status).to eq(200)
|
108
|
+
expect(last_response.body).to eq("This should sleep for one second")
|
109
|
+
expect(last_response.headers['Content-Type']).to eq("application/json")
|
110
|
+
end
|
101
111
|
end
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
112
|
+
describe "Return location header" do
|
113
|
+
it "POST: Service should return location when specified" do
|
114
|
+
time = Time.now
|
115
|
+
post '/location'
|
116
|
+
expect(last_response.status).to eq(200)
|
117
|
+
expect(last_response.location).to eq("http://www.camiloribeiro.com")
|
118
|
+
expect(last_response.headers['Content-Type']).to eq("application/json")
|
119
|
+
end
|
120
|
+
it "GET: Service should return location when specified" do
|
121
|
+
time = Time.now
|
122
|
+
get '/location'
|
123
|
+
expect(last_response.status).to eq(200)
|
124
|
+
expect(last_response.location).to eq("http://www.camiloribeiro.com")
|
125
|
+
expect(last_response.headers['Content-Type']).to eq("application/json")
|
126
|
+
end
|
109
127
|
end
|
110
128
|
end
|
111
129
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest_shifter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Camilo Ribeiro
|
@@ -193,6 +193,8 @@ files:
|
|
193
193
|
- lib/rest_shifter/ssl_helper.rb
|
194
194
|
- lib/rest_shifter/version.rb
|
195
195
|
- rest_shifter.gemspec
|
196
|
+
- spec/flavors/location_get.flavor
|
197
|
+
- spec/flavors/location_post.flavor
|
196
198
|
- spec/flavors/notfound_get.flavor
|
197
199
|
- spec/flavors/notfound_get_accept.flavor
|
198
200
|
- spec/flavors/notfound_post.flavor
|
@@ -230,6 +232,8 @@ signing_key:
|
|
230
232
|
specification_version: 4
|
231
233
|
summary: Simple Rest Mock service
|
232
234
|
test_files:
|
235
|
+
- spec/flavors/location_get.flavor
|
236
|
+
- spec/flavors/location_post.flavor
|
233
237
|
- spec/flavors/notfound_get.flavor
|
234
238
|
- spec/flavors/notfound_get_accept.flavor
|
235
239
|
- spec/flavors/notfound_post.flavor
|