optimus_prime 0.2.0 → 1.0.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: ba1a83012d6f90cfd997d9b14d627540fde4748d
4
- data.tar.gz: 60fad1b9d85c06245a57ea46b5e931f71e3502db
3
+ metadata.gz: 5af64dcf1d97cc72f361c73e99d6ca751cada381
4
+ data.tar.gz: df394a539bce898a440faeba0fd8cad99578580a
5
5
  SHA512:
6
- metadata.gz: 45ae1393325e37b22fc003048b371e71571a1758db5d15f6f9bf12a8f4a811d106c164d530670cac0606f7d024f9a8ecfc04bae8feb864a1603e47fe94c535f1
7
- data.tar.gz: ae9c6d64e7f25dde83975cdf92ec7374785ffc3ad746a32471378f4c1837897e659123d154d3ef290ef3e135fcfe593682092f257edff256b5c88590d026e819
6
+ metadata.gz: aa7e5241638d58b0587b4d357bcf3154cc18344bf02f3ccb88ef0a43c7c7bf56a21802fdf30333cbd98f56eab55e1f71ea892be693f5e303defa4c4147ea81b7
7
+ data.tar.gz: 18b6aaf213bc6faf2c8c1c806d63bec0844ea8d80c3c0e23a8bca0eb863fcf1c0be69ea426ad97a0514b9104857fcd07b26bf1cf503c6dedcd76ec0ba4b88374
data/README.md CHANGED
@@ -22,7 +22,8 @@ OptimusPrime allows developers to persist fake date and tell their API to talk
22
22
  to it and get the desired response.
23
23
 
24
24
  ## Default configuration
25
- * localhost:7002/get -> default endpoint
25
+ * localhost:7002 -> default endpoint
26
+ * localhost:7003 -> TEST default endpoint
26
27
  * returns 200 status code for GET,POST
27
28
  * sets content-type to text
28
29
 
@@ -37,6 +38,13 @@ op = OptimusPrime::Base.new
37
38
  op.prime("path_name", response, options)
38
39
  ```
39
40
 
41
+ changing port number:
42
+ ```ruby
43
+ OptimusPrime.start_server(port: 9292)
44
+ op = OptimusPrime::Base.new
45
+ op.prime("path_name", response, options)
46
+ ```
47
+
40
48
  ## GET requests:
41
49
  ```ruby
42
50
  op.prime("users", " response... ", status_code: 200)
data/lib/optimus_prime.rb CHANGED
@@ -3,16 +3,21 @@ require "optimus_prime/server"
3
3
 
4
4
  module OptimusPrime
5
5
 
6
+ @@op_port = 7002
7
+ def self.op_port; @@op_port; end
8
+
6
9
  def self.restart_server
7
10
  self.stop_server
8
11
  self.start_server
9
12
  end
10
13
 
11
- def self.start_server
14
+ def self.start_server(options={})
15
+ @@op_port = ENV["OP.ENV"] == "test" ? 7003 : options[:port]
16
+
12
17
  `mkdir -p ./tmp/pids`
13
18
  return `echo 'Optimus is already priming :)'` if system("ls ./tmp/pids/optimus_prime.pid")
14
19
  path = `pwd`.chomp
15
- if system("cd #{optimus_prime_path} && echo '\nStarting Optimus Prime\n' && thin start -p 7002 -P #{path}/tmp/pids/optimus_prime.pid -l #{path}/optimus_prime.log -d -D")
20
+ if system("cd #{optimus_prime_path} && echo '\nStarting Optimus Prime\n' && thin start -p #{op_port} -P #{path}/tmp/pids/optimus_prime.pid -l #{path}/optimus_prime.log -d -D")
16
21
  while :starting_server
17
22
  sleep(2) and break if `ls ./tmp/pids`.include?("optimus_prime.pid")
18
23
  end
@@ -37,11 +42,11 @@ module OptimusPrime
37
42
  class Base
38
43
 
39
44
  def prime(path_name, response="", options={})
40
- ::Faraday.post("http://localhost:7002/prime", { path_name: path_name, response: response }.merge!(options))
45
+ ::Faraday.post("http://localhost:#{OptimusPrime.op_port}/prime", { path_name: path_name, response: response }.merge!(options))
41
46
  end
42
47
 
43
48
  def clear!
44
- ::Faraday.get("http://localhost:7002/clear")
49
+ ::Faraday.get("http://localhost:#{OptimusPrime.op_port}/clear")
45
50
  end
46
51
 
47
52
  end
@@ -9,8 +9,9 @@ module OptimusPrime
9
9
  set :public_folder, __dir__ + "/server/public"
10
10
 
11
11
  put "/get/*" do
12
- path = self.env["REQUEST_URI"].sub("/get/", "")
12
+ path = get_path
13
13
  response = responses[path]
14
+
14
15
  return 404 if response.nil?
15
16
 
16
17
  if response[:requested_with]
@@ -28,7 +29,7 @@ module OptimusPrime
28
29
  end
29
30
 
30
31
  post "/get/*" do
31
- path = self.env["REQUEST_URI"].sub("/get/", "")
32
+ path = get_path
32
33
  response = responses[path]
33
34
  return 404 if response.nil?
34
35
 
@@ -48,14 +49,13 @@ module OptimusPrime
48
49
  response[:body]
49
50
  end
50
51
 
51
- def get_response
52
- path = self.env["REQUEST_URI"].sub("/get/", "")
53
- responses[path]
52
+ def get_path
53
+ self.env["REQUEST_URI"].scan(/^\/get\/([\/\w+]+)(\/|\?|$)/).flatten[0]
54
54
  end
55
55
 
56
56
  get "/get/*" do
57
- #path = self.env["REQUEST_URI"].sub("/get/", "")
58
- response = get_response
57
+ path = get_path
58
+ response = responses[path]
59
59
  return 404 if response.nil?
60
60
  sleep(response[:sleep].to_f) if response[:sleep]
61
61
 
@@ -1,3 +1,3 @@
1
1
  module OptimusPrime
2
- VERSION = "0.2.0"
2
+ VERSION = "1.0.0"
3
3
  end
data/optimus_prime.log CHANGED
@@ -2328,3 +2328,430 @@ Thin web server (v1.6.2 codename Doc Brown)
2328
2328
  Debugging ON
2329
2329
  Maximum connections set to 1024
2330
2330
  Listening on 0.0.0.0:7002, CTRL+C to stop
2331
+ Writing PID to /Users/acnalesso/dev/optimus_prime/tmp/pids/optimus_prime.pid
2332
+ Using rack adapter
2333
+ Thin web server (v1.6.2 codename Doc Brown)
2334
+ Debugging ON
2335
+ Maximum connections set to 1024
2336
+ Listening on 0.0.0.0:7002, CTRL+C to stop
2337
+ Exiting!
2338
+ Writing PID to /Users/acnalesso/dev/optimus_prime/tmp/pids/optimus_prime.pid
2339
+ Using rack adapter
2340
+ Thin web server (v1.6.2 codename Doc Brown)
2341
+ Debugging ON
2342
+ Maximum connections set to 1024
2343
+ Listening on 0.0.0.0:7002, CTRL+C to stop
2344
+ Exiting!
2345
+ Writing PID to /Users/acnalesso/dev/optimus_prime/tmp/pids/optimus_prime.pid
2346
+ Using rack adapter
2347
+ Thin web server (v1.6.2 codename Doc Brown)
2348
+ Debugging ON
2349
+ Maximum connections set to 1024
2350
+ Listening on 0.0.0.0:7002, CTRL+C to stop
2351
+ Exiting!
2352
+ Writing PID to /Users/acnalesso/dev/optimus_prime/tmp/pids/optimus_prime.pid
2353
+ Using rack adapter
2354
+ Thin web server (v1.6.2 codename Doc Brown)
2355
+ Debugging ON
2356
+ Maximum connections set to 1024
2357
+ Listening on 0.0.0.0:7003, CTRL+C to stop
2358
+ Exiting!
2359
+ Writing PID to /Users/acnalesso/dev/optimus_prime/tmp/pids/optimus_prime.pid
2360
+ Using rack adapter
2361
+ Thin web server (v1.6.2 codename Doc Brown)
2362
+ Debugging ON
2363
+ Maximum connections set to 1024
2364
+ Listening on 0.0.0.0:7002, CTRL+C to stop
2365
+ Exiting!
2366
+ Writing PID to /Users/acnalesso/dev/optimus_prime/tmp/pids/optimus_prime.pid
2367
+ Using rack adapter
2368
+ Thin web server (v1.6.2 codename Doc Brown)
2369
+ Debugging ON
2370
+ Maximum connections set to 1024
2371
+ Listening on 0.0.0.0:7003, CTRL+C to stop
2372
+ Exiting!
2373
+ Writing PID to /Users/acnalesso/dev/optimus_prime/tmp/pids/optimus_prime.pid
2374
+ Using rack adapter
2375
+ Thin web server (v1.6.2 codename Doc Brown)
2376
+ Debugging ON
2377
+ Maximum connections set to 1024
2378
+ Listening on 0.0.0.0:7002, CTRL+C to stop
2379
+ Exiting!
2380
+ Writing PID to /Users/acnalesso/dev/optimus_prime/tmp/pids/optimus_prime.pid
2381
+ Using rack adapter
2382
+ Thin web server (v1.6.2 codename Doc Brown)
2383
+ Debugging ON
2384
+ Maximum connections set to 1024
2385
+ Listening on 0.0.0.0:7002, CTRL+C to stop
2386
+ Exiting!
2387
+ Writing PID to /Users/acnalesso/dev/optimus_prime/tmp/pids/optimus_prime.pid
2388
+ Using rack adapter
2389
+ Thin web server (v1.6.2 codename Doc Brown)
2390
+ Debugging ON
2391
+ Maximum connections set to 1024
2392
+ Listening on 0.0.0.0:7003, CTRL+C to stop
2393
+ Exiting!
2394
+ Writing PID to /Users/acnalesso/dev/optimus_prime/tmp/pids/optimus_prime.pid
2395
+ Using rack adapter
2396
+ Thin web server (v1.6.2 codename Doc Brown)
2397
+ Debugging ON
2398
+ Maximum connections set to 1024
2399
+ Listening on 0.0.0.0:7003, CTRL+C to stop
2400
+ Exiting!
2401
+ Writing PID to /Users/acnalesso/dev/optimus_prime/tmp/pids/optimus_prime.pid
2402
+ Using rack adapter
2403
+ Thin web server (v1.6.2 codename Doc Brown)
2404
+ Debugging ON
2405
+ Maximum connections set to 1024
2406
+ Listening on 0.0.0.0:7003, CTRL+C to stop
2407
+ Exiting!
2408
+ Writing PID to /Users/acnalesso/dev/optimus_prime/tmp/pids/optimus_prime.pid
2409
+ Using rack adapter
2410
+ Thin web server (v1.6.2 codename Doc Brown)
2411
+ Debugging ON
2412
+ Maximum connections set to 1024
2413
+ Listening on 0.0.0.0:7003, CTRL+C to stop
2414
+ Exiting!
2415
+ Writing PID to /Users/acnalesso/dev/optimus_prime/tmp/pids/optimus_prime.pid
2416
+ Using rack adapter
2417
+ Thin web server (v1.6.2 codename Doc Brown)
2418
+ Debugging ON
2419
+ Maximum connections set to 1024
2420
+ Listening on 0.0.0.0:7003, CTRL+C to stop
2421
+ Exiting!
2422
+ Writing PID to /Users/acnalesso/dev/optimus_prime/tmp/pids/optimus_prime.pid
2423
+ Using rack adapter
2424
+ Thin web server (v1.6.2 codename Doc Brown)
2425
+ Debugging ON
2426
+ Maximum connections set to 1024
2427
+ Listening on 0.0.0.0:7003, CTRL+C to stop
2428
+ Writing PID to /Users/user/dev/optimus_prime/tmp/pids/optimus_prime.pid
2429
+ Using rack adapter
2430
+ Thin web server (v1.6.2 codename Doc Brown)
2431
+ Debugging ON
2432
+ Maximum connections set to 1024
2433
+ Listening on 0.0.0.0:7003, CTRL+C to stop
2434
+ Exiting!
2435
+ Writing PID to /Users/user/dev/optimus_prime/tmp/pids/optimus_prime.pid
2436
+ Using rack adapter
2437
+ Thin web server (v1.6.2 codename Doc Brown)
2438
+ Debugging ON
2439
+ Maximum connections set to 1024
2440
+ Listening on 0.0.0.0:7003, CTRL+C to stop
2441
+ RuntimeError - user:
2442
+ /Users/user/dev/optimus_prime/lib/optimus_prime/server.rb:55:in `get_response'
2443
+ /Users/user/dev/optimus_prime/lib/optimus_prime/server.rb:32:in `block in <class:Server>'
2444
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1603:in `call'
2445
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1603:in `block in compile!'
2446
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `[]'
2447
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `block (3 levels) in route!'
2448
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:985:in `route_eval'
2449
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `block (2 levels) in route!'
2450
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1006:in `block in process_route'
2451
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1004:in `catch'
2452
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1004:in `process_route'
2453
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:964:in `block in route!'
2454
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:963:in `each'
2455
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:963:in `route!'
2456
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1076:in `block in dispatch!'
2457
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `block in invoke'
2458
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `catch'
2459
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `invoke'
2460
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1073:in `dispatch!'
2461
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:898:in `block in call!'
2462
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `block in invoke'
2463
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `catch'
2464
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `invoke'
2465
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:898:in `call!'
2466
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:886:in `call'
2467
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/xss_header.rb:18:in `call'
2468
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/path_traversal.rb:16:in `call'
2469
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/json_csrf.rb:18:in `call'
2470
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
2471
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
2472
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/frame_options.rb:31:in `call'
2473
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-1.5.2/lib/rack/nulllogger.rb:9:in `call'
2474
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-1.5.2/lib/rack/head.rb:11:in `call'
2475
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/show_exceptions.rb:21:in `call'
2476
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:180:in `call'
2477
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:2014:in `call'
2478
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `block in call'
2479
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1788:in `synchronize'
2480
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `call'
2481
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/connection.rb:86:in `block in pre_process'
2482
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/connection.rb:84:in `catch'
2483
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/connection.rb:84:in `pre_process'
2484
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/connection.rb:53:in `process'
2485
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/connection.rb:39:in `receive_data'
2486
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
2487
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
2488
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/backends/base.rb:73:in `start'
2489
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/server.rb:162:in `start'
2490
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/controllers/controller.rb:87:in `start'
2491
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/runner.rb:199:in `run_command'
2492
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/runner.rb:155:in `run!'
2493
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/bin/thin:6:in `<top (required)>'
2494
+ /Users/user/.rvm/gems/ruby-2.1.1/bin/thin:23:in `load'
2495
+ /Users/user/.rvm/gems/ruby-2.1.1/bin/thin:23:in `<main>'
2496
+ /Users/user/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `eval'
2497
+ /Users/user/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `<main>'
2498
+ Waiting for 1 connection(s) to finish, can take up to 30 sec, CTRL+C to stop now
2499
+ Exiting!
2500
+ Writing PID to /Users/user/dev/optimus_prime/tmp/pids/optimus_prime.pid
2501
+ Using rack adapter
2502
+ Thin web server (v1.6.2 codename Doc Brown)
2503
+ Debugging ON
2504
+ Maximum connections set to 1024
2505
+ Listening on 0.0.0.0:7003, CTRL+C to stop
2506
+ RuntimeError - :
2507
+ /Users/user/dev/optimus_prime/lib/optimus_prime/server.rb:34:in `block in <class:Server>'
2508
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1603:in `call'
2509
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1603:in `block in compile!'
2510
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `[]'
2511
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `block (3 levels) in route!'
2512
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:985:in `route_eval'
2513
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `block (2 levels) in route!'
2514
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1006:in `block in process_route'
2515
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1004:in `catch'
2516
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1004:in `process_route'
2517
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:964:in `block in route!'
2518
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:963:in `each'
2519
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:963:in `route!'
2520
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1076:in `block in dispatch!'
2521
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `block in invoke'
2522
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `catch'
2523
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `invoke'
2524
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1073:in `dispatch!'
2525
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:898:in `block in call!'
2526
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `block in invoke'
2527
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `catch'
2528
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `invoke'
2529
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:898:in `call!'
2530
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:886:in `call'
2531
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/xss_header.rb:18:in `call'
2532
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/path_traversal.rb:16:in `call'
2533
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/json_csrf.rb:18:in `call'
2534
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
2535
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
2536
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/frame_options.rb:31:in `call'
2537
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-1.5.2/lib/rack/nulllogger.rb:9:in `call'
2538
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-1.5.2/lib/rack/head.rb:11:in `call'
2539
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/show_exceptions.rb:21:in `call'
2540
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:180:in `call'
2541
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:2014:in `call'
2542
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `block in call'
2543
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1788:in `synchronize'
2544
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `call'
2545
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/connection.rb:86:in `block in pre_process'
2546
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/connection.rb:84:in `catch'
2547
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/connection.rb:84:in `pre_process'
2548
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/connection.rb:53:in `process'
2549
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/connection.rb:39:in `receive_data'
2550
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
2551
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
2552
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/backends/base.rb:73:in `start'
2553
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/server.rb:162:in `start'
2554
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/controllers/controller.rb:87:in `start'
2555
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/runner.rb:199:in `run_command'
2556
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/runner.rb:155:in `run!'
2557
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/bin/thin:6:in `<top (required)>'
2558
+ /Users/user/.rvm/gems/ruby-2.1.1/bin/thin:23:in `load'
2559
+ /Users/user/.rvm/gems/ruby-2.1.1/bin/thin:23:in `<main>'
2560
+ /Users/user/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `eval'
2561
+ /Users/user/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `<main>'
2562
+ Exiting!
2563
+ Writing PID to /Users/user/dev/optimus_prime/tmp/pids/optimus_prime.pid
2564
+ Using rack adapter
2565
+ Thin web server (v1.6.2 codename Doc Brown)
2566
+ Debugging ON
2567
+ Maximum connections set to 1024
2568
+ Listening on 0.0.0.0:7003, CTRL+C to stop
2569
+ RuntimeError - {"user"=>{:content_type=>"json", :body=>"{\"username\":\"Test\"}", :status_code=>200, :requested_with=>"I am a body", :sleep=>false, :persisted=>false}} ----> {:content_type=>"json", :body=>"{\"username\":\"Test\"}", :status_code=>200, :requested_with=>"I am a body", :sleep=>false, :persisted=>false} ----> :
2570
+ /Users/user/dev/optimus_prime/lib/optimus_prime/server.rb:34:in `block in <class:Server>'
2571
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1603:in `call'
2572
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1603:in `block in compile!'
2573
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `[]'
2574
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `block (3 levels) in route!'
2575
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:985:in `route_eval'
2576
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `block (2 levels) in route!'
2577
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1006:in `block in process_route'
2578
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1004:in `catch'
2579
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1004:in `process_route'
2580
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:964:in `block in route!'
2581
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:963:in `each'
2582
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:963:in `route!'
2583
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1076:in `block in dispatch!'
2584
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `block in invoke'
2585
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `catch'
2586
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `invoke'
2587
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1073:in `dispatch!'
2588
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:898:in `block in call!'
2589
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `block in invoke'
2590
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `catch'
2591
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `invoke'
2592
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:898:in `call!'
2593
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:886:in `call'
2594
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/xss_header.rb:18:in `call'
2595
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/path_traversal.rb:16:in `call'
2596
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/json_csrf.rb:18:in `call'
2597
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
2598
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
2599
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/frame_options.rb:31:in `call'
2600
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-1.5.2/lib/rack/nulllogger.rb:9:in `call'
2601
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-1.5.2/lib/rack/head.rb:11:in `call'
2602
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/show_exceptions.rb:21:in `call'
2603
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:180:in `call'
2604
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:2014:in `call'
2605
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `block in call'
2606
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1788:in `synchronize'
2607
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `call'
2608
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/connection.rb:86:in `block in pre_process'
2609
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/connection.rb:84:in `catch'
2610
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/connection.rb:84:in `pre_process'
2611
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/connection.rb:53:in `process'
2612
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/connection.rb:39:in `receive_data'
2613
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
2614
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
2615
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/backends/base.rb:73:in `start'
2616
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/server.rb:162:in `start'
2617
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/controllers/controller.rb:87:in `start'
2618
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/runner.rb:199:in `run_command'
2619
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/runner.rb:155:in `run!'
2620
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/bin/thin:6:in `<top (required)>'
2621
+ /Users/user/.rvm/gems/ruby-2.1.1/bin/thin:23:in `load'
2622
+ /Users/user/.rvm/gems/ruby-2.1.1/bin/thin:23:in `<main>'
2623
+ /Users/user/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `eval'
2624
+ /Users/user/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `<main>'
2625
+ Exiting!
2626
+ Writing PID to /Users/user/dev/optimus_prime/tmp/pids/optimus_prime.pid
2627
+ Using rack adapter
2628
+ Thin web server (v1.6.2 codename Doc Brown)
2629
+ Debugging ON
2630
+ Maximum connections set to 1024
2631
+ Listening on 0.0.0.0:7003, CTRL+C to stop
2632
+ NameError - undefined local variable or method `path' for #<OptimusPrime::Server:0x00000102148c70>:
2633
+ /Users/user/dev/optimus_prime/lib/optimus_prime/server.rb:32:in `block in <class:Server>'
2634
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1603:in `call'
2635
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1603:in `block in compile!'
2636
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `[]'
2637
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `block (3 levels) in route!'
2638
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:985:in `route_eval'
2639
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `block (2 levels) in route!'
2640
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1006:in `block in process_route'
2641
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1004:in `catch'
2642
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1004:in `process_route'
2643
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:964:in `block in route!'
2644
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:963:in `each'
2645
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:963:in `route!'
2646
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1076:in `block in dispatch!'
2647
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `block in invoke'
2648
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `catch'
2649
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `invoke'
2650
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1073:in `dispatch!'
2651
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:898:in `block in call!'
2652
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `block in invoke'
2653
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `catch'
2654
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `invoke'
2655
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:898:in `call!'
2656
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:886:in `call'
2657
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/xss_header.rb:18:in `call'
2658
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/path_traversal.rb:16:in `call'
2659
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/json_csrf.rb:18:in `call'
2660
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
2661
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
2662
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/frame_options.rb:31:in `call'
2663
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-1.5.2/lib/rack/nulllogger.rb:9:in `call'
2664
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-1.5.2/lib/rack/head.rb:11:in `call'
2665
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/show_exceptions.rb:21:in `call'
2666
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:180:in `call'
2667
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:2014:in `call'
2668
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `block in call'
2669
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1788:in `synchronize'
2670
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `call'
2671
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/connection.rb:86:in `block in pre_process'
2672
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/connection.rb:84:in `catch'
2673
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/connection.rb:84:in `pre_process'
2674
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/connection.rb:53:in `process'
2675
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/connection.rb:39:in `receive_data'
2676
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
2677
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
2678
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/backends/base.rb:73:in `start'
2679
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/server.rb:162:in `start'
2680
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/controllers/controller.rb:87:in `start'
2681
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/runner.rb:199:in `run_command'
2682
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/runner.rb:155:in `run!'
2683
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/bin/thin:6:in `<top (required)>'
2684
+ /Users/user/.rvm/gems/ruby-2.1.1/bin/thin:23:in `load'
2685
+ /Users/user/.rvm/gems/ruby-2.1.1/bin/thin:23:in `<main>'
2686
+ /Users/user/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `eval'
2687
+ /Users/user/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `<main>'
2688
+ Exiting!
2689
+ Writing PID to /Users/user/dev/optimus_prime/tmp/pids/optimus_prime.pid
2690
+ Using rack adapter
2691
+ Thin web server (v1.6.2 codename Doc Brown)
2692
+ Debugging ON
2693
+ Maximum connections set to 1024
2694
+ Listening on 0.0.0.0:7003, CTRL+C to stop
2695
+ NameError - undefined local variable or method `path' for #<OptimusPrime::Server:0x0000010309d950>:
2696
+ /Users/user/dev/optimus_prime/lib/optimus_prime/server.rb:40:in `block in <class:Server>'
2697
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1603:in `call'
2698
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1603:in `block in compile!'
2699
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `[]'
2700
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `block (3 levels) in route!'
2701
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:985:in `route_eval'
2702
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:966:in `block (2 levels) in route!'
2703
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1006:in `block in process_route'
2704
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1004:in `catch'
2705
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1004:in `process_route'
2706
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:964:in `block in route!'
2707
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:963:in `each'
2708
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:963:in `route!'
2709
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1076:in `block in dispatch!'
2710
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `block in invoke'
2711
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `catch'
2712
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `invoke'
2713
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1073:in `dispatch!'
2714
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:898:in `block in call!'
2715
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `block in invoke'
2716
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `catch'
2717
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1058:in `invoke'
2718
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:898:in `call!'
2719
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:886:in `call'
2720
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/xss_header.rb:18:in `call'
2721
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/path_traversal.rb:16:in `call'
2722
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/json_csrf.rb:18:in `call'
2723
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
2724
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
2725
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-protection-1.5.3/lib/rack/protection/frame_options.rb:31:in `call'
2726
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-1.5.2/lib/rack/nulllogger.rb:9:in `call'
2727
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/rack-1.5.2/lib/rack/head.rb:11:in `call'
2728
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/show_exceptions.rb:21:in `call'
2729
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:180:in `call'
2730
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:2014:in `call'
2731
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `block in call'
2732
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1788:in `synchronize'
2733
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/sinatra-1.4.5/lib/sinatra/base.rb:1478:in `call'
2734
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/connection.rb:86:in `block in pre_process'
2735
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/connection.rb:84:in `catch'
2736
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/connection.rb:84:in `pre_process'
2737
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/connection.rb:53:in `process'
2738
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/connection.rb:39:in `receive_data'
2739
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
2740
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
2741
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/backends/base.rb:73:in `start'
2742
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/server.rb:162:in `start'
2743
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/controllers/controller.rb:87:in `start'
2744
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/runner.rb:199:in `run_command'
2745
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/lib/thin/runner.rb:155:in `run!'
2746
+ /Users/user/.rvm/gems/ruby-2.1.1/gems/thin-1.6.2/bin/thin:6:in `<top (required)>'
2747
+ /Users/user/.rvm/gems/ruby-2.1.1/bin/thin:23:in `load'
2748
+ /Users/user/.rvm/gems/ruby-2.1.1/bin/thin:23:in `<main>'
2749
+ /Users/user/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `eval'
2750
+ /Users/user/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `<main>'
2751
+ Exiting!
2752
+ Writing PID to /Users/user/dev/optimus_prime/tmp/pids/optimus_prime.pid
2753
+ Using rack adapter
2754
+ Thin web server (v1.6.2 codename Doc Brown)
2755
+ Debugging ON
2756
+ Maximum connections set to 1024
2757
+ Listening on 0.0.0.0:7003, CTRL+C to stop
@@ -9,20 +9,20 @@ describe OptimusPrime do
9
9
  it "primes an endpoint with attributes" do
10
10
  op.prime("test", "I am a response")
11
11
 
12
- response = ::Faraday.get("http://localhost:7002/get/test")
12
+ response = ::Faraday.get("http://localhost:7003/get/test")
13
13
  expect( response.body ).to eq "I am a response"
14
14
  end
15
15
 
16
16
  it "sets a content type" do
17
17
  op.prime("test", "I am a response", content_type: :json)
18
18
 
19
- response = ::Faraday.get("http://localhost:7002/get/test")
19
+ response = ::Faraday.get("http://localhost:7003/get/test")
20
20
  expect( response.headers["content-type"] ).to eq "application/json"
21
21
  end
22
22
 
23
23
  it "retrieves a path containing attributes" do
24
24
  op.prime("route/name", "<html><head><title>Response</title></head><body><h1>Hi</h1><body></html>", content_type: :html)
25
- response = ::Faraday.get('http://localhost:7002/get/route/name')
25
+ response = ::Faraday.get('http://localhost:7003/get/route/name')
26
26
 
27
27
  expect(response.headers["content-type"]).to include("text/html")
28
28
  expect(response.body).to include("<h1>Hi</h1>")
@@ -30,44 +30,38 @@ describe OptimusPrime do
30
30
 
31
31
  it "retrieves a very nested path" do
32
32
  op.prime("getUserProfile/queue/token/12345678", { username: 'Antonio', age: 21 }.to_json, content_type: :json)
33
- response = ::Faraday.get('http://localhost:7002/get/getUserProfile/queue/token/12345678')
33
+ response = ::Faraday.get('http://localhost:7003/get/getUserProfile/queue/token/12345678')
34
34
 
35
35
  expect(JSON.parse(response.body)).to eq({ "username" => "Antonio", "age" => 21 })
36
36
  end
37
37
 
38
- it "retrieves from url with params" do
39
- op.prime("getUser?id=10&queue=NaN", { username: "Test" }.to_json, content_type: :json)
40
- response = ::Faraday.get('http://localhost:7002/get/getUser?id=10&queue=NaN')
41
-
42
- expect( JSON.parse(response.body) ).to eq({ "username" => "Test" })
43
- end
44
-
45
38
  it "returns a 404 when endpoint is not found" do
46
- response = ::Faraday.get('http://localhost:7002/get/iDoNotExist')
39
+ response = ::Faraday.get('http://localhost:7003/get/iDoNotExist')
47
40
 
48
41
  expect( response.status ).to eq 404
49
42
  end
50
43
 
51
44
  it "allows developers to change the response status code" do
52
45
  op.prime("notFound", { username: "Test" }.to_json, content_type: :json, status_code: 404)
53
- response = ::Faraday.get('http://localhost:7002/get/notFound')
46
+ response = ::Faraday.get('http://localhost:7003/get/notFound')
54
47
 
55
48
  expect( response.status ).to eq 404
56
49
  end
57
50
 
58
51
  it "returns 200 http status code as default" do
59
52
  op.prime("continue", { username: "Test" }.to_json, content_type: :json)
60
- response = ::Faraday.get('http://localhost:7002/get/continue')
53
+ response = ::Faraday.get('http://localhost:7003/get/continue')
61
54
 
62
55
  expect( response.status ).to eq 200
63
56
  end
64
57
 
58
+
65
59
  context "Asserting on request content" do
66
60
 
67
61
  it "returns a 404 if the request body does not match the assertion" do
68
62
  op.prime("user", { username: "Test" }.to_json, content_type: :json, requested_with: "haha")
69
63
 
70
- response = ::Faraday.post('http://localhost:7002/get/user', "I am a body")
64
+ response = ::Faraday.post('http://localhost:7003/get/user', "I am a body")
71
65
 
72
66
  expect( response.status ).to eq 404
73
67
  end
@@ -75,7 +69,7 @@ describe OptimusPrime do
75
69
  it "returns a 200 if the request body does match the assertion" do
76
70
  op.prime("user", { username: "Test" }.to_json, content_type: :json, requested_with: "I am a body")
77
71
 
78
- response = ::Faraday.post('http://localhost:7002/get/user', "I am a body")
72
+ response = ::Faraday.post('http://localhost:7003/get/user', "I am a body")
79
73
 
80
74
  expect( response.status ).to eq 200
81
75
  end
@@ -87,7 +81,7 @@ describe OptimusPrime do
87
81
  it "#GET tells the server to sleep for 10 seconds in order to reproduce timeouts" do
88
82
  op.prime("userAsleep", { username: "Test" }.to_json, content_type: :json, sleep: 10)
89
83
 
90
- f = ::Faraday.new('http://localhost:7002/get/')
84
+ f = ::Faraday.new('http://localhost:7003/get/')
91
85
  f.options.timeout = 0
92
86
 
93
87
  expect { f.get("/userAsleep") }.to raise_error(Faraday::TimeoutError)
@@ -98,7 +92,7 @@ describe OptimusPrime do
98
92
  it "#POST tells the server to sleep for n seconds in order to reproduce timeouts" do
99
93
  op.prime("userAsleepAgain", { username: "Test" }.to_json, content_type: :json, sleep: 10)
100
94
 
101
- f = ::Faraday.new('http://localhost:7002/get/')
95
+ f = ::Faraday.new('http://localhost:7003/get/')
102
96
  f.options.timeout = 0
103
97
 
104
98
  expect { f.get("/userAsleepAgain") }.to raise_error(Faraday::TimeoutError)
@@ -108,23 +102,23 @@ describe OptimusPrime do
108
102
 
109
103
  end
110
104
 
111
- it "creates a record for with default params" do
105
+ it "#POST creates a record for with default params" do
112
106
  op.prime("posts/1", {}, content_type: :json)
113
107
 
114
- ::Faraday.post("http://localhost:7002/get/posts/1", { text: "I have been created", age: 21, category: "user" })
108
+ ::Faraday.post("http://localhost:7003/get/posts/1", { text: "I have been created", age: 21, category: "user" })
115
109
 
116
- expect( JSON.parse(::Faraday.get("http://localhost:7002/get/posts/1").body, symbolize_names: true) ).to eq({:age=>"21", :category=>"user", :text=>"I have been created"})
110
+ expect( JSON.parse(::Faraday.get("http://localhost:7003/get/posts/1").body, symbolize_names: true) ).to eq({:age=>"21", :category=>"user", :text=>"I have been created"})
117
111
  end
118
112
 
119
113
  context "#PUT" do
120
114
  it "persists a request when told so" do
121
115
  op.prime("persisted", { text: "" }.to_json, persisted: true, content_type: :json)
122
116
 
123
- expect( JSON.parse(::Faraday.get("http://localhost:7002/get/persisted").body) ).to eq({ "text" => "" })
117
+ expect( JSON.parse(::Faraday.get("http://localhost:7003/get/persisted").body) ).to eq({ "text" => "" })
124
118
 
125
- ::Faraday.put("http://localhost:7002/get/persisted", { id: 1 })
119
+ ::Faraday.put("http://localhost:7003/get/persisted", { id: 1 })
126
120
 
127
- expect( JSON.parse(::Faraday.get("http://localhost:7002/get/persisted").body, symbolize_names: true) ).to eq({ text: "", id: "1"})
121
+ expect( JSON.parse(::Faraday.get("http://localhost:7003/get/persisted").body, symbolize_names: true) ).to eq({ text: "", id: "1"})
128
122
  end
129
123
 
130
124
  end
@@ -1,4 +1,19 @@
1
1
  describe OptimusPrime, "Starting and Stopping the server" do
2
+
3
+ it "allows devs to change server port" do
4
+ OptimusPrime.stop_server
5
+ OptimusPrime.start_server(port: 7004)
6
+ expect( `lsof -i:7003` ).to include("COMMAND")
7
+ OptimusPrime.stop_server
8
+ end
9
+
10
+ it "starts the server in test mode" do
11
+ OptimusPrime.stop_server
12
+ OptimusPrime.start_server
13
+ expect( `lsof -i:7003` ).to include("COMMAND")
14
+ OptimusPrime.stop_server
15
+ end
16
+
2
17
  it "starts the server" do
3
18
  OptimusPrime.restart_server
4
19
  expect( `ls ./tmp/pids` ).to include("optimus_prime.pid")
data/spec/spec_helper.rb CHANGED
@@ -2,6 +2,7 @@ require "optimus_prime"
2
2
 
3
3
  RSpec.configure do |config|
4
4
  begin
5
+ ENV["OP.ENV"] = "test"
5
6
  OptimusPrime.start_server
6
7
 
7
8
  config.filter_run :focus
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: 0.2.0
4
+ version: 1.0.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-08-15 00:00:00.000000000 Z
11
+ date: 2014-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler