2

Hi I am working on Daniel Kehoe's Rspec Tutorial. Everything went fine until I created the file spec/features/visitor/home_page_spec.rb . When I put the following test code in it

# Feature: Home Page
#   As a visitor
#   I want to visit a home page
#   So I can learn more about the website
feature 'Home Page' do

  # Scenario: Visit the Home Page
  #   Given I am a visitor
  #   When I visit the home page
  #   Then I should see "Welcome"
  scenario 'Visit the Home Page' do
    visit root_path
    expect(page).to have_content 'Welcome'
  end

end

and run rspec spec/features/visitor/home_page_spec.rb from the terminal, I got the error below. I get that the method was not defined but Daniel's tutorial just tells you to put the code in the folder above. Guess I am missing something. Thank you

rails-bootstrap/spec/features/visitor/home_page_spec.rb:7:in `<top (required)>': 
undefined method `feature' for main:Object (NoMethodError)
1
  • 1
    add require 'spec_helper' Commented Jul 21, 2014 at 20:46

2 Answers 2

2

What's in your .rspec file in the project directory? You should have:

--color
--format documentation
--require spec_helper
--require rails_helper

If the .rspec file is set up properly, you will not need additional require statements in your spec files.

Sign up to request clarification or add additional context in comments.

Comments

0

The only way I get rake test to run is to add the below require to test/integration/home_page_test.rb

require 'minitest/rails/capybara'

This line is already in test/test_helper.rb so I'm not sure why it isn't picking it up. I also tried adding the .rspec file with the options suggested by Daniel. If nothing else works, try that.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.