RSpec - thuy-econsys/rails_app GitHub Wiki

Resources for test automation with RSpec

Run your tests

Run specific tests by appending the line number of where the example group starts to spec file path preceded by a :. The following runs tests for example groups located in a_spec.rb file inside the /spec directory that start at line 37 and line 87.

rspec ./spec/a_spec.rb:37:87

If you have followed the best practices of describing your methods with brief, clear descriptions, organize your tests with context, and follow the "one expectation" tip, it's possible to use the -e option to search for specific strings or even Regex patterns with -E to run all the example groups for a method:

rspec ./spec/a_spec.rb -e "GET #edit"

Or run all the example groups for a particular expectation:

rspec ./spec/a_spec.rb -e "200 OK status"

References