Sha256: 8207e6f063bd5a2a674536fc3472121826a2f7b6d4e9a1e01da84e5a331d489e

Contents?: true

Size: 1.74 KB

Versions: 5

Compression:

Stored size: 1.74 KB

Contents

require 'opal'
require 'opal-sprockets'
require 'opal/rspec/version'
require 'opal/rspec/sprockets_environment'
require 'opal/rspec/runner'

# Just register our opal code path with opal build tools
Opal.append_path File.expand_path('../../../lib-opal', __FILE__)
Opal.append_path File.expand_path('../../../stubs', __FILE__)

# Catch our git submodule included directories
%w{rspec rspec-core rspec-expectations rspec-mocks rspec-support}.each do |gem_name|
  Opal.append_path File.expand_path("../../../#{gem_name}/upstream/lib", __FILE__)
end

# Since we have better specs than before (and a script to deal with this), ignoring
Opal::Config.dynamic_require_severity = :ignore

module Opal
  module RSpec
    autoload :ProjectInitializer, 'opal/rspec/project_initializer'

    def self.spec_opts_code(spec_opts)
      code = []
      if spec_opts && !spec_opts.empty?
        code << 'RSpec.configure do |config|'

        if (match = /--(no-)?color\b/.match(spec_opts))
          color_value = !match.captures[0]
          # Have to use instance_variable_set because config.color= is designed to not allow overriding color once it's set, but
          # we do not yet have true SPEC_OPTS parsing via RSpec config to get it initially set
          code << "config.instance_variable_set(:@color, #{color_value})"
        end

        if (requires = spec_opts.scan(/(?:--require|-r) \S+/)).any?
          requires.map {|r| /--require (.*)/.match(r).captures[0]}.each do |req|
            code << %{require "#{req}"}
          end
        end

        if (match = /--format (\S+)/.match(spec_opts))
          formatter = match.captures[0]
          code << %{config.formatter = "#{formatter}"}
        end

        code << 'end'
      end
      code.join('; ')
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
opal-rspec-0.8.0 lib/opal/rspec.rb
opal-rspec-0.8.0.alpha3 lib/opal/rspec.rb
opal-rspec-0.8.0.alpha2 lib/opal/rspec.rb
opal-rspec-0.8.0.alpha1 lib/opal/rspec.rb
opal-rspec-0.7.1 lib/opal/rspec.rb