Permalink
View
@@ -12,6 +12,12 @@
* Make reporter.report an API (David Chelimsky)
* supports extension tools like interative_rspec
+* Changes
+ * change `config.color_enabled` (getter/setter/predicate) to `color` to align
+ with `--[no]-color` CLI option.
+ * `color_enabled` is still supported for now, but will likley be deprecated
+ in a 2.x release so we can remove it in 3.0.
+
* Bug fixes
* Make sure the `bar` in `--tag foo:bar` makes it to DRb (Aaron Gibralter)
* Fix bug where full descriptions of groups nested 3 deep were repeated.
@@ -8,8 +8,8 @@ class Configuration
class MustBeConfiguredBeforeExampleGroupsError < StandardError; end
- def self.define_predicate_for(name)
- alias_method "#{name}?", name
+ def self.define_predicate_for(*names)
+ names.each {|name| alias_method "#{name}?", name}
end
# @api private
@@ -78,7 +78,7 @@ def initialize
@mock_framework = nil
@files_to_run = []
@formatters = []
- @color_enabled = false
+ @color = false
@pattern = '**/*_spec.rb'
@failure_exit_code = 1
@backtrace_clean_patterns = DEFAULT_BACKTRACE_PATTERNS.dup
@@ -254,23 +254,27 @@ def full_backtrace=(true_or_false)
@backtrace_clean_patterns = true_or_false ? [] : DEFAULT_BACKTRACE_PATTERNS
end
- def color_enabled
- @color_enabled && output_to_tty?
+ def color
+ @color && output_to_tty?
end
- define_predicate_for :color_enabled
-
- def color_enabled=(bool)
+ def color=(bool)
return unless bool
- @color_enabled = true
+ @color = true
if bool && ::RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
unless ENV['ANSICON']
warn "You must use ANSICON 1.31 or later (http://adoxa.110mb.com/ansicon/) to use colour on Windows"
- @color_enabled = false
+ @color = false
end
end
end
+ # TODO - deprecate color_enabled - probably not until the last 2.x
+ # release before 3.0
+ alias_method :color_enabled, :color
+ alias_method :color_enabled=, :color=
+ define_predicate_for :color_enabled, :color
+
def libs=(libs)
libs.map {|lib| $LOAD_PATH.unshift lib}
end
@@ -6,7 +6,7 @@ def initialize(submitted_options)
def options
argv = []
- argv << "--color" if @submitted_options[:color_enabled]
+ argv << "--color" if @submitted_options[:color]
argv << "--profile" if @submitted_options[:profile_examples]
argv << "--backtrace" if @submitted_options[:full_backtrace]
argv << "--tty" if @submitted_options[:tty]
@@ -33,7 +33,7 @@ def parser(options)
end
parser.on('-c', '--[no-]color', '--[no-]colour', 'Enable color in the output') do |o|
- options[:color_enabled] = o
+ options[:color] = o
end
parser.on('-d', '--debugger', 'Enable debugging') do |o|
@@ -95,7 +95,7 @@ def config_options(argv=[])
# this is necessary to ensure that color works correctly on windows
config.should_receive(:error_stream=).ordered
config.should_receive(:output_stream=).ordered
- config.should_receive(:color_enabled=).ordered
+ config.should_receive(:color=).ordered
command_line.run(err, out) rescue nil
end
@@ -57,24 +57,24 @@
end
describe "-c, --color, and --colour" do
- it "sets :color_enabled => true" do
- parse_options('-c').should include(:color_enabled => true)
- parse_options('--color').should include(:color_enabled => true)
- parse_options('--colour').should include(:color_enabled => true)
+ it "sets :color => true" do
+ parse_options('-c').should include(:color => true)
+ parse_options('--color').should include(:color => true)
+ parse_options('--colour').should include(:color => true)
end
end
describe "--no-color" do
- it "sets :color_enabled => false" do
- parse_options('--no-color').should include(:color_enabled => false)
+ it "sets :color => false" do
+ parse_options('--no-color').should include(:color => false)
end
- it "overrides previous :color_enabled => true" do
- parse_options('--color', '--no-color').should include(:color_enabled => false)
+ it "overrides previous :color => true" do
+ parse_options('--color', '--no-color').should include(:color => false)
end
- it "gets overriden by a subsequent :color_enabled => true" do
- parse_options('--no-color', '--color').should include(:color_enabled => true)
+ it "gets overriden by a subsequent :color => true" do
+ parse_options('--no-color', '--color').should include(:color => true)
end
end
@@ -266,7 +266,7 @@
File.open("~/.rspec", "w") {|f| f << "--color"}
ENV["SPEC_OPTS"] = "--debug"
options = parse_options("--drb")
- options[:color_enabled].should be_true
+ options[:color].should be_true
options[:line_numbers].should eq(["37"])
options[:debug].should be_true
options[:drb].should be_true
@@ -320,7 +320,7 @@
File.open("./custom.opts", "w") {|f| f << "--color"}
options = parse_options("-O", "./custom.opts")
options[:format].should be_nil
- options[:color_enabled].should be_true
+ options[:color].should be_true
end
end
end
View
@@ -75,7 +75,7 @@ def in_editor?
# runtime options
c.treat_symbols_as_metadata_keys_with_true_values = true
- c.color_enabled = !in_editor?
+ c.color = !in_editor?
c.filter_run :focus
c.run_all_when_everything_filtered = true
c.filter_run_excluding :ruby => lambda {|version|

0 comments on commit a862270

Please sign in to comment.