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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c2fe4aa6f29a8902dc28650c5e2d57a77630b158
4
- data.tar.gz: fa83ee36c23422c4dcced0eb075b9fd0def7337f
3
+ metadata.gz: 7710140c55e76a722ab58ac7354b4ee9e5bb4ef6
4
+ data.tar.gz: fea94528de65f030c24a3c1797cfa5b332e8479d
5
5
  SHA512:
6
- metadata.gz: 16102bf66655b3dd12cb445d85042863e5878a509245a3508eeb82b2758baba354918f94eb8c01019205d4318d73e8c25c5230fd46235289b718e61f20bdead6
7
- data.tar.gz: c6ea274f7d9cfc3f5a83c70555bd22a57c856ab4a555c6d520d4af39ce5cbf0f07e06a8c08703a78d6ced50b402bb6a33c2b57ff6103c24ed4ba4dc9e7164bc8
6
+ metadata.gz: e15d0f50faca93c5a41e1e22c083cae64fe76432b5766f742f982269e679ed957e5fbd67c45342320b3a4bc4e9938ef3d86e1a1a58b52035207c5e4c1bb95b5b
7
+ data.tar.gz: 96ea0deed3c470ffae9e0392d1ff1acd81a9e75fe79212577c715463db24cb6f1280b24a86e7f099577c21ccb2fda3ea7936ad26ef079387faeff4bcf79001fb
@@ -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]
@@ -1,3 +1,3 @@
1
1
  module OptimusPrime
2
- VERSION = "3.0.1"
2
+ VERSION = "3.1.0"
3
3
  end
@@ -10274,3 +10274,16 @@ Listening on 0.0.0.0:7003, CTRL+C to stop
10274
10274
  => 80: end
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.1
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-21 00:00:00.000000000 Z
11
+ date: 2014-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler