How to run unit tests on rspec?

0

When I run rake spec it runs all tests. How do I run only the unit tests.

    
asked by anonymous 21.11.2014 / 13:21

2 answers

1

You can specify specific files so that RSpec only runs tests on these files, for example

$ rspec spec/models/*

You will only run the models tests. You can also just run a test by specifying the line, for example.

$ rspec spec/models/user_spec.rb:31

What will only run the test of line 31 of the user_spec.rb file

    
03.12.2014 / 23:04
1

Rspec tests behavior, while the Unit Test (assuming this tool is used for unit testing) tests the units of your application. You can not run unit tests with a tool that runs behavior tests.

If you want to run only the unit tests you can run the following command:

ruby -I test test/unit/
    
21.11.2014 / 23:10