Browse files

Allow tag filtering when using drb

- Closes #277.
  • Loading branch information...
1 parent c4a852d commit 07fcb320f7950e58da6d159effd00121927ebae4 @monocle monocle committed with dchelimsky Jan 14, 2011
View
1 features/Changelog.md
@@ -9,6 +9,7 @@
* Bug fixes
* fix dom IDs in HTML formatter (Brian Faherty)
* fix bug with --drb + formatters when not running in drb
+ * include --tag options in drb args (monocle)
### 2.4.0 / 2011-01-02
View
7 lib/rspec/core/configuration_options.rb
@@ -39,6 +39,11 @@ def drb_argv
argv << "--line_number" << options[:line_number] if options[:line_number]
argv << "--options" << options[:custom_options_file] if options[:custom_options_file]
argv << "--example" << options[:full_description].source if options[:full_description]
+ if options[:filter]
+ options[:filter].each_pair do |k, v|
+ argv << "--tag" << k.to_s
@cs3b
cs3b added a note Apr 28, 2011

problem appear when using sport (drb) and filtering by tag value
above line, forgot about tag value, example

--tag status:wip

only status is passed (key without value)

Running tests with args ["--color", "--tag", "status", "spec/acceptance"]

the one of solution could look like

if options[:filter]
  options[:filter].each_pair do |k, v|
    argv << "--tag" << (v == true ? k.to_s : [k.to_s,v].join(':') )
  end
end

then we have correct params

Running tests with args ["--color", "--tag", "status:wip", "spec/acceptance"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ end
+ end
if options[:formatters]
options[:formatters].each do |pair|
argv << "--format" << pair[0]
@@ -107,7 +112,7 @@ def args_from_options_file(path)
config_string = options_file_as_erb_string(path)
config_string.split(/\n+/).map {|l| l.split}.flatten
end
-
+
def options_file_as_erb_string(path)
require 'erb'
ERB.new(IO.read(path)).result(binding)
View
13 spec/rspec/core/configuration_options_spec.rb
@@ -205,6 +205,19 @@ def parse_options(*args)
config_options_object(*%w[--options custom.opts]).drb_argv.should include("--options", "custom.opts")
end
+ context "with tags" do
+ it "includes the tags" do
+ coo = config_options_object("--tag", "tag")
+ coo.drb_argv.should eq(["--tag", "tag"])
+ end
+
+ it "leaves tags intact" do
+ coo = config_options_object("--tag", "tag")
+ coo.drb_argv
+ coo.options[:filter].should eq( {:tag=>true} )
+ end
+ end
+
context "with formatters" do
it "includes the formatters" do
coo = config_options_object("--format", "d")

0 comments on commit 07fcb32

Please sign in to comment.