Class: Cucumber::Formatter::GherkinFormatterAdapter
- Defined in:
- lib/cucumber/formatter/gherkin_formatter_adapter.rb
Overview
Adapts Cucumber formatter events to Gherkin formatter events This class will disappear when Cucumber is based on Gherkin’s model.
Instance Method Summary collapse
- #after_feature(feature) ⇒ Object
- #before_background(background) ⇒ Object
- #before_examples(examples) ⇒ Object
- #before_feature(feature) ⇒ Object
- #before_feature_element(feature_element) ⇒ Object
- #before_features(features) ⇒ Object
- #before_step(step) ⇒ Object
- #before_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background) ⇒ Object
- #embed(file, mime_type) ⇒ Object
-
#initialize(gherkin_formatter, print_emtpy_match) ⇒ GherkinFormatterAdapter
constructor
A new instance of GherkinFormatterAdapter.
Constructor Details
#initialize(gherkin_formatter, print_emtpy_match) ⇒ GherkinFormatterAdapter
Returns a new instance of GherkinFormatterAdapter.
9 10 11 12 |
# File 'lib/cucumber/formatter/gherkin_formatter_adapter.rb', line 9 def initialize(gherkin_formatter, print_emtpy_match) @gf = gherkin_formatter @print_emtpy_match = print_emtpy_match end |
Instance Method Details
#after_feature(feature) ⇒ Object
75 76 77 |
# File 'lib/cucumber/formatter/gherkin_formatter_adapter.rb', line 75 def after_feature(feature) @gf.eof end |
#before_background(background) ⇒ Object
22 23 24 25 26 |
# File 'lib/cucumber/formatter/gherkin_formatter_adapter.rb', line 22 def before_background(background) @outline = false @gf.steps(background.raw_steps) @gf.background(background.gherkin_statement) end |
#before_examples(examples) ⇒ Object
71 72 73 |
# File 'lib/cucumber/formatter/gherkin_formatter_adapter.rb', line 71 def before_examples(examples) @gf.examples(examples.gherkin_statement) end |
#before_feature(feature) ⇒ Object
17 18 19 20 |
# File 'lib/cucumber/formatter/gherkin_formatter_adapter.rb', line 17 def before_feature(feature) @gf.uri(feature.file) @gf.feature(feature.gherkin_statement) end |
#before_feature_element(feature_element) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/cucumber/formatter/gherkin_formatter_adapter.rb', line 28 def before_feature_element(feature_element) @gf.steps(feature_element.raw_steps) case(feature_element) when Ast::Scenario @outline = false @gf.scenario(feature_element.gherkin_statement) when Ast::ScenarioOutline @outline = true @gf.scenario_outline(feature_element.gherkin_statement) else raise "Bad type: #{feature_element.class}" end end |
#before_features(features) ⇒ Object
14 15 |
# File 'lib/cucumber/formatter/gherkin_formatter_adapter.rb', line 14 def before_features(features) end |
#before_step(step) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/cucumber/formatter/gherkin_formatter_adapter.rb', line 42 def before_step(step) @gf.step(step.gherkin_statement) if @print_emtpy_match if(@outline) match = Gherkin::Formatter::Model::Match.new(step.gherkin_statement.outline_args, nil) else match = Gherkin::Formatter::Model::Match.new([], nil) end @gf.match(match) end end |
#before_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/cucumber/formatter/gherkin_formatter_adapter.rb', line 54 def before_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background) arguments = step_match.step_arguments.map{|a| Gherkin::Formatter::Argument.new(a.byte_offset, a.val)} location = step_match.file_colon_line match = Gherkin::Formatter::Model::Match.new(arguments, location) if @print_emtpy_match # Trick the formatter to believe that's what was printed previously so we get arg highlights on #result @gf.instance_variable_set('@match', match) else @gf.match(match) end = exception ? "#{exception.} (#{exception.class})\n#{exception.backtrace.join("\n")}" : nil unless @outline @gf.result(Gherkin::Formatter::Model::Result.new(status, nil, )) end end |
#embed(file, mime_type) ⇒ Object
79 80 81 |
# File 'lib/cucumber/formatter/gherkin_formatter_adapter.rb', line 79 def (file, mime_type) @gf.(mime_type, File.read(file)) end |