Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

Yuan Tang
Yuan Tang
14,168 Points

cannot find rspec directory

first i tried bin/rails generate rspec:install and it said "could not find generator rspec:install" then i tried the following: gem install rspec gem install rspec-rails

but by installing the gem this way it didn't generate a folder for rspec

Any help would be appreciated.

4 Answers

Robert Ho
PLUS
Robert Ho
Courses Plus Student 11,383 Points

Hey Yuan,

I noticed something is wrong with your gem file. To the right of the "SDOC" gem, I see that you have an unclosed "group: :doc" rails method. Remove that, , save, and run bundle install again. Then do the bin/rails generate rspec:install command again.

For reference to what I'm talking about:

source 'https://rubygems.org'

gem 'rails', '4.1.1' 
gem 'sqlite3'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0',          group: :doc  ## <-- OVER HERE 
gem 'tzinfo-data', platforms: [:mingw, :mswin]

group :doc do
    # bundle exec rake doc:rails generates the API under doc/api
    gem 'sdoc', require: false
end

group :development, :test do
    gem 'rspec-rails', '~> 2.0'
end

group :test do
    gem 'capybara', '~> 2.1.0'
   end

Let me know if that helped

Yuan Tang
Yuan Tang
14,168 Points

Thanks Robert, I just tried but it still didn't work. It makes no difference for some reason.

Robert Ho
Robert Ho
Courses Plus Student 11,383 Points

Can you copy and paste your entire gem file after making the changes? Also, do you still get the same error?

Yuan Tang
Yuan Tang
14,168 Points

''' source 'https://rubygems.org'

gem 'rails', '4.1.1' gem 'sqlite3' gem 'sass-rails', '~> 4.0.3' gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.0.0' gem 'jquery-rails' gem 'turbolinks' gem 'jbuilder', '~> 2.0' gem 'sdoc', '~> 0.4.0', gem 'tzinfo-data', platforms: [:mingw, :mswin]

group :doc do # bundle exec rake doc:rails generates the API under doc/api gem 'sdoc', require: false end

group :development, :test do gem 'rspec-rails', '~> 2.0' end

group :test do gem 'capybara', '~> 2.1.0' end '''

Thanks a lot. Yes, I still get the same error. Will this problem be related to my Windows 8 x64 machine? I am using treehouse VM.

Have you tried copying and pasting from the project files? If it doesn't work after that - you know you've got a problem somewhere else!

Robert Ho
Robert Ho
Courses Plus Student 11,383 Points

Hey Yuan,

I noticed that you have a comma right after gem 'sdoc' '~0.4.0', You should remove that comma and try the steps above. In summary:

  1. Remove that comma,
  2. Save
  3. Run bundle install in the command line.
  4. Then do bin/rails generate rspec:install in the command.

For reference:

 gem 'jbuilder', '~> 2.0'
 gem 'sdoc', '~> 0.4.0', # <-- OVER HERE 
 gem 'tzinfo-data', platforms: [:mingw, :mswin]

Hope this works! Haha.

Yuan Tang
Yuan Tang
14,168 Points

Sadly it's still not working. Really appreciate it for your time though.

It was a little while ago since I did this course, but I think the 'spec' folder is created manually (mkdir spec).

Have you added rspec to your gem file and run bundle?

Yuan Tang
Yuan Tang
14,168 Points

Yes I have added them to my gem file and run bundle. In the video, spec folder was created by the command gem install rspec gem install rspec-rails.

Yuan Tang
Yuan Tang
14,168 Points

after I typed bundle, it didn't show any gem called rspec installed. But I did add them in my Gemfile. Here is a copy of it. (this could not show up properly here, losing its format) source 'https://rubygems.org'

gem 'rails', '4.1.1' gem 'sqlite3' gem 'sass-rails', '~> 4.0.3' gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.0.0' gem 'jquery-rails' gem 'turbolinks' gem 'jbuilder', '~> 2.0' gem 'sdoc', '~> 0.4.0', group: :doc gem 'tzinfo-data', platforms: [:mingw, :mswin]

group :doc do # bundle exec rake doc:rails generates the API under doc/api gem 'sdoc', require: false end

group :development, :test do gem 'rspec-rails', '~> 2.0' end

group :test do gem 'capybara', '~> 2.1.0' end

Above the 'post answer' button is a link to the Markdown Cheatsheet. This shows you how to add code to your forum post :-)

Yuan Tang
Yuan Tang
14,168 Points
source 'https://rubygems.org'

gem 'rails', '4.1.1' 
gem 'sqlite3'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0',          group: :doc
gem 'tzinfo-data', platforms: [:mingw, :mswin]

group :doc do
    # bundle exec rake doc:rails generates the API under doc/api
    gem 'sdoc', require: false
end

group :development, :test do
    gem 'rspec-rails', '~> 2.0'
end

group :test do
    gem 'capybara', '~> 2.1.0'
end

Gem file looks okay to me.. But I'm not that experienced.

Just to confirm, you added the gem to your gem file, ran bundle, then called

"bin/rails generate rspec:install"

?

Try with bundle install and bundle update, it sounds like the gem isn't being installed via your gemfile + bundle

Yuan Tang
Yuan Tang
14,168 Points

I just tried it but the rspec did not show up

I think Dino PaΕ‘kvan might be able to give much better help