문제

I have the below code in my 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

i ran rspec index_spec.rb and it failed saying 'unidentified method visit', then i searched on the net and included the following in the spec_helper.rb

require 'capybara'
include Capybara::DSL

when i include it, it shows me " syntax error, unexpected tIDENTIFIER, expecting $end" at spec_helper.rb: 1, i have been trying this out for last three hours, could not figure out where i need to put 'end' in the spec_helper file. Let me know if some worked on dashing and validated the dashboard file using rspec

도움이 되었습니까?

해결책

First you should add capybara to your Gemfile and bundle it. Then add to spec_helper.rb:

require 'capybara/rspec'

Also

# change this:
# visit '../../dashboards/index'
# to:
visit dashboard_path

https://github.com/jnicklas/capybara#using-capybara-with-rspec

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top