rspec在红宝石中潇洒

时间:2013-06-07 18:14:04

标签: ruby sinatra dashing

我的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

进行划线和验证仪表板文件

1 个答案:

答案 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