File: relation_match_array.feature

package info (click to toggle)
ruby-rspec-rails 7.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,796 kB
  • sloc: ruby: 11,068; sh: 198; makefile: 6
file content (23 lines) | stat: -rw-r--r-- 754 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Feature: ActiveRecord::Relation match array

  The `match_array` matcher can be used with an `ActiveRecord::Relation`
  (scope). The assertion will pass if the scope would return all of the
  elements specified in the array on the right hand side.

  Scenario: An example spec with relation match_array matcher
    Given a file named "spec/models/widget_spec.rb" with:
      """ruby
      require "rails_helper"

      RSpec.describe Widget do
        let!(:widgets) { Array.new(3) { Widget.create } }

        subject { Widget.all }

        it "returns all widgets in any order" do
          expect(subject).to match_array(widgets)
        end
      end
      """
    When I run `rspec spec/models/widget_spec.rb`
    Then the examples should all pass