Sha256: da390b06bac45a66317feead7ceccddd1bfcc40ba8ed72096ad61731c30d625b

Contents?: true

Size: 1.39 KB

Versions: 5

Compression:

Stored size: 1.39 KB

Contents

module JsTestDriver
  module CLI

    class Run

      attr_reader :command, :runner, :config, :coverage_command

      def initialize(jstd_jar_command, runner, config, coverage_command)
        @command = jstd_jar_command
        @runner = runner
        @config = config
        @coverage_command = coverage_command
      end

      def run(opts = {})
        result = run_jstd_command(opts)
        generate_coverage_report(opts)
        return result
      end

      protected

      def run_jstd_command(opts)
        command
          .start_server
          .with_config
          .capture_browsers(opts[:browsers])
          .run_tests(opts[:tests])

        command.output_xml if opts[:output_xml]
        command.capture_console if opts[:capture_console]
        command.verbose if opts[:verbose]
        command.run_mode(opts[:runner_mode]) if opts[:runner_mode]
        command.browser_timeout(opts[:browser_timeout]) if opts[:browser_timeout]

        return runner.run(command.to_s)
      end

      def generate_coverage_report(opts)
        return unless config.measure_coverage? && opts[:output_xml]

        if genhtml_installed?
          runner.run(coverage_command.to_s)
        else
          puts "Could not find genhtml. You must install lcov (sudo apt-get install lcov)"
        end
      end

      def genhtml_installed?
        !%x[which genhtml].strip.empty?
      end

    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
js-test-driver-rails-0.5.0.pre5 lib/js_test_driver/cli/run.rb
js-test-driver-rails-0.5.0.pre4 lib/js_test_driver/cli/run.rb
js-test-driver-rails-0.5.0.pre3 lib/js_test_driver/cli/run.rb
js-test-driver-rails-0.5.0.pre2 lib/js_test_driver/cli/run.rb
js-test-driver-rails-0.5.0.pre1 lib/js_test_driver/cli/run.rb