Watir和Rspec脚本什么都不做

时间:2012-11-16 09:03:38

标签: watir

我是Watir的新手,Rspec测试,我只是熟悉它。我在互联网上找到了一个测试,Rspec和watir的组合但是id什么也没做。抛出错误需要'spec'不存在。我安装了rspec 2.12。我在这里错过了什么,我需要安装一些东西吗? Rspec脚本和watir一样工作,但这个组合没有。

require 'watir'
require 'spec'

describe "Google" do

  before :all do
    @browser = Watir::Browser.new
    @browser.goto "http://google.com"
  end

  it "has word 'Google' on main page" do
    @browser.text.should include("Google")
  end

  it "has word 'Bing' as it's title" do
    @browser.title.should == "Bing"
  end

  after :all do
    @browser.close
  end

end

1 个答案:

答案 0 :(得分:2)

“我在互联网上发现了一个测试”并没有帮助。请提供该页面的链接。

另外,您没有说明如何运行脚本。据我记忆,要运行RSpec 1.x脚本,您必须执行spec file_name.rb,而使用RSpec 2.x,您必须执行rspec file_name.rb。这可能是问题所在。