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 Build a Todo List Application with Rails 4 Build a Todo List Application with Rails 4 Deleting Todo Lists

Nikola Novakovic
Nikola Novakovic
4,171 Points

Rake 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

bin/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.

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

rspec by itself will also run everything in the spec folder.

Gabriele Rossi
Gabriele Rossi
5,887 Points

Awesome, I was just wondering about this exactly. Also thank you Nikola Novakovic for the question

Jason Seifer
STAFF
Jason Seifer
Treehouse Guest Teacher

Hey 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
Nikola Novakovic
4,171 Points

Thank you so much Jason Seifer ! Really enjoying these Ruby On Rails lessons :)

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

I 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
Nikola Novakovic
4,171 Points

Thank you Maciej! I hope that Jason maybe could help out on this one as well to clear out the confusion :)

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

I will tag him to draw his attention ;) Jason Seifer

Nikola Novakovic
Nikola Novakovic
4,171 Points

Hahah thanks totally forgot about tagging :D