Skip to content

Commit

Permalink
Merge PR #864 and the fixes for the tags and comments handling.
Browse files Browse the repository at this point in the history
Also update the History.md.
  • Loading branch information
brasmusson committed Jun 7, 2015
2 parents 6730394 + 95bcefa commit 19801f2
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 0 deletions.
1 change: 1 addition & 0 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

### Bugfixes

* Pass tags and comments to the legacy api formatters correctly, fixes [864](https://github.com/cucumber/cucumber/pull/864) (@brasmusson).
* Properly close HTML formatter pre tag for leading comment ([828](https://github.com/cucumber/cucumber/issues/828), [854](https://github.com/cucumber/cucumber/pull/854) @pdswan)
* Make the HTML formatter handle failures in hooks ([835](https://github.com/cucumber/cucumber/issues/835) @brasmusson)
* Fix the check for multiple formatters using stdout ([826](https://github.com/cucumber/cucumber/pull/826) @brasmusson)
Expand Down
7 changes: 7 additions & 0 deletions lib/cucumber/formatter/legacy_api/adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ def after_hook(*)

def before
formatter.before_background Ast::Background.new(feature, node)
Ast::Comments.new(node.comments).accept(formatter)
formatter.background_name node.keyword, node.legacy_conflated_name_and_description, node.location.to_s, indent.of(node)
before_hook_results.accept(formatter)
self
Expand Down Expand Up @@ -520,6 +521,7 @@ def after_test_case(*);end

def before
formatter.before_feature_element(node)
Ast::Comments.new(node.comments).accept(formatter)
Ast::Tags.new(node.tags).accept(formatter)
formatter.scenario_name node.keyword, node.legacy_conflated_name_and_description, node.location.to_s, indent.of(node)
before_hook_results.accept(formatter)
Expand Down Expand Up @@ -594,6 +596,7 @@ def steps

def before
formatter.before_feature_element(node)
Ast::Comments.new(node.comments).accept(formatter)
Ast::Tags.new(node.tags).accept(formatter)
formatter.scenario_name node.keyword, node.legacy_conflated_name_and_description, node.location.to_s, indent.of(node)
OutlineStepsPrinter.new(formatter, configuration, indent).print(node)
Expand Down Expand Up @@ -694,6 +697,8 @@ def after

def before
formatter.before_examples(node)
Ast::Comments.new(node.comments).accept(formatter)
Ast::Tags.new(node.tags).accept(formatter)
formatter.examples_name(node.keyword, node.legacy_conflated_name_and_description)
formatter.before_outline_table(legacy_table)
if !configuration.expand?
Expand Down Expand Up @@ -804,6 +809,7 @@ def legacy_table_row
end

def before
Ast::Comments.new(node.comments).accept(formatter)
formatter.before_table_row(node)
self
end
Expand All @@ -823,6 +829,7 @@ def after
class TableRowPrinter < TableRowPrinterBase
def before
before_hook_results.accept(formatter)
Ast::Comments.new(node.comments).accept(formatter)
formatter.before_table_row(node)
self
end
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/formatter/legacy_api/ast.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def describe_exception_to(formatter)

def accept(formatter)
formatter.before_step(self)
Ast::Comments.new(step.comments).accept(formatter)
messages.each { |message| formatter.puts(message) }
embeddings.each { |embedding| embedding.send_to_formatter(formatter) }
formatter.before_step_result *step_result_attributes
Expand Down
11 changes: 11 additions & 0 deletions spec/cucumber/formatter/html_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,17 @@ module Formatter
end
end

describe "with a comment at scenario level" do
define_feature <<-FEATURE
Feature: Foo
# Healthy Scenario
Scenario:
Given passing
FEATURE

it { expect(@doc).to have_css_node('.scenario .comment', /Healthy Scenario/) }
end

describe "with a tag" do
define_feature <<-FEATURE
@foo
Expand Down
38 changes: 38 additions & 0 deletions spec/cucumber/formatter/legacy_api/adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,8 @@ def after_hooks(source)
:after_steps,
:before_examples_array,
:before_examples,
:before_tags,
:after_tags,
:examples_name,
:before_outline_table,
:before_table_row,
Expand Down Expand Up @@ -522,6 +524,8 @@ def after_hooks(source)
:after_steps,
:before_examples_array,
:before_examples,
:before_tags,
:after_tags,
:examples_name,
:before_outline_table,
:before_table_row,
Expand Down Expand Up @@ -606,6 +610,8 @@ def after_hooks(source)
:after_steps,
:before_examples_array,
:before_examples,
:before_tags,
:after_tags,
:examples_name,
:before_outline_table,
:before_table_row,
Expand Down Expand Up @@ -635,6 +641,8 @@ def after_hooks(source)
:after_steps,
:before_examples_array,
:before_examples,
:before_tags,
:after_tags,
:examples_name,
:before_outline_table,
:before_table_row,
Expand Down Expand Up @@ -701,6 +709,8 @@ def after_hooks(source)
:after_steps,
:before_examples_array,
:before_examples,
:before_tags,
:after_tags,
:examples_name,
:before_outline_table,
:before_table_row,
Expand Down Expand Up @@ -775,6 +785,8 @@ def after_hooks(source)
:after_steps,
:before_examples_array,
:before_examples,
:before_tags,
:after_tags,
:examples_name,
:before_outline_table,
:before_table_row,
Expand All @@ -790,6 +802,8 @@ def after_hooks(source)
:after_outline_table,
:after_examples,
:before_examples,
:before_tags,
:after_tags,
:examples_name,
:before_outline_table,
:before_table_row,
Expand Down Expand Up @@ -936,6 +950,8 @@ def after_hooks(source)
:after_steps,
:before_examples_array,
:before_examples,
:before_tags,
:after_tags,
:examples_name,
:before_outline_table,
:before_table_row,
Expand Down Expand Up @@ -1003,6 +1019,8 @@ def after_hooks(source)
:after_steps,
:before_examples_array,
:before_examples,
:before_tags,
:after_tags,
:examples_name,
:before_outline_table,
:before_table_row,
Expand Down Expand Up @@ -1058,6 +1076,8 @@ def after_hooks(source)
:after_steps,
:before_examples_array,
:before_examples,
:before_tags,
:after_tags,
:examples_name,
:before_outline_table,
:before_table_row,
Expand Down Expand Up @@ -1123,6 +1143,8 @@ def after_hooks(source)
:after_steps,
:before_examples_array,
:before_examples,
:before_tags,
:after_tags,
:examples_name,
:before_outline_table,
:before_table_row,
Expand Down Expand Up @@ -1184,6 +1206,8 @@ def after_hooks(source)
:after_steps,
:before_examples_array,
:before_examples,
:before_tags,
:after_tags,
:examples_name,
:before_outline_table,
:before_table_row,
Expand All @@ -1199,6 +1223,8 @@ def after_hooks(source)
:after_outline_table,
:after_examples,
:before_examples,
:before_tags,
:after_tags,
:examples_name,
:before_outline_table,
:before_table_row,
Expand Down Expand Up @@ -1258,6 +1284,8 @@ def after_hooks(source)
:after_steps,
:before_examples_array,
:before_examples,
:before_tags,
:after_tags,
:examples_name,
:before_outline_table,
:before_table_row,
Expand Down Expand Up @@ -1287,6 +1315,8 @@ def after_hooks(source)
:after_steps,
:before_examples_array,
:before_examples,
:before_tags,
:after_tags,
:examples_name,
:before_outline_table,
:before_table_row,
Expand Down Expand Up @@ -1339,6 +1369,8 @@ def after_hooks(source)
:after_steps,
:before_examples_array,
:before_examples,
:before_tags,
:after_tags,
:examples_name,
:before_outline_table,
:before_table_row,
Expand Down Expand Up @@ -1456,6 +1488,8 @@ def after_hooks(source)
:after_steps,
:before_examples_array,
:before_examples,
:before_tags,
:after_tags,
:examples_name,
:before_outline_table,
:scenario_name,
Expand Down Expand Up @@ -1660,6 +1694,8 @@ def apply_before_hooks(test_case)
:after_steps,
:before_examples_array,
:before_examples,
:before_tags,
:after_tags,
:examples_name,
:before_outline_table,
:before_table_row,
Expand Down Expand Up @@ -1814,6 +1850,8 @@ def apply_after_hooks(test_case)
:after_steps,
:before_examples_array,
:before_examples,
:before_tags,
:after_tags,
:examples_name,
:before_outline_table,
:before_table_row,
Expand Down
96 changes: 96 additions & 0 deletions spec/cucumber/formatter/pretty_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,102 @@ module Formatter
1 scenario (1 passed)
2 steps (2 passed)
OUTPUT
end
end

describe "with tags on all levels" do
define_feature <<-FEATURE
@tag1
Feature:
@tag2
Scenario:
Given this step passes
@tag3
Scenario Outline:
Given this step passes
@tag4
Examples:
| dummy |
| dummy |
FEATURE


it "includes the tags in the output " do
expect( @out.string ).to include <<OUTPUT
@tag1
Feature:
@tag2
Scenario:
Given this step passes
@tag3
Scenario Outline:
Given this step passes
@tag4
Examples:
| dummy |
| dummy |
OUTPUT
end
end

describe "with comments on all levels" do
define_feature <<-FEATURE
#comment1
Feature:
#comment2
Background:
#comment3
Given this step passes
#comment4
Scenario:
#comment5
Given this step passes
#comment6
| dummy |
#comment7
Scenario Outline:
#comment8
Given this step passes
#comment9
Examples:
#comment10
| dummy |
#comment11
| dummy |
FEATURE


it "includes the all comments except for data table rows in the output " do
expect( @out.string ).to include <<OUTPUT
#comment1
Feature:
#comment2
Background:
#comment3
Given this step passes
#comment4
Scenario:
#comment5
Given this step passes
| dummy |
#comment7
Scenario Outline:
#comment8
Given this step passes
#comment9
Examples:
#comment10
| dummy |
#comment11
| dummy |
OUTPUT
end
end
Expand Down

0 comments on commit 19801f2

Please sign in to comment.