Sha256: 5fa2c30aa72e2f838e4679c52232821c53cee0670aab2eb6756e3dc380e6778c

Contents?: true

Size: 1010 Bytes

Versions: 1

Compression:

Stored size: 1010 Bytes

Contents

Feature: define matcher outside rspec

  In order to express my domain clearly in my code examples
  As a non-rspec user
  I want a shortcut to define custom matchers

  Scenario: define a matcher with default messages
    Given a file named "test_multiples.rb" with:
      """ruby
      require "minitest/autorun"
      require "rspec/expectations/minitest_integration"

      RSpec::Matchers.define :be_a_multiple_of do |expected|
        match do |actual|
          actual % expected == 0
        end
      end

      class TestMultiples < Minitest::Test

        def test_9_should_be_a_multiple_of_3
          expect(9).to be_a_multiple_of(3)
        end

        def test_9_should_be_a_multiple_of_4
          expect(9).to be_a_multiple_of(4)
        end

      end
      """
    When I run `ruby test_multiples.rb`
    Then the exit status should not be 0
    And the output should contain "expected 9 to be a multiple of 4"
    And the output should contain "2 runs, 2 assertions, 1 failures, 0 errors"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-expectations-3.0.0.beta2 features/custom_matchers/define_matcher_outside_rspec.feature