Module: Halcyon::Runner::Helpers::CommandHelper
- Defined in:
- lib/halcyon/runner/helpers/command_helper.rb
Instance Method Summary collapse
- #app ⇒ Object
- #clear ⇒ Object
- #delete(path) ⇒ Object
- #get(path) ⇒ Object
- #log ⇒ Object
- #post(path, params = {}) ⇒ Object
- #put(path, params = {}) ⇒ Object
- #response ⇒ Object
- #tail ⇒ Object
- #usage ⇒ Object
Instance Method Details
#app ⇒ Object
28 29 30 |
# File 'lib/halcyon/runner/helpers/command_helper.rb', line 28 def app $app end |
#clear ⇒ Object
40 41 42 |
# File 'lib/halcyon/runner/helpers/command_helper.rb', line 40 def clear $log = '' end |
#delete(path) ⇒ Object
59 60 61 62 |
# File 'lib/halcyon/runner/helpers/command_helper.rb', line 59 def delete(path) $response = Rack::MockRequest.new($app).delete(path) JSON.parse($response.body) end |
#get(path) ⇒ Object
44 45 46 47 |
# File 'lib/halcyon/runner/helpers/command_helper.rb', line 44 def get(path) $response = Rack::MockRequest.new($app).get(path) JSON.parse($response.body) end |
#log ⇒ Object
32 33 34 |
# File 'lib/halcyon/runner/helpers/command_helper.rb', line 32 def log $log end |
#post(path, params = {}) ⇒ Object
49 50 51 52 |
# File 'lib/halcyon/runner/helpers/command_helper.rb', line 49 def post(path, params = {}) $response = Rack::MockRequest.new($app).post(path, :input => params.to_params) JSON.parse($response.body) end |
#put(path, params = {}) ⇒ Object
54 55 56 57 |
# File 'lib/halcyon/runner/helpers/command_helper.rb', line 54 def put(path, params = {}) $response = Rack::MockRequest.new($app).put(path, :input => params.to_params) JSON.parse($response.body) end |
#response ⇒ Object
64 65 66 |
# File 'lib/halcyon/runner/helpers/command_helper.rb', line 64 def response $response end |
#tail ⇒ Object
36 37 38 |
# File 'lib/halcyon/runner/helpers/command_helper.rb', line 36 def tail puts $log.split("\n").reverse[0..5].reverse.join("\n") end |
#usage ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/halcyon/runner/helpers/command_helper.rb', line 6 def usage msg = <<-"end;" These methods will provide you with most of the functionality you will need to test your app. #app The loaded application #log The contents of the log (Ex: puts log) #tail The tail end of the log (Ex: tail) #clear Clears the log (Ex: clear) #get Sends a GET request to the app Ex: get '/controller/action' #post Sends a POST request to #app Ex: post '/controller/action', :key => value #put See #post #delete See #get #response Response of the last request end; puts msg.gsub(/^[ ]{12}/, '') end |