[RUBY] RSpec error resolution undefined method `feature'for RSpec: Module

The error I got when I typed the rspec command.

Conclusion

I didn't load capybara.

code

Error code

require 'rails_helper'

RSpec.feature "Users", type: :feature do

  describe "Signup page" do
    before do
      visit signup_path
    end
 
    it "display Signup contents, title properly" do
      expect(page).to have_css('h1', text: 'user registration')
      expect(page).to have_title 'Signup hoge'
    end
  end
  
end

Load the resolved code capybara

  require 'rails_helper'
+ require 'capybara/rspec'

RSpec.feature "Users", type: :feature do

  describe "Signup page" do
    before do
      visit signup_path
    end

    it "display Signup contents, title properly" do
      expect(page).to have_css('h1', text: 'user registration')
      expect(page).to have_title 'Signup hoge'
    end
  end
  
end

Gemfile



#Shows the progress bar of rspec. Command to execute% bin/rspec spec/ --format Fuubar
gem 'fuubar'

group :test do
 #The following three gems are required for rspec.
  gem 'rspec-rails'
  gem 'factory_bot_rails'
  gem 'rails-controller-testing'
  #Required for rspec features.
  gem 'capybara', '~> 2.13'
  #To see which page is currently open while testing with Capybara
  gem 'launchy'
  #Convenient. validation takes about one line.
  gem 'shoulda-matchers',
    git: 'https://github.com/thoughtbot/shoulda-matchers.git',
    branch: 'rails-5'
end

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'spring-commands-rspec'
end

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 4.1.0'
  # Display performance information such as SQL time and flame graphs for each request in your browser.
  # Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md
  gem 'rack-mini-profiler', '~> 2.0'
  gem 'listen', '~> 3.3'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

reference:

https://stackoverflow.com/questions/26217184/rspec-3-1-undefined-method-feature-for-mainobject

Recommended Posts

RSpec error resolution undefined method `feature'for RSpec: Module
RSpec error resolution undefined method'name' in'user' factory
rspec Error: ActionView :: Template :: Error: undefined method `name'for nil: NilClass
[Ruby on Rails] undefined method ʻid'for nil: NilClass error resolution method
Spring Boot + PostgreSQL error resolution method
[Ruby on Rails] Follow function undefined method ʻid'for nil: NilClass error resolution
[Ruby on Rails] NoMethodError undefined method `devise_for'error resolution
ITMS-90626 Error Resolution
undefined method `** _ path'error
Rails error undefined method ʻimage_name'for nil: NilClass handling
[Rails] How to solve the error "undefined method` visit'" when using Capybara with Rspec
RSpec error resolution undefined method `feature'for RSpec: Module
undefined method `** _ path'error
[Ruby on Rails] NoMethodError undefined method `devise_for'error resolution
[Rails] devise helper method
[Rails Tutorial] "NoMethodError (undefined method` activation_digest ='for # <User: 0x00000003156938>
[Rails] devise introduction method
[Ruby] Invalid multibyte char (UTF-8) Error resolution method [CSV]
About No Method Error
ActionController :: InvalidAuthenticityToken error resolution
rails error resolution summary
Error resolution on Heroku