This file is indexed.

/usr/share/doc/ruby-rspec-mocks/features/old_syntax/should_receive.feature is in ruby-rspec-mocks 3.4.0c3e0m1s1-1ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
@allow-old-syntax
Feature: `should_receive`

  `should_receive` is the old way to [expect messages](../basics/expecting-messages) but carries the
  baggage of a global monkey patch on all objects. It supports the
  same fluent interface for [setting constraints](../setting-constraints) and [configuring responses](../configuring-responses).

  Similarly, you can use `should_not_receive` to set a negative message expectation.

  Background:
    Given a file named "spec/spec_helper.rb" with:
      """ruby
      RSpec.configure do |config|
        config.mock_with :rspec do |mocks|
          mocks.syntax = :should
        end
      end
      """
    And a file named ".rspec" with:
      """
      --require spec_helper
      """

  Scenario: Failing positive message expectation
    Given a file named "spec/unfulfilled_message_expectation_spec.rb" with:
      """ruby
      RSpec.describe "An unfulfilled message expectation" do
        it "triggers a failure" do
          dbl = double("Some Collaborator")
          dbl.should_receive(:foo)
        end
      end
      """
     When I run `rspec spec/unfulfilled_message_expectation_spec.rb`
     Then it should fail with:
      """
        1) An unfulfilled message expectation triggers a failure
           Failure/Error: dbl.should_receive(:foo)

             (Double "Some Collaborator").foo(*(any args))
                 expected: 1 time with any arguments
                 received: 0 times with any arguments
      """

  Scenario: Passing positive message expectation
    Given a file named "spec/fulfilled_message_expectation_spec.rb" with:
      """ruby
      RSpec.describe "A fulfilled message expectation" do
        it "passes" do
          dbl = double("Some Collaborator")
          dbl.should_receive(:foo)
          dbl.foo
        end
      end
      """
     When I run `rspec spec/fulfilled_message_expectation_spec.rb`
     Then the examples should all pass

  Scenario: Failing negative message expectation
    Given a file named "spec/negative_message_expectation_spec.rb" with:
      """ruby
      RSpec.describe "A negative message expectation" do
        it "fails when the message is received" do
          dbl = double("Some Collaborator").as_null_object
          dbl.should_not_receive(:foo)
          dbl.foo
        end
      end
      """
     When I run `rspec spec/negative_message_expectation_spec.rb`
     Then it should fail with:
      """
        1) A negative message expectation fails when the message is received
           Failure/Error: dbl.foo

             (Double "Some Collaborator").foo(no args)
                 expected: 0 times with any arguments
                 received: 1 time
      """

  Scenario: Passing negative message expectation
    Given a file named "spec/negative_message_expectation_spec.rb" with:
      """ruby
      RSpec.describe "A negative message expectation" do
        it "passes if the message is never received" do
          dbl = double("Some Collaborator").as_null_object
          dbl.should_not_receive(:foo)
        end
      end
      """
     When I run `rspec spec/negative_message_expectation_spec.rb`
     Then the examples should all pass