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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 57ef6f8c36894669e923fa5a2b9ea28e62229c36
4
- data.tar.gz: 4b7b9a41dbc0c3ceccf8e3fe9bb567dd1173222e
3
+ metadata.gz: 7ce74ac48d14e2bccaa1aaa7ca8f0538f44158db
4
+ data.tar.gz: f6d0a5b1de3931a0c3e4ea028e25fe18c2722cb2
5
5
  SHA512:
6
- metadata.gz: 81365f67f546c8faa6e4e4df0f3b5eab136a9ad03781eb8edf5fa1bf6d958056f7160fd4ba1cf572c24250a86744bf20ae1a63aac46dec67ef726411b6f2dae5
7
- data.tar.gz: 049b1ac727aac5c0aa5490f024bb06bf1dd17fa3a95c5a2a158aa350245afbfcecd186cf76f3b446a2ee31a994b164665033ce2906a42c00ac8dc84b7064415a
6
+ metadata.gz: 872091083cb523758a40f6795466519fad06b40c5c92b02ecc5fb872bc1f63c56b5ee2d3608a8a76dae2a97995fbb2250527f8ae12a308dd0e2ff52cec60e087
7
+ data.tar.gz: 2eb1d413adc9656b68718644ccf6bfa126b5e7dce5bb8bd43831a1eaa15b11895de29ab11cb59abe99d5210620aa259385b5dd2b6ec9910dd8f1f013bf0c2a75
data/CHANGES CHANGED
@@ -1,4 +1,8 @@
1
1
 
2
+ ** 0.0.16
3
+ - Feature
4
+ -- Adding support to location header
5
+
2
6
  ** 0.0.15
3
7
  - Feature
4
8
  -- Adding support to run from external machines
@@ -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
- cmd = args.shift
11
- if !cmd.to_s.empty?
12
- RestShifter::Commands::Start.run cmd
13
- else
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module RestShifter
2
- VERSION = "0.0.15"
2
+ VERSION = "0.0.16"
3
3
  end
@@ -0,0 +1,9 @@
1
+ method_used = "get"
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"
@@ -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"
@@ -6,3 +6,4 @@ response_sleep = 0
6
6
  response_status = "201"
7
7
  response_body = "This is just a text"
8
8
  response_content_type = "text/plain"
9
+ response_location = ""
@@ -6,3 +6,4 @@ response_sleep = 0
6
6
  response_status = "200"
7
7
  response_body = "Found"
8
8
  response_content_type = "application/json"
9
+ response_location = ""
@@ -6,3 +6,4 @@ response_sleep = 0
6
6
  response_status = "201"
7
7
  response_body = "This is just a text"
8
8
  response_content_type = "text/plain"
9
+ response_location = ""
@@ -6,3 +6,4 @@ response_sleep = 0
6
6
  response_status = "200"
7
7
  response_body = "Found"
8
8
  response_content_type = "application/json"
9
+ response_location = ""
@@ -6,3 +6,4 @@ response_sleep = 1
6
6
  response_status = "200"
7
7
  response_body = "This should sleep for one second"
8
8
  response_content_type = "application/json"
9
+ response_location = ""
@@ -6,3 +6,4 @@ response_sleep = 1
6
6
  response_status = "200"
7
7
  response_body = "This should sleep for one second"
8
8
  response_content_type = "application/json"
9
+ response_location = ""
@@ -6,3 +6,4 @@ response_sleep = 0
6
6
  response_status = "200"
7
7
  response_body = "delete success"
8
8
  response_content_type = "application/json"
9
+ response_location = ""
@@ -20,3 +20,4 @@ response_sleep = 0
20
20
  response_status = "200"
21
21
  response_body = "success"
22
22
  response_content_type = "application/json"
23
+ response_location = ""
@@ -6,3 +6,4 @@ response_sleep = 0
6
6
  response_status = "200"
7
7
  response_body = "success"
8
8
  response_content_type = "application/json"
9
+ response_location = ""
@@ -6,3 +6,4 @@ response_sleep = 0
6
6
  response_status = "200"
7
7
  response_body = "put success"
8
8
  response_content_type = "application/json"
9
+ response_location = ""
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
- it "GET: Service should sleep for a second" do
95
- time = Time.now
96
- get '/sleep'
97
- expect(Time.now - time).to be > 1
98
- expect(last_response.status).to eq(200)
99
- expect(last_response.body).to eq("This should sleep for one second")
100
- expect(last_response.headers['Content-Type']).to eq("application/json")
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
- it "POST: Service should sleep for a second" do
103
- time = Time.now
104
- post '/sleep'
105
- expect(Time.now - time).to be > 1
106
- expect(last_response.status).to eq(200)
107
- expect(last_response.body).to eq("This should sleep for one second")
108
- expect(last_response.headers['Content-Type']).to eq("application/json")
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.15
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