Reputation: 21096
I'd want to get feature name in scenario hook. How can I get it?
What information besides scenario name and exception message is available in scenario hook?
Upvotes: 1
Views: 1222
Reputation: 46836
You can get the feature name by accessing the feature from the scenario object:
Before do |scenario|
case scenario
when Cucumber::Ast::Scenario
p scenario.feature.title
when Cucumber::Ast::OutlineTable::ExampleRow
p scenario.scenario_outline.feature.title
end
end
Note that you have to handle scenarios vs scenario outlines differently.
For other information that is available about the scenario, the best bet is to view the documentation - see http://rdoc.info/gems/cucumber/Cucumber/Ast/Scenario.
Upvotes: 2