This repository was archived by the owner on Nov 30, 2024. It is now read-only.
File tree 2 files changed +6
-6
lines changed
features/setting_constraints 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -279,7 +279,7 @@ expect(double).to receive(:msg).with(hash_including(:a => 5)) # first arg is a h
279
279
expect(double).to receive(:msg ).with(array_including(5 )) # first arg is an array with 5 as one of the key-values
280
280
expect(double).to receive(:msg ).with(hash_excluding(:a => 5 )) # first arg is a hash without a: 5 as one of the key-values
281
281
expect(double).to receive(:msg ).with(start_with(' a' )) # any matcher, custom or from rspec-expectations
282
- expect(double).to receive(:msg ).with(satisfy{ |data | data.dig(:a , :b , :c ) == 5 }) # any expectation
282
+ expect(double).to receive(:msg ).with(satisfy { |data | data.dig(:a , :b , :c ) == 5 }) # assert anything you want
283
283
```
284
284
285
285
## Receive Counts
Original file line number Diff line number Diff line change @@ -77,18 +77,18 @@ Feature: Matching arguments
77
77
"""ruby
78
78
RSpec.describe "Using satisfy for complex custom expecations" do
79
79
let(:dbl) { double }
80
- before do
81
- expectation = satisfy do |data|
82
- data[:a][:b][:c] == 5
83
- end
84
- expect(dbl).to receive(:foo).with(expectation)
80
+
81
+ def a_b_c_equals_5
82
+ satisfy { |data| data[:a][:b][:c] == 5 }
85
83
end
86
84
87
85
it "passes when the expectation is true" do
86
+ expect(dbl).to receive(:foo).with(a_b_c_equals_5)
88
87
dbl.foo(a: { b: { c: 5 } })
89
88
end
90
89
91
90
it "fails when the expectation is false" do
91
+ expect(dbl).to receive(:foo).with(a_b_c_equals_5)
92
92
dbl.foo(a: { b: { c: 3 } })
93
93
end
94
94
end
You can’t perform that action at this time.
0 commit comments