<% spec_opts = ENV['SPEC_OPTS'] if spec_opts && !spec_opts.empty? %> 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 %> config.instance_variable_set(:@color, <%=color_value.to_s%>) <% end if (requires = spec_opts.scan(/--require \S+/)).any? requires.map {|r| /--require (.*)/.match(r).captures[0]}.each do |req| %> require "<%= req %>" <% end end if (match = spec_opts.scan(/(?:--format (\S+)|-f ?(\S+))/).flatten.compact).any? %> <%= match.inspect %>.each { |f| config.add_formatter f } <% end %> end <% end %>