Sha256: 0f4dd0cdd2b6d9e1c18018dd2e0eee7ff63abefeb95f23f66013329b90e0f937

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

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:
      """
      require 'test/unit'
      require 'rspec/expectations'
      
      Rspec::Matchers.define :be_a_multiple_of do |expected|
        match do |actual|
          actual % expected == 0
        end
      end
      
      class Test::Unit::TestCase
        include Rspec::Matchers
      end
      
      class TestMultiples < Test::Unit::TestCase
      
        def test_9_should_be_a_multiple_of_3
          9.should be_a_multiple_of(3)
        end

        def test_9_should_be_a_multiple_of_4
          9.should be_a_multiple_of(4)
        end
        
      end
      """
    When I run "ruby test_multiples.rb"
    Then the exit code should be 256
    And the stdout should match "expected 9 to be a multiple of 4"
    And the stdout should match "2 tests, 0 assertions, 0 failures, 1 errors"

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rspec-core-2.0.0.a6 features/matchers/define_matcher_outside_rspec.feature
rspec-core-2.0.0.a5 features/matchers/define_matcher_outside_rspec.feature
rspec-core-2.0.0.a4 features/matchers/define_matcher_outside_rspec.feature
rspec-core-2.0.0.a3 features/matchers/define_matcher_outside_rspec.feature