Skip to content

Commit

Permalink
Don't clobber formatter options when generating drb_argv
Browse files Browse the repository at this point in the history
- fixes bug in which --drb + formatters would raise an error when not
  running in drb
- Closes #267
  • Loading branch information
dchelimsky committed Jan 7, 2011
1 parent 27deb82 commit 3e17efe
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
1 change: 1 addition & 0 deletions History.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

* Bug fixes
* fix dom IDs in HTML formatter (Brian Faherty)
* fix bug with --drb + formatters when not running in drb

### 2.4.0 / 2011-01-02

Expand Down
18 changes: 8 additions & 10 deletions lib/rspec/core/configuration_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,18 @@ def configure(config)

def drb_argv
argv = []
argv << "--color" if options[:color_enabled]
argv << "--profile" if options[:profile_examples]
argv << "--backtrace" if options[:full_backtrace]
argv << "--tty" if options[:tty]
argv << "--fail-fast" if options[:fail_fast]
argv << "--color" if options[:color_enabled]
argv << "--profile" if options[:profile_examples]
argv << "--backtrace" if options[:full_backtrace]
argv << "--tty" if options[:tty]
argv << "--fail-fast" if options[:fail_fast]
argv << "--line_number" << options[:line_number] if options[:line_number]
argv << "--options" << options[:custom_options_file] if options[:custom_options_file]
argv << "--options" << options[:custom_options_file] if options[:custom_options_file]
argv << "--example" << options[:full_description].source if options[:full_description]
if options[:formatters]
options[:formatters].each do |pair|
argv << "--format" << pair.shift
unless pair.empty?
argv << "--out" << pair.shift
end
argv << "--format" << pair[0]
argv << "--out" << pair[1] if pair[1]
end
end
(options[:libs] || []).each do |path|
Expand Down
20 changes: 20 additions & 0 deletions spec/rspec/core/configuration_options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def parse_options(*args)
it "does not send --drb back to the parser after parsing options" do
config_options_object("--drb", "--color").drb_argv.should_not include("--drb")
end

end

describe "files_or_directories_to_run" do
Expand Down Expand Up @@ -204,6 +205,25 @@ def parse_options(*args)
config_options_object(*%w[--options custom.opts]).drb_argv.should include("--options", "custom.opts")
end

context "with formatters" do
it "includes the formatters" do
coo = config_options_object("--format", "d")
coo.drb_argv.should eq(["--format", "d"])
end

it "leaves formatters intact" do
coo = config_options_object("--format", "d")
coo.drb_argv
coo.options[:formatters].should eq([["d"]])
end

it "leaves output intact" do
coo = config_options_object("--format", "p", "--out", "foo.txt", "--format", "d")
coo.drb_argv
coo.options[:formatters].should eq([["p","foo.txt"],["d"]])
end
end

context "--drb specified in ARGV" do
it "renders all the original arguments except --drb" do
config_options_object(*%w[ --drb --color --format s --line_number 1 --example pattern --profile --backtrace -I path/a -I path/b --require path/c --require path/d]).
Expand Down

0 comments on commit 3e17efe

Please sign in to comment.