Sha256: 8386ad239e95746cc49a517a12f6ab6206761e20b8937cc61793b26ad6629cf6

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

module Micronaut

  class Runner

    def self.installed_at_exit?
      @installed_at_exit ||= false
    end

    def self.autorun
      at_exit { Micronaut::Runner.new.run(ARGV) ? exit(0) : exit(1) } unless installed_at_exit?
      @installed_at_exit = true
    end

    def options
      Micronaut.configuration.options
    end
    
    def run(args = [])
      args.inject([]) { |files, arg| files.concat(Dir[arg].map { |g| Dir.glob(g) }.flatten) }.each do |file|
        load file
      end
      
      behaviours_to_run = Micronaut::World.behaviours_to_run
      total_behaviours = behaviours_to_run.inject(0) { |sum, b| sum + b.examples_to_run.size }

      old_sync, options.formatter.output.sync = options.formatter.output.sync, true if options.formatter.output.respond_to?(:sync=)

      options.formatter.start(total_behaviours)

      suite_success = true

      starts_at = Time.now
      behaviours_to_run.each do |behaviour|
        suite_success &= behaviour.run(options.formatter)
      end
      duration = Time.now - starts_at

      options.formatter.start_dump
      options.formatter.dump_pending
      options.formatter.dump_failures
      options.formatter.dump_summary(duration, total_behaviours, options.formatter.failed_examples.size, options.formatter.pending_examples.size)

      options.formatter.output.sync = old_sync if options.formatter.output.respond_to? :sync=

      suite_success
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spicycode-micronaut-0.1.2 lib/micronaut/runner.rb