2

I'm following the NetTuts intro to Rails screencast to get a better handle on rspec/capybara/guard etc. and after a few errors I cannot get passed this one:

/home/jonlee/.rvm/gems/ruby-2.1.1@railstutorial_rails_4_0/gems/capybara-2.3.0/lib/capybara/rails.rb:15:in `<top (required)>': undefined method `join' for nil:NilClass (NoMethodError)
    from /home/jonlee/Projects/rails/guardtest/spec/spec_helper.rb:3:in `require'
    from /home/jonlee/Projects/rails/guardtest/spec/spec_helper.rb:3:in `<top (required)>'

My spec_helper is as follows:

require 'rails'
require 'rspec/core'
require 'capybara/rails'


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

my gemfile has:

group :test, :development do
  gem 'rspec-core'
  gem 'capybara'
  gem 'guard-rspec'
end

im using: Ruby - 2.1.1 Rails - 4.0.5 rspec - 3.0.1 capybara - 2.3.0

Even after suggestion of changing spec_helper.rb file to require 'rspec/core' and changing gem to rspec-core I still have this error.

Does the order in the spec_helper matter or do I need to perform some further work in the Rspec.configure block?

GIT - https://github.com/JonleePeakman/guardtest

1 Answer 1

1

Your gemfile has gem 'rspec-core'. It should be gem 'rspec-rails'.

You have RSpec 3.0.1 and there are big changes in configuration compared to previous versions. Be careful not to follow outdated tutorials or blog posts. Have you used the RSpec generator to set up RSpec?

$ rails generate rspec:install

You should have files:

.rspec
spec/spec_helper.rb
spec/rails_helper.rb

Capybara will work "out of the box" without any changes to the configuration files. Try removing your spec/spec_helper.rb file and use the RSpec generator to set things up.

As an alternative to the NetTuts tutorial, you might want to look at the RSpec Tutorial I've written which is up to date with RSpec 3.0.

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

2 Comments

I did use rspec:install and those are the files I have, I then created a guard init rspec file and right from scratch I had this issue. In fact I had others that I managed to overcome but this error is really stumping me.
What happens if you use gem 'rspec-rails' instead of gem 'rspec-core'?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.