このような単純なキュウリの機能とシナリオがある場合(コード例はキュウリの wikiからのものです):
Feature: Eating cucumbers
Scenario: eat 5 out of 12
Given there are 12 cucumbers
When I eat 5 cucumbers
Then I should have 7 cucumbers
フックで機能とシナリオ名を取得する方法を知っています:before
Before do |scenario|
p [scenario.feature.name, scenario.name]
end
上記のコードは次を返します。
["Eating cucumbers", "eat 5 out of 12"]
問題は、機能にシナリオの概要がある場合です。
Scenario Outline: eating
Given there are <start> cucumbers
When I eat <eat> cucumbers
Then I should have <left> cucumbers
Examples:
| start | eat | left |
| 12 | 5 | 7 |
上記のコードを実行すると、次のようになります。
undefined method `feature' for #<Cucumber::Ast::OutlineTable::ExampleRow:0x007fb0f94a8240> (NoMethodError)
キュウリフックで機能とシナリオのアウトライン名を取得するにはどうすればよいですか?before