Skip to content

Commit

Permalink
Support example.feature:10:20:30 syntax for running a feature at mult…
Browse files Browse the repository at this point in the history
…iple lines
  • Loading branch information
Joseph Wilk committed Nov 18, 2008
1 parent 3836795 commit 307e11c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
1 change: 1 addition & 0 deletions History.txt
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/cucumber/cli.rb
Expand Up @@ -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
Expand Down
41 changes: 26 additions & 15 deletions spec/cucumber/cli_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit 307e11c

Please sign in to comment.