我的index_spec.rb
require '../../spec_helper'
describe "Dashboards" do
describe "Welcome Widget" do
it "should have the content" do
visit '../../dashboards/index'
page.should have_content('Random Content.')
end
end
end
我跑了rspec index_spec.rb
并且说'unidentified method visit'
失败,然后我在网上搜索并在spec_helper.rb
require 'capybara'
include Capybara::DSL
当我加入它时,它会在syntax error, unexpected tIDENTIFIER, expecting $end
向我显示“spec_helper.rb: 1
”,我在过去三个小时内一直在尝试这个,无法弄清楚我需要将“结束”放在哪里spec_helper文件。让我知道是否有人使用rspec
答案 0 :(得分:0)
首先,您应该将capybara
添加到您的Gemfile并将其捆绑。然后添加到spec_helper.rb
:
require 'capybara/rspec'
另外
# change this:
# visit '../../dashboards/index'
# to:
visit dashboard_path
https://github.com/jnicklas/capybara#using-capybara-with-rspec