Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. To easily limit the execution of RSpec tests while you are developing use the
  2. power of the `.rspec` opts file and RSpec tags.
  3.  
  4. Tags can be added to any RSpec method `describe`, `context`, `it`, etc.
  5.  
  6. The are simply arguments passed as a Hash to the method.
  7.  
  8. ```ruby
  9. describe 'foo', focus: true do
  10. context 'bar', slow: true do
  11. it 'uses the database', db: true do
  12. ```
  13.  
  14. The above example shows a couple different tags you can try. They can really be
  15. any valid Ruby symbol but `:focus` and `:skip` are traditional.
  16.  
  17. You can call `rspec` to either run only the tags or to ignore the tags.
  18.  
  19. `be rspec --tag ~db` skips all the `:db` tagged specs.
  20. `be rspec --tag focus` runs all the specs inside the `describe` block.
  21.  
  22. RSpec uses an opt file that can exist in your local directory and your home
  23. directory. The home directory file sets your global defaults but the local file
  24. will override those settings.
  25.  
  26. Copy and paste this into your command line to get started with running `:focus`
  27. specs via tags instead of having to always pass a line number to your `rspec`
  28. commands.
  29.  
  30. echo "--color
  31. --no-profile
  32. --format Fuubar
  33. --deprecation-out log/rspec-deprecations.log
  34. --tag focus" > ~/.rspec
  35.  
  36. Remove the `--tag focus` line to run all specs (hint the above snippet will
  37. tell RSpec to *only* run `:focus` tagged specs).
  38.  
  39. Run `rspec --help` for more ways to customize your RSpec experience.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement