`require': cannot load such file --./spec_helper (LoadError)

I’m going through Ruby on Rails book…and trying to load Rspec for
static pages. I’ve looked on stack overflow and have tried what was
recommended, such as changing the folder name to features, and adding
require ‘capybara’ to the spec_helper folder, but to no avail.

My directory is:
Spec (folder)
-spec_helper.rb
features (folder)
-static_pages_spec.rb

Here is the code for static_pages_spec.rb:

require ‘…/spec_helper’

describe “Static pages” do
describe “Home page” do

it "should have the content 'Sample App'" do
   visit '/static_pages/home'
  page.should have_content('Sample App')
end

end
end

When I change the folder name back to ‘requests’ and remove require
capybara from spec_helper.rb I just get the failed test:

Failures:

  1. Static pages Home page should have the content ‘Sample App’
    Failure/Error: visit ‘/static_pages/home’

    NoMethodError:
    undefined method `visit’ for
    #RSpec::ExampleGroups::StaticPages::HomePage:0x007ff7c18d6498

    ./spec/features/static_pages_spec.rb:7:in `block (3 levels) in

<top (required)>’

Finished in 0.00102 seconds (files took 0.15198 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/features/static_pages_spec.rb:6 # Static pages Home page
should have the content 'Sample App

the test seems to have a problem with the following line in my
static_pages_spec.rb file:

visit ‘/static_pages/home’

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs