class Opal::RSpec::Runner

Attributes

arity_checking[RW]
cli_options[RW]
default_path[RW]
exclude_pattern[RW]
files[RW]
pattern[RW]
requires[RW]
runner[RW]
spec_opts[RW]

Public Class Methods

new(&block) click to toggle source
# File lib/opal/rspec/runner.rb, line 70
def initialize(&block)
  @legacy_server_proxy = LegacyServerProxy.new
  block.call(@legacy_server_proxy, self) if block_given? # for compatibility

  raise 'Cannot supply both a pattern and files!' if self.files and self.pattern

  locator = ::Opal::RSpec::Locator.new pattern: self.pattern, exclude_pattern: self.exclude_pattern, files: self.files, default_path: self.default_path

  options = []
  options << '--arity-check' if arity_checking?
  options += ['--runner', runner] unless runner.empty?
  options << '-ropal-rspec'
  options << '--missing-require=ignore'
  options += @legacy_server_proxy.to_cli_options

  Opal.paths.each                     { |p| options << "-I#{p}" }
  locator.get_spec_load_paths.each    { |p| options << "-I#{p}" }
  requires.each                       { |p| options << "-r#{p}" }
  locator.get_opal_spec_requires.each { |p| options << "-r#{p}" }
  ::Opal::Config.stubbed_files.each   { |p| options << "-s#{p}" }

  options += @cli_options if @cli_options
  bootstrap_code = [
    ::Opal::RSpec.spec_opts_code(spec_opts),
    '::RSpec::Core::Runner.autorun',
  ].join(';')

  @args = "#{options.map(&:shellescape).join ' '} -e #{bootstrap_code.shellescape}"
end

Public Instance Methods

arity_checking?() click to toggle source
# File lib/opal/rspec/runner.rb, line 17
def arity_checking?
  setting = @arity_checking || :enabled
  setting == :enabled
end
cli() click to toggle source
# File lib/opal/rspec/runner.rb, line 124
def cli
  @cli ||= ::Opal::CLI.new(cli_options)
end
command() click to toggle source
# File lib/opal/rspec/runner.rb, line 112
def command
  @command ||= "opal #{@args}"
end
get_load_asset_code(server) click to toggle source
# File lib/opal/rspec/runner.rb, line 34
def get_load_asset_code(server)
  sprockets = server.sprockets
  name = server.main
  asset = sprockets[name]
  raise "Cannot find asset: #{name}" if asset.nil?
  # Opal::Sprockets.load_asset name, sprockets
  ''
end
options() click to toggle source
# File lib/opal/rspec/runner.rb, line 100
def options
  {
    pattern: pattern,
    exclude_pattern: exclude_pattern,
    files: files,
    default_path: default_path,
    runner: runner,
    arity_checking: arity_checking,
    spec_opts: spec_opts,
  }
end
run() click to toggle source
# File lib/opal/rspec/runner.rb, line 128
def run
  ENV['OPAL_CLI_RUNNERS_SERVER_STATIC_FOLDER'] = default_path
  cli.run
end
timeout=(_) click to toggle source
# File lib/opal/rspec/runner.rb, line 13
def timeout= _
  warn "deprecated: setting timeout has no effect"
end