我遇到了不明确的步骤定义错误。以下场景存在于不同的特征文件中,并且有一个相同的步骤: Then I should see my profile page
。我如何避免这种情况发生?
# authentication.feature
Scenario: Successful sign in
Given I visit the sign in page
When I submit valid sign in information
Then I should see my profile page
# signing_up.feature
Scenario: Successful sign up
Given I visit the sign up page
When I submit valid information
Then I should see my profile page
# authentication_steps.rb
...
Then /^I should see my profile page$/ do
page.current_path.should == user_path(@user)
end
# signing_up.feature
...
Then /^I should see my profile page$/ do
page.current_path.should == user_path(@user)
end
我也遇到了错误消息的这个问题:
Scenario: Unsuccessful sign up
...
Then I should see an error message
Scenario: Unsuccessful login
...
Then I should see an error message
最佳答案
为什么不只使用 authentication_steps.rb 中的那个?我认为您可以使用任何功能文件中的所有步骤
关于ruby-on-rails - 如何避免 Cucumber 中步骤定义不明确?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12709284/