Skip to content

Latest commit

 

History

History
59 lines (47 loc) · 1.3 KB

File metadata and controls

59 lines (47 loc) · 1.3 KB

Agent Guidelines

Testing Conventions

Use Existing Fixtures

Prefer using existing fixtures over creating new records in tests. For example, use leaves(:welcome_page) instead of books(:handbook).press Page.new(body: "..."), title: "...".

URL Helpers in Tests

Use _path helpers instead of _url helpers in controller/integration tests unless you need to test across different hosts or explicitly need the full URL.

Preferred:

get book_slug_path(books(:handbook))

Avoid:

get book_slug_url(books(:handbook))

Response Body Assertions

Use assert_in_body and assert_not_in_body to check if text is present or absent in the response body without DOM manipulation.

Preferred:

assert_in_body "Expected content"
assert_not_in_body "Unexpected content"

Avoid:

assert_includes response.body, "Expected content"
assert_not_includes response.body, "Unexpected content"

Controller Conventions

Simplified respond_to Blocks

When using respond_to with default rendering, omit the { render } block as it's implied.

Preferred:

def show
  respond_to do |format|
    format.html
    format.md
  end
end

Avoid:

def show
  respond_to do |format|
    format.html { render }
    format.md { render }
  end
end