Module: Opal::RSpec
- Defined in:
- lib/opal/rspec.rb,
lib/opal/rspec/runner.rb,
lib/opal/rspec/locator.rb,
lib/opal/rspec/version.rb,
lib/opal/rspec/rake_task.rb,
lib/opal/rspec/cached_environment.rb,
lib/opal/rspec/project_initializer.rb,
lib/opal/rspec/sprockets_environment.rb
Defined Under Namespace
Classes: CachedEnvironment, Locator, ProjectInitializer, RakeTask, Runner, SprocketsEnvironment
Constant Summary collapse
- VERSION =
'1.0.0'
Class Method Summary collapse
Class Method Details
.spec_opts_code(spec_opts) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/opal/rspec.rb', line 22 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 |