Sha256: 0ea2303412c11961d58a0d09645d8a2b7969768e96745eedb3adac0fba2f4672

Contents?: true

Size: 1.52 KB

Versions: 36

Compression:

Stored size: 1.52 KB

Contents

module Jasmine
  class CiRunner
    def initialize(config, options={})
      @config = config
      @thread = options.fetch(:thread, Thread)
      @application_factory = options.fetch(:application_factory, Jasmine::Application)
      @server_factory = options.fetch(:server_factory, Jasmine::Server)
      @outputter = options.fetch(:outputter, Kernel)
      @random = options.fetch(:random, config.random)
      @seed = options.has_key?(:seed) ? "&seed=#{options[:seed]}" : ''
    end

    def run
      formatters = config.formatters.map { |formatter_class| formatter_class.new }

      exit_code_formatter = Jasmine::Formatters::ExitCode.new
      formatters << exit_code_formatter

      url = "#{config.host}:#{config.port(:ci)}/?throwFailures=#{config.stop_spec_on_expectation_failure}&random=#{@random}#{@seed}"
      runner = config.runner.call(Jasmine::Formatters::Multi.new(formatters), url)

      if runner.respond_to?(:boot_js)
        config.runner_boot_dir = File.dirname(runner.boot_js)
        config.runner_boot_files = lambda { [runner.boot_js] }
      end

      server = @server_factory.new(config.port(:ci), app, config.rack_options)

      t = @thread.new do
        server.start
      end
      t.abort_on_exception = true

      Jasmine::wait_for_listener(config.port(:ci), config.host.sub(/\Ahttps?:\/\//, ''))
      @outputter.puts 'jasmine server started'

      runner.run

      exit_code_formatter.succeeded?
    end

    private

    attr_reader :config

    def app
      @application_factory.app(@config)
    end
  end
end

Version data entries

36 entries across 23 versions & 2 rubygems

Version Path
tdiary-5.2.4 vendor/bundle/ruby/3.1.0/gems/jasmine-2.99.0/lib/jasmine/ci_runner.rb
tdiary-5.2.3 vendor/bundle/ruby/3.1.0/gems/jasmine-2.99.0/lib/jasmine/ci_runner.rb
tdiary-5.2.2 vendor/bundle/ruby/3.1.0/gems/jasmine-2.99.0/lib/jasmine/ci_runner.rb
tdiary-5.2.1 vendor/bundle/ruby/3.1.0/gems/jasmine-2.99.0/lib/jasmine/ci_runner.rb
tdiary-5.2.0 vendor/bundle/ruby/2.7.0/gems/jasmine-2.99.0/lib/jasmine/ci_runner.rb
tdiary-5.2.0 vendor/bundle/ruby/3.0.0/gems/jasmine-2.99.0/lib/jasmine/ci_runner.rb
tdiary-5.1.7 vendor/bundle/ruby/2.7.0/gems/jasmine-2.99.0/lib/jasmine/ci_runner.rb
tdiary-5.1.7 vendor/bundle/ruby/3.0.0/gems/jasmine-2.99.0/lib/jasmine/ci_runner.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/jasmine-2.99.0/lib/jasmine/ci_runner.rb
tdiary-5.1.6 vendor/bundle/ruby/3.0.0/gems/jasmine-2.99.0/lib/jasmine/ci_runner.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/jasmine-2.99.0/lib/jasmine/ci_runner.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/jasmine-2.99.0/lib/jasmine/ci_runner.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/2.7.0/gems/jasmine-2.99.0/lib/jasmine/ci_runner.rb
tdiary-5.1.5 vendor/bundle/ruby/2.7.0/gems/jasmine-2.99.0/lib/jasmine/ci_runner.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/jasmine-2.99.0/lib/jasmine/ci_runner.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/jasmine-2.99.0/lib/jasmine/ci_runner.rb
tdiary-5.1.4 vendor/bundle/ruby/2.7.0/gems/jasmine-2.99.0/lib/jasmine/ci_runner.rb
tdiary-5.1.3 vendor/bundle/ruby/2.7.0/gems/jasmine-2.99.0/lib/jasmine/ci_runner.rb
tdiary-5.1.3 vendor/bundle/ruby/2.6.0/gems/jasmine-2.99.0/lib/jasmine/ci_runner.rb
tdiary-5.1.2 vendor/bundle/ruby/2.7.0/gems/jasmine-2.99.0/lib/jasmine/ci_runner.rb