Permalink
Browse files

Removed the --line option now that we have a better way to specify lines

  • Loading branch information...
1 parent 2c6582c commit c679c8356898cc27c7f56f9bcfcb7b71aaf0fd3e @aslakhellesoy aslakhellesoy committed Nov 18, 2008
Showing with 16 additions and 41 deletions.
  1. +1 −0 .gitignore
  2. +2 −2 History.txt
  3. +0 −4 lib/cucumber/cli.rb
  4. +1 −15 lib/cucumber/executor.rb
  5. +12 −20 spec/cucumber/executor_spec.rb
View
1 .gitignore
@@ -4,6 +4,7 @@ doc
*.log
*.pid
.eprj
+.tmtags
*~
.DS_Store
*.swp
View
4 History.txt
@@ -9,15 +9,15 @@ Will run addition.feature at line 15 and divison.feature at line 6
=== New features
* 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)
+* Support example.feature:20 or example.feature:10:20:30 syntax for running features at specific line number(s). (#88 Joseph Wilk)
=== Bugfixes
* Features written using Ruby where breaking due to missing a line number (#91 Joseph Wilk)
* Directly creating a Table meant the scenario table header was never set which was causing a formatter error (#91 Joseph Wilk)
=== Removed features
* Step definition without a block being treated as pending (#64 Joseph Wilk)
+* The --line option has been removed. Use the new file.feature:line format instead.
== 0.1.9
View
4 lib/cucumber/cli.rb
@@ -56,9 +56,6 @@ def parse_options!(args)
@options[:require] ||= []
@options[:require] << v
end
- opts.on("-l LINE", "--line LINE", "Only execute the scenario at the given line") do |v|
- @options[:line] = v
- end
opts.on("-s SCENARIO", "--scenario SCENARIO", "Only execute the scenario with the given name.",
"If this option is given more than once, run all",
"the specified scenarios.") do |v|
@@ -165,7 +162,6 @@ def execute!(step_mother, executor, features)
executor.formatters = build_formatter_broadcaster(step_mother)
require_files
load_plain_text_features(features)
- executor.line = @options[:line].to_i if @options[:line]
executor.lines_for_features = @options[:lines_for_features]
executor.scenario_names = @options[:scenario_names] if @options[:scenario_names]
executor.visit_features(features)
View
16 lib/cucumber/executor.rb
@@ -6,10 +6,6 @@ class Executor
attr_accessor :formatters
attr_writer :scenario_names, :lines_for_features
- def line=(line)
- @line = line
- end
-
def initialize(step_mother)
@world_proc = lambda do
Object.new
@@ -43,7 +39,6 @@ def register_after_step_proc(&proc)
end
def visit_features(features)
- raise "Line number can only be specified when there is 1 feature. There were #{features.length}." if @line && features.length != 1
formatters.visit_features(features)
features.accept(self)
formatters.dump
@@ -98,7 +93,6 @@ def execute_scenario(scenario)
def accept_scenario?(scenario)
scenario_at_specified_line?(scenario) &&
- scenario_at_specified_line_old?(scenario) &&
scenario_has_specified_name?(scenario)
end
@@ -168,21 +162,13 @@ def executing_unprepared_row_scenario?(scenario)
end
def scenario_at_specified_line?(scenario)
- if !@line && lines_defined_for_current_feature?
+ if lines_defined_for_current_feature?
@lines_for_features[@feature_file].inject(false) { |at_line, line| at_line || scenario.at_line?(line) }
else
true
end
end
- def scenario_at_specified_line_old?(scenario)
- if @line
- scenario.at_line?(@line)
- else
- true
- end
- end
-
def scenario_has_specified_name?(scenario)
if @scenario_names && !@scenario_names.empty?
@scenario_names.include?(scenario.name)
View
32 spec/cucumber/executor_spec.rb
@@ -51,15 +51,6 @@ def mock_scenario(stubs = {})
})
end
-# it "should allow calling of other steps from steps" do
-# @executor.register_step_proc("call me please") { @x = 1 }
-# @executor.register_step_proc("I will call you") { @executor.register_step_proc("call me please") }
-# @executor.register_step_proc(/I should owe (\d*) cucumbers/) { |n| @n.should == -n.to_i }
-# @feature.accept(@executor)
-# @formatters.each { |formatter| formatter.dump }
-# @io.string.should == "...\n"
-# end
-
describe "visiting feature" do
it "should set the feature file being visited" do
@@ -161,21 +152,22 @@ def mock_row_scenario(stubs = {})
describe "without having first run the matching regular scenario" do
before(:each) do
- @scenario = Tree::Scenario.new(nil, 'test', 1)
- @executor.line=5
- @executor.visit_regular_scenario(@scenario)
+ @regular_scenario = Tree::Scenario.new(nil, 'test', 1)
+ @executor.lines_for_features = Hash.new([5])
+ @executor.visit_regular_scenario(@regular_scenario)
end
it "should run the regular scenario before the row scenario" do
- @scenario.should_receive(:accept)
-
- @executor.visit_row_scenario(mock_row_scenario(:name => 'test', :at_line? => true, :accept => nil))
+ @regular_scenario.should_receive(:accept)
+ row_scenario = mock_row_scenario(:name => 'test', :at_line? => true)
+ row_scenario.should_receive(:accept)
+ @executor.visit_row_scenario(row_scenario)
end
it "should run the row scenario after running the regular scenario" do
- mock_row_scenario(:at_line? => true).should_receive(:accept)
-
- @executor.visit_row_scenario(mock_row_scenario)
+ row_scenario = mock_row_scenario(:at_line? => true)
+ row_scenario.should_receive(:accept)
+ @executor.visit_row_scenario(row_scenario)
end
end
@@ -198,7 +190,7 @@ def mock_row_scenario(stubs = {})
it "should check if a scenario is at the specified line number" do
mock_scenario = mock('scenario', :null_object => true)
- @executor.line = 1
+ @executor.lines_for_features = Hash.new([1])
mock_scenario.should_receive(:at_line?).with(1)
@@ -219,7 +211,7 @@ def mock_row_scenario(stubs = {})
it "should not check feature line numbers if --line is already set" do
@executor.instance_variable_set('@feature_file', 'sell_cucumbers.feature')
@executor.lines_for_features = {'sell_cucumbers.feature' => [11]}
- @executor.line = 5
+ @executor.lines_for_features = Hash.new([5])
mock_scenario.should_not_receive(:at_line?).with(11).and_return(false)

0 comments on commit c679c83

Please sign in to comment.