Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Support example.feature:10:20:30 syntax for running a feature at mult…

…iple lines
  • Loading branch information...
commit 307e11c46fc0440e761aaf7768d7349ca5f5aa85 1 parent 3836795
Joseph Wilk authored
Showing with 29 additions and 17 deletions.
  1. +1 −0  History.txt
  2. +2 −2 lib/cucumber/cli.rb
  3. +26 −15 spec/cucumber/cli_spec.rb
1  History.txt
View
@@ -10,6 +10,7 @@ Will run addition.feature at line 15 and divison.feature at line 6
* New webrat step defintions to wrap the new selects_time, selects_date, and selects_datetime methods. (Ben Mabey)
* Try to load webrat gem if it's not installed as a plugin (Aslak Hellesøy)
* Support example.feature:20 syntax for running features at a line number. (#88 Joseph Wilk)
+* Support example.feature:10:20:30 syntax for running a feature at multiple lines. (#88 Joseph Wilk)
=== Bugfixes
* Features written using Ruby where breaking due to missing a line number (#91 Joseph Wilk)
4 lib/cucumber/cli.rb
View
@@ -177,9 +177,9 @@ def execute!(step_mother, executor, features)
def extract_and_store_line_numbers(file_arguments)
@options[:lines_for_features] = Hash.new{|k,v| k[v] = []}
file_arguments.map do |arg|
- _, file, line = */^([\w\W]*):(\d+)$/.match(arg)
+ _, file, lines = */^([\w\W]*?):([\d:]+)$/.match(arg)
unless file.nil?
- @options[:lines_for_features][file] << line.to_i
+ @options[:lines_for_features][file] += lines.split(':').map { |line| line.to_i }
arg = file
end
arg
41 spec/cucumber/cli_spec.rb
View
@@ -227,26 +227,37 @@ def given_cucumber_yml_defined_as(hash)
cli.execute!(stub('step mother'), mock_executor, stub('features'))
end
- it "should extract line numbers attached to the end of feature file args" do
- cli = CLI.new
- cli.parse_options!(%w{example.feature:10})
+ describe "example.feature:line file arguments" do
+
+ it "should extract line numbers" do
+ cli = CLI.new
+ cli.parse_options!(%w{example.feature:10})
- cli.options[:lines_for_features]['example.feature'].should == [10]
- end
+ cli.options[:lines_for_features]['example.feature'].should == [10]
+ end
- it "should remove line numbers attached to the end of feature file" do
- cli = CLI.new
- cli.parse_options!(%w{example.feature:10})
+ it "should remove line numbers" do
+ cli = CLI.new
+ cli.parse_options!(%w{example.feature:10})
- cli.paths.should == ["example.feature"]
- end
+ cli.paths.should == ["example.feature"]
+ end
- it "should support multiple feature:line numbers" do
- cli = CLI.new
- cli.parse_options!(%w{example.feature:11 another_example.feature:12})
+ it "should support multiple feature:line numbers" do
+ cli = CLI.new
+ cli.parse_options!(%w{example.feature:11 another_example.feature:12})
- cli.options[:lines_for_features].should == {'another_example.feature' => [12], 'example.feature' => [11]}
- end
+ cli.options[:lines_for_features].should == {'another_example.feature' => [12], 'example.feature' => [11]}
+ end
+
+ it "should accept multiple line numbers for a single feature" do
+ cli = CLI.new
+ cli.parse_options!(%w{example.feature:11:12})
+
+ cli.options[:lines_for_features].should == {'example.feature' => [11, 12]}
+ end
+
+ end
it "should search for all features in the specified directory" do
cli = CLI.new
Please sign in to comment.
Something went wrong with that request. Please try again.