获取" rspec :: ExpectationNotMetError"同时尝试运行黄瓜测试谷歌搜索

时间:2014-05-08 15:07:38

标签: rspec cucumber

今天是Ruby和Cucumber的第一天。我在网上发现了这个非常有用的示例代码,我正在尝试使其工作,但我在最后一步陷入困境。

这是我的功能文件:

Feature:
'When I go to the Google search page, and search for an item,
    I expect to see some reference to that item in the result summary.'

Scenario:
Given that I have gone to the Google page
When I add "search" to the search box
And click the Search Button
Then "search" should be mentioned in the results

这是step_definition:

Given /^that I have gone to the Google page$/ do
  @browser = Selenium::WebDriver.for :firefox
  @browser.navigate.to 'http://www.google.com'
end

When /^I add "(.*)" to the search box$/ do |item|
  @browser.find_element(:name, 'q').send_keys(item)
end

When /^click the Search Button$/ do
  @browser.find_element(:name, 'btnG').click
end

Then /^"(.*)" should be mentioned in the results$/ do |item|
  @browser.title.should include(item)
  @browser.quit
end

我创建了一个env.rb文件:

require 'selenium-webdriver'
require 'rspec/expectations'

当我尝试运行此操作时,我得到以下与Rspec期望错误相关的错误:

Scenario:                                            # features\GoogleSearch.feature:5
    Given that I have gone to the Google page        # features/step_definitions
/Search_steps.rb:1
    When I add "Sogeti" to the search box            # features/step_definitions
/Search_steps.rb:6
    And click the Search Button                      # features/step_definitions
/Search_steps.rb:10
    Then "Sogeti" should be mentioned in the results # features/step_definitions
/Search_steps.rb:14
expected "Google" to include "Sogeti"     (RSpec::Expectations::ExpectationNotMetError)
  ./features/step_definitions/Search_steps.rb:15:in `/^"(.*)" should be mentioned in the results$/'
  features\GoogleSearch.feature:9:in `Then "Sogeti" should be mentioned in the results'
Failing Scenarios:
cucumber features\GoogleSearch.feature:5 # Scenario:

我已经安装了Rspec gem并将其包含在env.rb文件中但是我无法让它工作。你能帮我吗?提前谢谢。

0 个答案:

没有答案
相关问题