Sha256: f55b5a05505f1219ffe9307ebd0af479df0809b3f6723cf6012fba41540a8126

Contents?: true

Size: 1.82 KB

Versions: 1

Compression:

Stored size: 1.82 KB

Contents

require 'opal/rspec/util'
require 'optparse'

module Opal; module RSpec; module Core; end; end; end
# Load necessary files under Opal's namespace, so as not to conflict with RSpec if it's being loaded too.
# Later, we will monkey-patch those methods.
::Opal::RSpec.load_namespaced __dir__ + "/../../../rspec-core/upstream/lib/rspec/core/invocations.rb", ::Opal
::Opal::RSpec.load_namespaced __dir__ + "/../../../rspec-core/upstream/lib/rspec/core/option_parser.rb", ::Opal

class Opal::RSpec::Core::Parser
  alias parser_before_opal parser

  def parser(options)
    parser_before_opal(options).tap do |parser|
      parser.banner = "Usage: opal-rspec [options] [files or directories]\n\n"

      parser.separator ''
      parser.separator '  **** Opal specific options ****'
      parser.separator ''

      parser.on('-R', '--runner NAME', 'Use a different JS runner (default is nodejs)') do |name|
        options[:runner] = name
      end

      parser.on('-q', '--rbrequire FILE', 'Require a file in MRI context before running Opal') do |name|
        options[:opal_rbrequires] ||= []
        options[:opal_rbrequires] << name
      end

      parser.on('-O', '--opal-opt FLAG', 'Run Opal with additional options (separate by `,` or specify multiple times)') do |name|
        options[:opal_options] ||= []
        options[:opal_options] += name.split(",")
      end

      parser.separator ''
      parser.separator '  **** Help ****'
      parser.separator ''
    end
  end
end

class Opal::RSpec::Core::Invocations::PrintVersion
  alias call_before_opal call

  def call(options, err, out)
    exitcode = call_before_opal(options, err, out)
    out.puts "Opal #{Opal::VERSION}"
    out.puts "  - opal-rspec #{Opal::RSpec::VERSION}"
    exitcode
  end
end

module Opal::RSpec::Support
  def self.require_rspec_core(arg)
    require "opal/rspec/"+arg
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opal-rspec-1.1.0.alpha3 lib/opal/rspec/configuration_parser.rb