optimus_prime 3.0.1 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/optimus_prime/server.rb +26 -0
- data/lib/optimus_prime/version.rb +1 -1
- data/optimus_prime.log +13 -0
- data/spec/lib/optimus_prime_spec.rb +7 -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: 7710140c55e76a722ab58ac7354b4ee9e5bb4ef6
|
4
|
+
data.tar.gz: fea94528de65f030c24a3c1797cfa5b332e8479d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e15d0f50faca93c5a41e1e22c083cae64fe76432b5766f742f982269e679ed957e5fbd67c45342320b3a4bc4e9938ef3d86e1a1a58b52035207c5e4c1bb95b5b
|
7
|
+
data.tar.gz: 96ea0deed3c470ffae9e0392d1ff1acd81a9e75fe79212577c715463db24cb6f1280b24a86e7f099577c21ccb2fda3ea7936ad26ef079387faeff4bcf79001fb
|
data/lib/optimus_prime/server.rb
CHANGED
@@ -17,6 +17,32 @@ module OptimusPrime
|
|
17
17
|
@@requests ||= {}
|
18
18
|
@@not_primed ||= {}
|
19
19
|
|
20
|
+
patch "/get/*" do
|
21
|
+
path = get_path
|
22
|
+
response = responses[path]
|
23
|
+
|
24
|
+
if response.nil?
|
25
|
+
@@not_primed[path] = { time: Time.now.to_s, HTTP_METHOD: env["REQUEST_METHOD"] }
|
26
|
+
return 404
|
27
|
+
end
|
28
|
+
|
29
|
+
if response[:requested_with]
|
30
|
+
request.body.rewind
|
31
|
+
return 404 unless eval("request.body.read.include?('#{response[:requested_with]}')")
|
32
|
+
end
|
33
|
+
|
34
|
+
sleep(response[:sleep].to_i) if response[:sleep]
|
35
|
+
|
36
|
+
if response[:persisted]
|
37
|
+
new_body = request.body.read
|
38
|
+
@@responses[path][:body] = JSON.parse(response[:body]).merge!(JSON.parse(new_body)).to_json
|
39
|
+
end
|
40
|
+
|
41
|
+
record_request(path)
|
42
|
+
content_type(response[:content_type])
|
43
|
+
status(response[:status_code] || 201)
|
44
|
+
end
|
45
|
+
|
20
46
|
put "/get/*" do
|
21
47
|
path = get_path
|
22
48
|
response = responses[path]
|
data/optimus_prime.log
CHANGED
@@ -10274,3 +10274,16 @@ Listening on 0.0.0.0:7003, CTRL+C to stop
|
|
10274
10274
|
=> [1;34m80[0m: [32mend[0m
|
10275
10275
|
|
10276
10276
|
[1] pry(#<OptimusPrime::Server>)>
|
10277
|
+
Writing PID to /Users/acnalesso/dev/optimus_prime/tmp/pids/optimus_prime.pid
|
10278
|
+
Using rack adapter
|
10279
|
+
Thin web server (v1.6.2 codename Doc Brown)
|
10280
|
+
Debugging ON
|
10281
|
+
Maximum connections set to 1024
|
10282
|
+
Listening on 0.0.0.0:7003, CTRL+C to stop
|
10283
|
+
Exiting!
|
10284
|
+
Writing PID to /Users/acnalesso/dev/optimus_prime/tmp/pids/optimus_prime.pid
|
10285
|
+
Using rack adapter
|
10286
|
+
Thin web server (v1.6.2 codename Doc Brown)
|
10287
|
+
Debugging ON
|
10288
|
+
Maximum connections set to 1024
|
10289
|
+
Listening on 0.0.0.0:7003, CTRL+C to stop
|
@@ -57,6 +57,13 @@ describe OptimusPrime do
|
|
57
57
|
expect( response.status ).to eq 200
|
58
58
|
end
|
59
59
|
|
60
|
+
it "supports patch request methods" do
|
61
|
+
op.prime("patch", { username: "Test" }.to_json, content_type: :json, persisted: true)
|
62
|
+
::Faraday.patch('http://localhost:7003/get/patch', { username: "Changed" }.to_json)
|
63
|
+
response = ::Faraday.get('http://localhost:7003/get/patch')
|
64
|
+
|
65
|
+
expect( response.body ).to include("Changed")
|
66
|
+
end
|
60
67
|
|
61
68
|
context "Asserting on request content" do
|
62
69
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: optimus_prime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Antonio Nalesso
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|