Class: AllureCucumber::AllureCucumberModel
- Inherits:
-
Object
- Object
- AllureCucumber::AllureCucumberModel
- Defined in:
- lib/allure_cucumber/models/cucumber_model.rb
Overview
Support class for transforming cucumber test entities in to allure model entities
Instance Method Summary collapse
-
#failure_details(result) ⇒ Hash<Symbol, String>
Get failure details.
-
#fixture_result(hook_step) ⇒ Allure::StepResult
Convert to allure step result.
-
#initialize(config, allure_config) ⇒ AllureCucumberModel
constructor
A new instance of AllureCucumberModel.
-
#step_result(test_step) ⇒ Hash
Convert to allure step result.
-
#test_result(test_case) ⇒ Allure::TestResult
Convert to allure test result.
Constructor Details
#initialize(config, allure_config) ⇒ AllureCucumberModel
Returns a new instance of AllureCucumberModel.
11 12 13 14 |
# File 'lib/allure_cucumber/models/cucumber_model.rb', line 11 def initialize(config, allure_config) @ast_lookup = Cucumber::Formatter::AstLookup.new(config) @config = allure_config end |
Instance Method Details
#failure_details(result) ⇒ Hash<Symbol, String>
Get failure details
61 62 63 64 65 66 |
# File 'lib/allure_cucumber/models/cucumber_model.rb', line 61 def failure_details(result) return { message: result.exception., trace: result.exception.backtrace.join("\n") } if result.failed? return { message: result., trace: result.backtrace.join("\n") } if result.undefined? {} end |
#fixture_result(hook_step) ⇒ Allure::StepResult
Convert to allure step result
54 55 56 |
# File 'lib/allure_cucumber/models/cucumber_model.rb', line 54 def fixture_result(hook_step) Allure::FixtureResult.new(name: "#{hook_step.text} (#{hook_step.location.to_s.split('/').last})") end |
#step_result(test_step) ⇒ Hash
Convert to allure step result
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/allure_cucumber/models/cucumber_model.rb', line 40 def step_result(test_step) step = Step.new(ast_lookup.step_source(test_step)) = (step) allure_step = Allure::StepResult.new( name: step.name, attachments: .map { |att| att[:allure_attachment] } ) { allure_step: allure_step, attachments: } end |
#test_result(test_case) ⇒ Allure::TestResult
Convert to allure test result
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/allure_cucumber/models/cucumber_model.rb', line 19 def test_result(test_case) scenario = Scenario.new(test_case, ast_lookup) parser = MetadataParser.new(scenario, config) Allure::TestResult.new( name: scenario.name, description: scenario.description, description_html: scenario.description, history_id: scenario.id, full_name: scenario.name, labels: parser.labels, links: parser.links, parameters: parser.parameters, status_details: parser.status_details, environment: config.environment ) end |