Class: Dredd::Rack::RakeTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Dredd::Rack::RakeTask
- Defined in:
- lib/dredd/rack/rake_task.rb
Overview
A clonable Rake task powered by a Dredd::Rack::Runner
Examples:
require 'dredd/rack'
Dredd::Rack::RakeTask.new # run it with `rake dredd`
# Customize the name or description of the Rake task:
namespace :blueprint do
desc 'Verify an API complies with its blueprint'
Dredd::Rack::RakeTask.new(:verify)
end
# run it with `rake blueprint:verify`
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Return the task’s description.
-
#name ⇒ Object
readonly
Return the task’s name.
-
#runner ⇒ Object
readonly
Return the Dredd::Rack::Runner instance.
Instance Method Summary collapse
-
#initialize(*args) ⇒ RakeTask
constructor
Define a task with a custom name, arguments and description.
- #run_task(runner) ⇒ Object
Constructor Details
#initialize(*args) ⇒ RakeTask
Define a task with a custom name, arguments and description
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/dredd/rack/rake_task.rb', line 35 def initialize(*args) @name = args.shift || :dredd @description = 'Run Dredd::Rack API blueprint verification' @runner = Dredd::Rack::Runner.new(ENV['API_HOST']) desc description unless ::Rake.application.last_comment task name, args do run_task(runner) end end |
Instance Attribute Details
#description ⇒ Object (readonly)
Return the task’s description
29 30 31 |
# File 'lib/dredd/rack/rake_task.rb', line 29 def description @description end |
#name ⇒ Object (readonly)
Return the task’s name
26 27 28 |
# File 'lib/dredd/rack/rake_task.rb', line 26 def name @name end |
#runner ⇒ Object (readonly)
Return the Dredd::Rack::Runner instance
32 33 34 |
# File 'lib/dredd/rack/rake_task.rb', line 32 def runner @runner end |
Instance Method Details
#run_task(runner) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/dredd/rack/rake_task.rb', line 46 def run_task(runner) abort unless dredd_available? puts puts (runner) success = runner.run exit_status = $?.exitstatus puts (runner) unless success if dredd_connection_error?(exit_status) abort unless exit_status == 0 end |