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,437 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,437 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,437 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