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 trialNikola Novakovic
4,171 PointsRake spec and Rspec are the same thing ?
I am pretty new ( learning it for around 3 months) to Ruby On Rails and testing and I am really not sure what is the difference between rake spec and rspec and when should some of them be used.
I noticed this when Jason did some particular tests that went something like this
bin/rspec spec/features/todo_lists/nameofthefile_spec.rb
and then did this
bin/rake spec
Can someone please explain what is the difference between the two , what did the first rspec did and what did rake spec did in this example? :)
Thanks very much!
4 Answers
McFadden Gavender
4,893 Pointsbin/rspec spec/features/todo_lists/nameofthefile_spec.rb will run that specific test.
bin/rake spec will run all tests, including those setup by Rspec on install.
That is my understanding.
Jason Seifer
Treehouse Guest TeacherHey Nikola Novakovic great question! Jeremy Englert was totally correct in his response! bin/rspec
can run the whole suite or a specific file and rake spec
runs all tests.
Nikola Novakovic
4,171 PointsThank you so much Jason Seifer ! Really enjoying these Ruby On Rails lessons :)
Maciej Czuchnowski
36,441 PointsI was wondering what the difference was as well, but couldn't find anything solid. It seems that rake spec
is a rake task and gives some convenient shortcuts like rake spec:models
and "might be slower":
http://www.rubydoc.info/gems/rspec-rails/frames
I also see people on stack overflow who say that one of those commands shows errors while the other does not with the same code, so there has to be some underlying difference.
Nikola Novakovic
4,171 PointsThank you Maciej! I hope that Jason maybe could help out on this one as well to clear out the confusion :)
Maciej Czuchnowski
36,441 PointsI will tag him to draw his attention ;) Jason Seifer
Nikola Novakovic
4,171 PointsHahah thanks totally forgot about tagging :D
Nikola Novakovic
4,171 PointsNikola Novakovic
4,171 PointsCoolio , thank you! :)
Maciej Czuchnowski
36,441 PointsMaciej Czuchnowski
36,441 Pointsrspec
by itself will also run everything in the spec folder.Gabriele Rossi
5,887 PointsGabriele Rossi
5,887 PointsAwesome, I was just wondering about this exactly. Also thank you Nikola Novakovic for the question