Skip to content

Commit

Permalink
Implement location comment for outline steps. Release 0.1.99.14.
Browse files Browse the repository at this point in the history
  • Loading branch information
aslakhellesoy committed Jan 28, 2009
1 parent 98f7fa2 commit 1cb2bc8
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 19 deletions.
3 changes: 1 addition & 2 deletions Manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ examples/selenium/Rakefile
examples/selenium/features/search.feature
examples/selenium/features/step_definitons/stories_steps.rb
examples/self_test/README.textile
examples/self_test/Rakefile
examples/self_test/features/background/failing_background.feature
examples/self_test/features/background/failing_background_after_success.feature
examples/self_test/features/background/multiline_args_background.feature
Expand Down Expand Up @@ -217,7 +218,6 @@ lib/cucumber/rake/task.rb
lib/cucumber/step_definition.rb
lib/cucumber/step_mother.rb
lib/cucumber/version.rb
pom.xml
rails_generators/cucumber/USAGE
rails_generators/cucumber/cucumber_generator.rb
rails_generators/cucumber/templates/cucumber
Expand Down Expand Up @@ -272,4 +272,3 @@ spec/cucumber/treetop_parser/with_tags.feature
spec/cucumber/world/pending_spec.rb
spec/spec.opts
spec/spec_helper.rb
src/main/java/cukes/Cucumber.java
4 changes: 2 additions & 2 deletions cucumber.gemspec

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions features/cucumber_cli_outlines.feature
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ Feature: Cucumber command line
Feature: Outline Sample
Scenario Outline: Test state # features/outline_sample.feature:5
Given <state> without a table
Given <other_state> without a table
Given <state> without a table # features/step_definitions/sample_steps.rb:12
Given <other_state> without a table # features/step_definitions/sample_steps.rb:12
Examples: Rainbow colours
| state | other_state |
Expand Down
4 changes: 2 additions & 2 deletions gem_tasks/gemspec.rake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace :gemspec do
File.open('cucumber.gemspec', 'w') {|io| io.write($hoe.spec.to_ruby)}
puts "1) git commit -a -m \"Release #{Cucumber::VERSION::STRING}\""
puts "2) git tag -a \"v#{Cucumber::VERSION::STRING}\" -m \"Release #{Cucumber::VERSION::STRING}\""
puts "3) git push --tags"
puts "4) Bounce the version in version.rb"
puts "3) git push"
puts "4) git push --tags"
end
end
4 changes: 4 additions & 0 deletions lib/cucumber/ast/examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ def accept(visitor)
@outline_table.accept(visitor, nil)
end

def each_example_row(&proc)
@outline_table.each_cells_row(&proc)
end

def at_lines?(lines)
lines.empty? || lines.index(@line) || @outline_table.at_lines?(lines)
end
Expand Down
6 changes: 6 additions & 0 deletions lib/cucumber/ast/scenario_outline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ def accept(visitor)
end
end

def each_example_row(&proc)
@examples_array.each do |examples|
examples.each_example_row(&proc)
end
end

def execute_row(cells, visitor, &proc)
exception = nil

Expand Down
20 changes: 19 additions & 1 deletion lib/cucumber/ast/step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,31 @@ def execute_as_new(world, previous, visitor, row_line)

def accept(visitor)
execute(visitor)
visitor.visit_step_name(@keyword, @name, @status, @step_definition, source_indent)

if @status == :outline
step_definition = find_first_name_and_step_definition_from_examples(visitor)
else
step_definition = @step_definition
end
visitor.visit_step_name(@keyword, @name, @status, step_definition, source_indent)
@multiline_args.each do |multiline_arg|
visitor.visit_multiline_arg(multiline_arg, @status)
end
@exception
end

def find_first_name_and_step_definition_from_examples(visitor)
# @scenario is always a ScenarioOutline in this case
@scenario.each_example_row do |cells|
argument_hash = cells.to_hash
delimited_arguments = delimit_argument_names(argument_hash)
name = replace_name_arguments(delimited_arguments)
step_definition = visitor.step_definition(name) rescue nil
return step_definition if step_definition
end
nil
end

def to_sexp
[:step, @line, @keyword, @name, *@multiline_args.map{|arg| arg.to_sexp}]
end
Expand Down
4 changes: 4 additions & 0 deletions lib/cucumber/ast/table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ def rows
@raw[1..-1]
end

def each_cells_row(&proc)
cells_rows.each(&proc)
end

# For testing only
def to_sexp #:nodoc:
[:table, *cells_rows.map{|row| row.to_sexp}]
Expand Down
21 changes: 12 additions & 9 deletions lib/cucumber/formatter/console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@ module Console
FORMATS = Hash.new{|hash, format| hash[format] = method(format).to_proc}

def format_step(keyword, step_name, status, step_definition, source_indent)
line = if step_definition # nil for :outline
comment = if source_indent
c = (' # ' + step_definition.file_colon_line).indent(source_indent)
format_string(c, :comment)
else
''
end
keyword + " " + step_definition.format_args(step_name, format_for(status, :param)) + comment
comment = if source_indent
c = (' # ' + step_definition.file_colon_line).indent(source_indent)
format_string(c, :comment)
else
keyword + " " + step_name
''
end

begin
line = keyword + " " + step_definition.format_args(step_name, format_for(status, :param)) + comment
rescue
# It didn't match. This often happens for :outline steps
line = keyword + " " + step_name + comment
end

format_string(line, status)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/cucumber/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class VERSION #:nodoc:
MAJOR = 0
MINOR = 1
TINY = 99
PATCH = 13 # Set to nil for official release
PATCH = 14 # Set to nil for official release

STRING = [MAJOR, MINOR, TINY, PATCH].compact.join('.')
end
Expand Down

0 comments on commit 1cb2bc8

Please sign in to comment.