0

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

user1455116
  • 2,034
  • 4
  • 24
  • 48

1 Answers1

0

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

NARKOZ
  • 27,203
  • 7
  • 68
  • 90
  • i included the capybara gem in my gemfile. "gem 'capybara', '1.1.2'". but it still shows no visit method identified. Also, whenever i change anything in my rspec file, for example, if it has two 'requires' or even two lines, it throws an error that it cannot find 'end'. – user1455116 Jun 07 '13 at 18:36