如何避免Cucumber中的模糊步骤定义?

时间:2012-10-03 13:14:08

标签: ruby-on-rails ruby testing cucumber bdd

我遇到了模棱两可的步骤定义错误。以下方案存在于不同的功能文件中,并且具有相同的步骤: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

1 个答案:

答案 0 :(得分:4)

为什么不只使用authentication_steps.rb中的那个?我认为您可以使用任何功能文件中的所有步骤