Class: Tack::Runner
- Inherits:
-
Object
- Object
- Tack::Runner
- Defined in:
- lib/tack/runner.rb
Instance Method Summary collapse
-
#initialize(args) {|_self| ... } ⇒ Runner
constructor
A new instance of Runner.
- #run(tests) ⇒ Object
- #run_suite(tests) ⇒ Object
- #run_test(path, description) ⇒ Object
- #to_app ⇒ Object
- #use(middleware, *args, &block) ⇒ Object
Constructor Details
#initialize(args) {|_self| ... } ⇒ Runner
Returns a new instance of Runner.
5 6 7 8 9 10 11 12 13 |
# File 'lib/tack/runner.rb', line 5 def initialize(args) if(args.is_a?(Hash)) @root_dir = args.fetch(:root) else @root_dir = args end @handlers = [] yield self if block_given? end |
Instance Method Details
#run(tests) ⇒ Object
15 16 17 18 |
# File 'lib/tack/runner.rb', line 15 def run(tests) to_app if @start_app.nil? @start_app.run_suite(tests) end |
#run_suite(tests) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/tack/runner.rb', line 20 def run_suite(tests) results = { :passed => [], :failed => [], :pending => []} tests.each do |path, description| result = @start_app.run_test(path, description) results[:passed] += result[:passed] results[:failed] += result[:failed] results[:pending] += result[:pending] end results end |
#run_test(path, description) ⇒ Object
33 34 35 36 |
# File 'lib/tack/runner.rb', line 33 def run_test(path, description) adapter = Adapters::Adapter.for(path) adapter.run(path, description) end |
#to_app ⇒ Object
43 44 45 46 |
# File 'lib/tack/runner.rb', line 43 def to_app inner_app = self @start_app = @handlers.reverse.inject(inner_app) { |a, e| e.call(a) } end |
#use(middleware, *args, &block) ⇒ Object
38 39 40 41 |
# File 'lib/tack/runner.rb', line 38 def use(middleware, *args, &block) @handlers << lambda { |app| middleware.new(app, *args, &block) } end |