Parent

Files

Class/Module Index [+]

Quicksearch

Cucumber::Formatter::GherkinFormatterAdapter

Adapts Cucumber formatter events to Gherkin formatter events This class will disappear when Cucumber is based on Gherkin's model.

Public Class Methods

new(gherkin_formatter, print_emtpy_match) click to toggle source
# 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

Public Instance Methods

after_feature(feature) click to toggle source
# File lib/cucumber/formatter/gherkin_formatter_adapter.rb, line 70
def after_feature(feature)
  @gf.eof
end
after_features(features) click to toggle source
# File lib/cucumber/formatter/gherkin_formatter_adapter.rb, line 74
def after_features(features)
  @gf.done
end
before_background(background) click to toggle source
# File lib/cucumber/formatter/gherkin_formatter_adapter.rb, line 19
def before_background(background)
  @outline = false
  @gf.background(background.gherkin_statement)
end
before_examples(examples) click to toggle source
# File lib/cucumber/formatter/gherkin_formatter_adapter.rb, line 66
def before_examples(examples)
  @gf.examples(examples.gherkin_statement)
end
before_feature(feature) click to toggle source
# File lib/cucumber/formatter/gherkin_formatter_adapter.rb, line 14
def before_feature(feature)
  @gf.uri(feature.file)
  @gf.feature(feature.gherkin_statement)
end
before_feature_element(feature_element) click to toggle source
# File lib/cucumber/formatter/gherkin_formatter_adapter.rb, line 24
def before_feature_element(feature_element)
  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_step(step) click to toggle source
# File lib/cucumber/formatter/gherkin_formatter_adapter.rb, line 37
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) click to toggle source
# File lib/cucumber/formatter/gherkin_formatter_adapter.rb, line 49
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.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

  error_message = exception ? "#{exception.message} (#{exception.class})\n#{exception.backtrace.join("\n")}" : nil
  unless @outline
    @gf.result(Gherkin::Formatter::Model::Result.new(status, nil, error_message))
  end
end
embed(file, mime_type, label) click to toggle source
# File lib/cucumber/formatter/gherkin_formatter_adapter.rb, line 78
def embed(file, mime_type, label)
  data = File.read(file)
  if defined?(JRUBY_VERSION)
    data = data.to_java_bytes
  end
  @gf.embedding(mime_type, data)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.