Sha256: 9d8cf942298372a36d6db9685254c38198a535002aadc7153a43832597b01c1c

Contents?: true

Size: 1.13 KB

Versions: 7

Compression:

Stored size: 1.13 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
      RSpec.describe 10 do
        it { is_expected.to satisfy { |v| v > 5 } }
        it { is_expected.not_to satisfy { |v| v > 15 } }

        # deliberate failures
        it { is_expected.not_to satisfy { |v| v > 5 } }
        it { is_expected.to 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

7 entries across 7 versions & 1 rubygems

Version Path
opal-rspec-0.8.0 rspec-expectations/upstream/features/built_in_matchers/satisfy.feature
opal-rspec-0.8.0.alpha3 rspec-expectations/upstream/features/built_in_matchers/satisfy.feature
opal-rspec-0.8.0.alpha2 rspec-expectations/upstream/features/built_in_matchers/satisfy.feature
opal-rspec-0.8.0.alpha1 rspec-expectations/upstream/features/built_in_matchers/satisfy.feature
opal-rspec-0.7.1 rspec-expectations/upstream/features/built_in_matchers/satisfy.feature
opal-rspec-0.7.0 rspec-expectations/upstream/features/built_in_matchers/satisfy.feature
opal-rspec-0.7.0.rc.2 rspec-expectations/upstream/features/built_in_matchers/satisfy.feature