2012-11-16 52 views
1

我是Watir,Rspec測試的新手,我剛剛熟悉它。我在互聯網上發現了一個測試,Rspec和watir的組合,但id什麼都沒做。它會拋出錯誤,要求'spec'不存在。我已經安裝了rspec 2.12。我在這裏錯過了什麼,我是否需要安裝一些東西? Rspec腳本的工作和watir一樣好,但是這種組合不是。Watir和Rspec腳本什麼都不做

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 

回答

2

「我在互聯網上發現了一個測試」沒有幫助。請提供該頁面的鏈接。

此外,你沒有說你如何運行腳本。據我所知,要運行RSpec 1.x腳本,您必須執行spec file_name.rb,而使用RSpec 2.x則必須執行rspec file_name.rb。這可能是問題所在。

+1

謝謝你的回答,我用ruby file_name.rb運行它。 rspec file_name.rb解決了我的問題。再次感謝 –