【问题标题】:rspec with dashing in rubyrspec 在 ruby​​ 中很漂亮
【发布时间】:2013-06-08 02:21:24
【问题描述】:

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

当我包含它时,它在spec_helper.rb: 1 处显示“syntax error, unexpected tIDENTIFIER, expecting $end”,我已经尝试了过去三个小时,无法弄清楚我需要将“结束”放在 spec_helper 文件中的哪个位置。让我知道是否有人使用 rspec 进行破折号和验证仪表板文件

【问题讨论】:

    标签: ruby sinatra dashing


    【解决方案1】:

    首先,您应该将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

    【讨论】:

    • 我在我的 gemfile 中包含了 capybara gem。 “宝石‘水豚’,‘1.1.2’”。但它仍然显示没有识别出访问方法。此外,每当我更改我的 rspec 文件中的任何内容时,例如,如果它有两个“要求”甚至两行,它就会抛出一个找不到“结束”的错误。
    猜你喜欢
    • 2012-05-08
    • 2011-01-27
    • 2013-11-17
    • 1970-01-01
    • 1970-01-01
    • 2013-04-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多