instance method assert_no_queries_match

Ruby on Rails edge

Since v7.2.4

Available in: v7.2.4 v8.0.5.1 v8.1.4 edge

Signature

assert_no_queries_match(match, include_schema: false, &block)

Asserts that no SQL queries matching the pattern are executed in the given block.

```
assert_no_queries_match(/SELECT/i) { post.comments }
```

If the `:include_schema` option is provided, any queries (including schema related)
that match the matcher are counted.

```
assert_no_queries_match(/FROM pg_attribute/i, include_schema: true) { Post.columns }
```

: [R] (String | Regexp, ?include_schema: bool) { () -> R } -> R

Parameters

match req
include_schema key = false
block block
Source
# File activerecord/lib/active_record/testing/query_assertions.rb, line 113
      def assert_no_queries_match(match, include_schema: false, &block)
        assert_queries_match(match, count: 0, include_schema: include_schema, &block)
      end

Defined in activerecord/lib/active_record/testing/query_assertions.rb line 113 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::Assertions::QueryAssertions

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close