2013-07-01 88 views
0

我试图运行使用rspec的和水豚一个简单的测试:Rails的水豚不工作

describe "Create" do 
    visit new_client_path 

    page.should have_selector('h1', text: "New Client") 
end 

但是我得到的错误:

undefined local variable or method `visit' 

如果我删除访问线我得到这个错误:

undefined local variable or method `page' 

我已将DSL包含在spec_helper文件中。

是什么问题?

感谢

回答

3

看来你根本都忘了把你的测试it块内:

describe "Create" do 
    it "does something" do 
    visit new_client_path 
    page.should have_selector('h1', text: "New Client") 
    end 
end 
+0

不得不清理我的宝石,现在重新安装'水豚'和'它'块的作品,谢谢 – Wahtever

0

假设你正在使用Rails 3和RSpec,你放置在您的规格中的功能,而不是请求?如果您正在使用功能目录,则不需要包含DSL。

此外,请检查您是否有最新版本的宝石。

从:

Using Capybara with RSpec

Load RSpec 2.x support by adding the following line (typically to your spec_helper.rb file):

require 'capybara/rspec' If you are using Rails, put your Capybara specs in spec/features.

+0

我加入了DSL作为调试问题的一种方式,我也尝试过给规范一种功能,并添加了'require'水豚/规格',但没有运气 – Wahtever