rspec

RSpec

Used in 68 ruby projects (avg ★776)

Ruby
Testing
Default
Used by 68 projects

Details

Language / Topic
rubyRuby
Category
Testing

Rules

balanced

RSpec

- Use `describe` for the subject (class/method) and `context` for scenarios (`"when user is admin"`). Use `let` for lazy-loaded test data and `let!` for eager evaluation. Use `expect(subject).to` matcher syntax.

RSpec

- Use `describe` for the subject (class/method) and `context` for scenarios (`"when user is admin"`). Use `let` for lazy-loaded test data and `let!` for eager evaluation. Use `expect(subject).to` matcher syntax.
- Use `before(:each)` for per-test setup, `before(:all)` only for truly expensive shared setup. Use `shared_examples` and `it_behaves_like` for reusable test groups. Use `allow(obj).to receive(:method).and_return(value)` for stubs. Use `have_attributes`, `include`, `match_array` matchers for expressive assertions. Use `aggregate_failures` to collect multiple expectations.