Hi,
As I was working through your tutorial, an error popped up blocking me from using bundle exec rspec
. I have checked the gems and configuration file rails_helper.rb
to make sure it is exactly the same as in your tutorial.
I've already tried to explore internet and look for solutions, but must of them are about editing spec_helper.rb (which doesn't explain why, because backtrace shows problem comes from rails_helper.rb; and spec_helper.rb is identical to the one in tutorial) and used rails versions are < 5.0.
Here is a full trace:
****/todos-api$ bundle exec rspec
*full path*/todos-api/spec/rails_helper.rb:73:in `block in <top (required)>': uninitialized constant RequestSpecHelper (NameError)
from /home/beniusij/.rvm/gems/ruby-2.4.1/gems/rspec-core-3.5.4/lib/rspec/core.rb:98:in `configure'
from /home/beniusij/RubymineProjects/todos-api/spec/rails_helper.rb:37:in `<top (required)>'
from /home/beniusij/RubymineProjects/todos-api/spec/models/item_spec.rb:1:in `require'
from /home/beniusij/RubymineProjects/todos-api/spec/models/item_spec.rb:1:in `<top (required)>'
from /home/beniusij/.rvm/gems/ruby-2.4.1/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1435:in `load'
from /home/beniusij/.rvm/gems/ruby-2.4.1/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1435:in `block in load_spec_files'
from /home/beniusij/.rvm/gems/ruby-2.4.1/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1433:in `each'
from /home/beniusij/.rvm/gems/ruby-2.4.1/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1433:in `load_spec_files'
from /home/beniusij/.rvm/gems/ruby-2.4.1/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:100:in `setup'
from /home/beniusij/.rvm/gems/ruby-2.4.1/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:86:in `run'
from /home/beniusij/.rvm/gems/ruby-2.4.1/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:71:in `run'
from /home/beniusij/.rvm/gems/ruby-2.4.1/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:45:in `invoke'
from /home/beniusij/.rvm/gems/ruby-2.4.1/gems/rspec-core-3.5.4/exe/rspec:4:in `<top (required)>'
from /home/beniusij/.rvm/gems/ruby-2.4.1/bin/rspec:22:in `load'
from /home/beniusij/.rvm/gems/ruby-2.4.1/bin/rspec:22:in `<main>'
from /home/beniusij/.rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in `eval'
from /home/beniusij/.rvm/gems/ruby-2.4.1/bin/ruby_executable_hooks:15:in `<main>'
Gemfile:
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.0.rc1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
# gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
# gem 'rack-cors'
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 "rspec-rails", '~> 3.5'
end
group :development do
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
group :test do
gem 'factory_girl_rails', '~> 4.0'
gem 'shoulda-matchers', '~> 3.1'
gem 'faker'
gem 'database_cleaner'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
spec/rails_helper.rb
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
# Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.env.production?
require 'rspec/core'
require 'spec_helper'
require 'rspec/rails'
# Add additional requires below this line. Rails is not loaded until this point!
require 'database_cleaner'
# Requires supporting ruby files with custom matchers and macros, etc, in
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
# run as spec files by default. This means that files in spec/support that end
# in _spec.rb will both be required and run as specs, causing the specs to be
# run twice. It is recommended that you do not name files matching this glob to
# end with _spec.rb. You can configure this pattern with the --pattern
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
#
# The following line is provided for convenience purposes. It has the downside
# of increasing the boot-up time by auto-requiring all files in the support
# directory. Alternatively, in the individual `*_spec.rb` files, manually
# require only the support files necessary.
#
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
# Checks for pending migration and applies them before tests are run.
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.maintain_test_schema!
Shoulda::Matchers.configure do |config|
config.integrate do |with|
with.test_framework :rspec
with.library :rails
end
end
RSpec.configure do |config|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true
config.include FactoryGirl::Syntax::Methods
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
DatabaseCleaner.strategy = :transaction
end
config.around(:each) do |example|
DatabaseCleaner.cleaning do
example.run
end
end
# RSpec Rails can automatically mix in different behaviours to your tests
# based on their file location, for example enabling you to call `get` and
# `post` in specs under `spec/controllers`.
#
# You can disable this behaviour by removing the line below, and instead
# explicitly tag your specs with their type, e.g.:
#
# RSpec.describe UsersController, :type => :controller do
# # ...
# end
#
# The different available types are documented in the features, such as in
# https://relishapp.com/rspec/rspec-rails/docs
config.infer_spec_type_from_file_location!
config.include RequestSpecHelper, type: :request
# Filter lines from Rails gems in backtraces.
config.filter_rails_from_backtrace!
# arbitrary gems may also be filtered via:
# config.filter_gems_from_backtrace("gem name")
end
Versions:
Rails 5.1.0.rc1
Ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
P.S. Fun tutorial, I hope to get this solved soon so I could finish the tutorial and wait for part 2! :)