我已经将我的整个堆栈从基于 Rails 3.0 的项目升级到 3.1。我的规格通过了,但我的功能现在有点挑剔。我目前遇到的问题是这一步:
Then /^I should see (\d+) menu item(?:s)? within "([^"]*)"$/ do |count, selector|
page.find(:css, selector, :count => count.to_i)
end
在功能本身中,我可能会说:
Then I should see 5 menu items within "tr#menu_item_row"
我得到的信息是:
Then I should see 5 menu items within "tr#menu_item_row" # features/step_definitions/admin_menu_steps.rb:1
Ambiguous match, found 5 elements matching css "tr#menu_item_row" (Capybara::Ambiguous)
./features/step_definitions/admin_menu_steps.rb:2:in `/^I should see (\d+) menu item(?:s)? within "([^"]*)"$/'
features/admin_menu.feature:30:in `Then I should see 5 menu items within "tr#menu_item_row"'
据我所知,这 5 个元素与实际找到的 5 个元素相匹配。我是写错了这段代码还是发生了重大变化?谢谢!