Sha256: f0670c134c11878b9a65f54e375aa7bf41249bde70900f52680cd710f0365b83

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 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 configuration
      Micronaut.configuration
    end
    
    def formatter
      Micronaut.configuration.formatter
    end
     
    def require_all_behaviours(files_from_args=[])
      files_from_args.each { |file| require file }
    end
    
    def run(args = [])
      require_all_behaviours(args)
      
      total_examples_to_run = Micronaut.world.total_examples_to_run

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

      formatter.start(total_examples_to_run)

      suite_success = true

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

      formatter.start_dump
      formatter.dump_failures
      # TODO: Stop passing in the last two items, the formatter knows this info
      formatter.dump_summary(duration, total_examples_to_run, formatter.failed_examples.size, formatter.pending_examples.size)
      formatter.dump_pending

      formatter.output.sync = old_sync if 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.4.3 lib/micronaut/runner.rb