This is the sample application for the Ruby on Rails Tutorial by Michael Hartl.
Modified by Stinge Su.
My rails is 4.2.1
, ruby is 2.1.2
You may be counter some problems in this sample application.
- 1. Rspec can not be bundled
'require': cannot load such file -- rails_helper
step 1 :
add config.include Capybara::DSL
to spec_helper.rb
include Capybara to use visit
method
step 2 :
modify your Gemfile
gem 'selenium-webdriver', '~>2.35.1'
your selenium-webdriver version need to be upgraded.
step 3 :
using GET
method in config/rounter.rb
get '/home' => 'static_pages#home'
redirct localhost:3000/home
step 4 :
modify your config/environment/development.rb
production.rb
. test.rb
from Rails.application.configure
to YourAppName::Aplication.configure
- 2. Guard can not find class
ERROR - Could not load 'guard/rspec'
cannot load such file -- guard/guard (LoadError)
step 1:
check your capybara version in Gemfile
make sure it's version is more than 2.2.0
or even delete the description of capybara
step 2:
bundle update
step 3:
bundle exec guard
- 3. Spork server causes a Exception
Exception encountered: #<ActiveRecord::ConnectionNotEstablished: ActiveRecord::ConnectionNotEstablished>
#<NameError: uninitialized constant RSpec::Core::CommandLine>
step 1:
check your spec_helper.rb
is the same as this
step 2:
add the support file to spork
mkdir spec/support
and add the support file called spork_patch.rb
like this
step 3:
restart spork server.bundle exec spork
step 4:
bundle exec rspec spec/requests/static_pages --drb
in new window
- 4. Named routes in Rspec could not work
undefined local variable or method 'XXX_path'
if you not defined named routes in rspec_helper
you just add this line:
config.include Rails.application.routes.url_helpers
- **5. RSpec be_false error** - `expected false to respond to 'false?'`
using `bcrypt-ruby 3.0.1` for password validation need to notice there are some differences in RSpec 3.0
please change `be_true/befalse` to `be_truthly/be_falsey`