Sha256: 6abcb790b921c5ec6dd2f3078a82705200bc16da97730e88b4c5f7d45f10b0f8

Contents?: true

Size: 1.57 KB

Versions: 42

Compression:

Stored size: 1.57 KB

Contents

Feature: match matcher

  The match matcher calls #match on the object, passing if #match returns a
  truthy (not false or nil) value.  Regexp and String both provide a #match
  method.

    ```ruby
    "a string".should match(/str/) # passes
    "a string".should match(/foo/) # fails
    /foo/.should match("food")     # passes
    /foo/.should match("drinks")   # fails
    ```

  This is equivalent to using the =~ matcher (see the operator matchers
  feature for more details).

  Scenario: string usage
    Given a file named "string_match_spec.rb" with:
      """ruby
      describe "a string" do
        it { should match(/str/) }
        it { should_not match(/foo/) }

        # deliberate failures
        it { should_not match(/str/) }
        it { should match(/foo/) }
      end
      """
    When I run `rspec string_match_spec.rb`
    Then the output should contain all of these:
      | 4 examples, 2 failures                 |
      | expected "a string" not to match /str/ |
      | expected "a string" to match /foo/     |

  Scenario: regular expression usage
    Given a file named "regexp_match_spec.rb" with:
      """ruby
      describe /foo/ do
        it { should match("food") }
        it { should_not match("drinks") }

        # deliberate failures
        it { should_not match("food") }
        it { should match("drinks") }
      end
      """
    When I run `rspec regexp_match_spec.rb`
    Then the output should contain all of these:
      | 4 examples, 2 failures             |
      | expected /foo/ not to match "food" |
      | expected /foo/ to match "drinks"   |

Version data entries

42 entries across 42 versions & 12 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/rspec-expectations-2.14.5/features/built_in_matchers/match.feature
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/rspec-expectations-2.14.5/features/built_in_matchers/match.feature
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/rspec-expectations-2.14.5/features/built_in_matchers/match.feature
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/features/built_in_matchers/match.feature
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/features/built_in_matchers/match.feature
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/features/built_in_matchers/match.feature
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/features/built_in_matchers/match.feature
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/rspec-expectations-2.14.5/features/built_in_matchers/match.feature
vagrant-cloudstack-1.1.0 vendor/bundle/gems/rspec-expectations-2.14.5/features/built_in_matchers/match.feature
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/rspec-expectations-2.13.0/features/built_in_matchers/match.feature
rspec-expectations-2.99.2 features/built_in_matchers/match.feature
dxruby_rp5-0.0.4 spec/vendor/rspec-expectations-2.14.4/features/built_in_matchers/match.feature
rspec-expectations-2.99.1 features/built_in_matchers/match.feature
rspec-expectations-2.99.0 features/built_in_matchers/match.feature
rspec-expectations-2.99.0.rc1 features/built_in_matchers/match.feature
rspec-expectations-2.99.0.beta2 features/built_in_matchers/match.feature
rspec-expectations-2.14.5 features/built_in_matchers/match.feature
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/rspec-expectations-2.14.4/features/built_in_matchers/match.feature
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/rspec-expectations-2.14.4/features/built_in_matchers/match.feature
dxruby_rp5-0.0.3 spec/vendor/rspec-expectations-2.14.4/features/built_in_matchers/match.feature