Sha256: 1b355be990e8cd4e795edaee8965f7345e7208545a585bd0a4518be44e331e62

Contents?: true

Size: 1.39 KB

Versions: 9

Compression:

Stored size: 1.39 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=)

      suite_success = true

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

      formatter.start(total_examples_to_run) # start the clock
      start = Time.now
      Micronaut.world.behaviours_to_run.each do |behaviour|
        suite_success &= behaviour.run(formatter)
      end
      formatter.start_dump(Time.now - start)
      
      formatter.dump_failures
      formatter.dump_summary
      formatter.dump_pending
      formatter.close
      
      formatter.output.sync = old_sync if formatter_supports_sync

      suite_success
    end

  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
spicycode-micronaut-0.1.4.4 lib/micronaut/runner.rb
spicycode-micronaut-0.1.5.2 lib/micronaut/runner.rb
spicycode-micronaut-0.1.5 lib/micronaut/runner.rb
spicycode-micronaut-0.1.6.1 lib/micronaut/runner.rb
spicycode-micronaut-0.1.6.8 lib/micronaut/runner.rb
spicycode-micronaut-0.1.6.9.1 lib/micronaut/runner.rb
spicycode-micronaut-0.1.6.9 lib/micronaut/runner.rb
spicycode-micronaut-0.1.6 lib/micronaut/runner.rb
spicycode-micronaut-0.1.7 lib/micronaut/runner.rb