Sha256: 244a5901e4e9118fc8b95f98ac00d478d103148d4b60db3053e3645b8d100f10
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
Feature: satisfy matcher The satisfy matcher is extremely flexible and can handle almost anything you want to specify. It passes if the block you provide returns true: ```ruby expect(10).to satisfy { |v| v % 5 == 0 } expect(7).not_to satisfy { |v| v % 5 == 0 } ``` This flexibility comes at a cost, however: the failure message ("expected [actual] to satisfy block") is not very descriptive or helpful. You will usually be better served by using one of the other built-in matchers, or writing a custom matcher. Scenario: basic usage Given a file named "satisfy_matcher_spec.rb" with: """ruby describe 10 do it { should satisfy { |v| v > 5 } } it { should_not satisfy { |v| v > 15 } } # deliberate failures it { should_not satisfy { |v| v > 5 } } it { should satisfy { |v| v > 15 } } end """ When I run `rspec satisfy_matcher_spec.rb` Then the output should contain all of these: | 4 examples, 2 failures | | expected 10 not to satisfy block | | expected 10 to satisfy block |
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rspec-expectations-3.0.0.beta2 | features/built_in_matchers/satisfy.feature |
rspec-expectations-3.0.0.beta1 | features/built_in_matchers/satisfy.feature |