Skip to content

Commit

Permalink
Change internally used --autotest option to --tty
Browse files Browse the repository at this point in the history
- Closes #224.
  • Loading branch information
dchelimsky committed Nov 25, 2010
1 parent 921bb6a commit 285b438
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions lib/rspec/core/configuration.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def self.add_setting(name, opts={})
add_setting :files_to_run add_setting :files_to_run
add_setting :include_or_extend_modules add_setting :include_or_extend_modules
add_setting :backtrace_clean_patterns add_setting :backtrace_clean_patterns
add_setting :autotest add_setting :tty


def initialize def initialize
@color_enabled = false @color_enabled = false
Expand Down Expand Up @@ -149,7 +149,7 @@ def full_backtrace=(bool)
end end


def color_enabled def color_enabled
@color_enabled && (output_to_tty? || autotest?) @color_enabled && output_to_tty?
end end


def color_enabled? def color_enabled?
Expand Down Expand Up @@ -346,7 +346,7 @@ def raise_if_rspec_1_is_loaded


def output_to_tty? def output_to_tty?
begin begin
settings[:output_stream].tty? output_stream.tty? || tty?
rescue NoMethodError rescue NoMethodError
false false
end end
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/core/configuration_options.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def drb_argv
argv << "--color" if options[:color_enabled] argv << "--color" if options[:color_enabled]
argv << "--profile" if options[:profile_examples] argv << "--profile" if options[:profile_examples]
argv << "--backtrace" if options[:full_backtrace] argv << "--backtrace" if options[:full_backtrace]
argv << "--autotest" if options[:autotest] argv << "--tty" if options[:tty]
argv << "--fail-fast" if options[:fail_fast] argv << "--fail-fast" if options[:fail_fast]
argv << "--format" << options[:formatter] if options[:formatter] argv << "--format" << options[:formatter] if options[:formatter]
argv << "--line_number" << options[:line_number] if options[:line_number] argv << "--line_number" << options[:line_number] if options[:line_number]
Expand Down
4 changes: 2 additions & 2 deletions lib/rspec/core/option_parser.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def parser(options)
options[:drb_port] = o.to_i options[:drb_port] = o.to_i
end end


parser.on('--autotest') do |o| parser.on('--tty') do |o|
options[:autotest] = true options[:tty] = true
end end


parser.on('--fail-fast', 'Use the fail_fast option to tell RSpec to abort the run on first failure.') do |o| parser.on('--fail-fast', 'Use the fail_fast option to tell RSpec to abort the run on first failure.') do |o|
Expand Down
4 changes: 2 additions & 2 deletions spec/rspec/core/configuration_options_spec.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ def options_from_args(*args)
it "renders all the original arguments except --drb" do it "renders all the original arguments except --drb" do
File.stub(:exist?) { true } File.stub(:exist?) { true }
IO.stub(:read) { "--drb --color" } IO.stub(:read) { "--drb --color" }
config_options_object(*%w[ --autotest --format s --line_number 1 --example pattern --profile --backtrace ]). config_options_object(*%w[ --tty --format s --line_number 1 --example pattern --profile --backtrace ]).
drb_argv.should eq(%w[ --color --profile --backtrace --autotest --format s --line_number 1 --example pattern ]) drb_argv.should eq(%w[ --color --profile --backtrace --tty --format s --line_number 1 --example pattern ])
end end
end end


Expand Down
8 changes: 4 additions & 4 deletions spec/rspec/core/configuration_spec.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def that_thing
it "does not set color_enabled" do it "does not set color_enabled" do
config.output_stream = StringIO.new config.output_stream = StringIO.new
config.output_stream.stub(:tty?) { false } config.output_stream.stub(:tty?) { false }
config.autotest = false config.tty = false
config.color_enabled = true config.color_enabled = true
config.color_enabled.should be_false config.color_enabled.should be_false
end end
Expand All @@ -266,17 +266,17 @@ def that_thing
it "does not set color_enabled" do it "does not set color_enabled" do
config.output_stream = StringIO.new config.output_stream = StringIO.new
config.output_stream.stub(:tty?) { true } config.output_stream.stub(:tty?) { true }
config.autotest = false config.tty = false
config.color_enabled = true config.color_enabled = true
config.color_enabled.should be_true config.color_enabled.should be_true
end end
end end


context "with autotest output" do context "with tty set" do
it "does not set color_enabled" do it "does not set color_enabled" do
config.output_stream = StringIO.new config.output_stream = StringIO.new
config.output_stream.stub(:tty?) { false } config.output_stream.stub(:tty?) { false }
config.autotest = true config.tty = true
config.color_enabled = true config.color_enabled = true
config.color_enabled.should be_true config.color_enabled.should be_true
end end
Expand Down

0 comments on commit 285b438

Please sign in to comment.