Sha256: 00b6c773534b148739b88d10a55dd98195952a57ef6a8f1a49da391bc24f010e

Contents?: true

Size: 1.04 KB

Versions: 12

Compression:

Stored size: 1.04 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 "rspec/expectations"
      require "test/unit"
      
      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 status should not be 0 
    And I should see "expected 9 to be a multiple of 4"
    And I should see "2 tests, 0 assertions, 0 failures, 1 errors"

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rspec-expectations-2.0.0.beta.8 features/matchers/define_matcher_outside_rspec.feature
rspec-expectations-2.0.0.beta.7 features/matchers/define_matcher_outside_rspec.feature
rspec-expectations-2.0.0.beta.6 features/matchers/define_matcher_outside_rspec.feature
rspec-expectations-2.0.0.beta.5 features/matchers/define_matcher_outside_rspec.feature
rspec-expectations-2.0.0.beta.4 features/matchers/define_matcher_outside_rspec.feature
rspec-expectations-2.0.0.beta.3 features/matchers/define_matcher_outside_rspec.feature
rspec-expectations-2.0.0.beta.2 features/matchers/define_matcher_outside_rspec.feature
rspec-expectations-2.0.0.beta.1 features/matchers/define_matcher_outside_rspec.feature
rspec-expectations-2.0.0.a10 features/matchers/define_matcher_outside_rspec.feature
rspec-expectations-2.0.0.a9 features/matchers/define_matcher_outside_rspec.feature
rspec-expectations-2.0.0.a8 features/matchers/define_matcher_outside_rspec.feature
rspec-expectations-2.0.0.a7 features/matchers/define_matcher_outside_rspec.feature