Created
August 4, 2025 16:42
-
-
Save RStankov/53df6ded146af02cae3adffaa713bf2b to your computer and use it in GitHub Desktop.
Cursor rules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When tasked with generating a new file (e.g., model, factory, test), first identify existing files of the same type in the project. Open several relevant examples and analyze their structure, naming conventions, and implementation patterns. Use these patterns as a reference to create a consistent and idiomatic new file. Focus on reusing established conventions and aligning with the existing codebase. | |
# When writing Ruby | |
Follow the project rubocop rules. | |
- Prefer `case in`, instead of `case where` | |
- Prefer `_1` for blocks with one argument, where you otherwise will use a single letter | |
- Use `!` versions for `save!` / `update!` / `destroy!` when not checking the result of the operation | |
- Don't define methods ending with `!` unless there is a method with the same name without `!` | |
# When writing RSpec tests | |
- Avoid `let` / `before` | |
- Use factories. They are called with `build` or `create | |
- Don't use the `Faker` gem | |
- When you need to make multiple assertions for some object, use `has_attribute` | |
- Use `described_class` when referencing the test object | |
- Use `allow` only to stub External services calls | |
- Use `have_been_enqueued` to test Jobs | |
- Use `expect_to_be_destroyed(record)` to check if the record is deleted | |
- Avoid using `context`. Especially when `context` has only one example | |
- When naming `it` examples don't use "if", in the name use "when" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment