неинициализирана константа Capybara след използване на Capybara с Rspec

Уча Ruby on rails с учебната книга Ruby on Rails онлайн и попаднах на това упражнение http://www.railstutorial.org/book/static_pages#code-capybara_dsl

Следвах инструкциите за добавяне

RSpec.configure do |config|
  config.include Capybara::DSL
end

към моя spec_helper.rb, но сега получавам грешките

uninitialized constant Capybara <NameError>

Това е текущият ми spec_helper.rb

require "spec_helper"

RSpec.configure do |config|
  config.include Capybara::DSL
end

describe "Static pages" do 
  describe "Home page" do 
    it "should have the content 'Sample App'" do
      visit '/static_pages/home'
      expect(page).to have_content('Sample App')
    end
  end

describe "Help page" do

    it "should have the content 'Help'" do
      visit '/static_pages/help'
      expect(page).to have_content('Help')
    end
end

 describe "About page" do

     it "should have the content 'About Us'" do
      visit '/static_pages/about'
      expect(page).to have_content('About Us')
     end
  end
end

какво правя грешно неправилно ли инсталирах скъпоценния камък?

Редактиране: Не съм сигурен дали това ще помогне, но ето неуспешните изходни примери, след като извиках $ bundle exec rspec spec/requests/static_pages_spec.rb

←[31mrspec ./spec/spec_helper.rb:7←[0m ←[36m# Static pages Home page should have
 the content 'Sample App'←[0m
←[31mrspec ./spec/spec_helper.rb:15←[0m ←[36m# Static pages Help page should hav
e the content 'Help'←[0m
←[31mrspec ./spec/spec_helper.rb:23←[0m ←[36m# Static pages About page should ha
ve the content 'About Us'←[0m
←[31mrspec ./spec/requests/static_pages_spec.rb:5←[0m ←[36m# StaticPages GET /st
atic_pages works! (now write some real specs)←[0m

person user3277633    schedule 19.05.2014    source източник
comment
Бихте ли могли да проверите дали rspec gem е посочен във вашия Gemfile?   -  person evedovelli    schedule 19.05.2014
comment
В момента имам gem 'rspec-rails', '2.13.1'   -  person user3277633    schedule 19.05.2014


Отговори (1)


Колко съм глупав. В урока има два файла, които не съм разгледал внимателно. Единият е static_pages_spec.rb под spec/requests, а друг е просто spec_helper.rb под spec. Обърках двата файла и поставих противоположните неща един в друг.

Открих грешката си, след като разбрах "защо трябва да изисквам spec_helper.rb, когато вече съм в spec_helper.rb"

person user3277633    schedule 19.05.2014