Sha256: ef134f573624a78f29ce5a0aa780533cd12bc9315d4d25c675b863aab4997b89

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

Feature: custom matcher shortcut

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

  Scenario: creating a matcher with default messages
    Given a file named test_multiples.rb with:
      """
      $:.unshift File.join(File.dirname(__FILE__), "/../lib")
      require 'test/unit'
      require 'spec/expectations'
      
      Spec::Matchers.create :be_a_multiple_of do |expected|
        match do |actual|
          actual % expected == 0
        end
      end
      
      class Test::Unit::TestCase
        include Spec::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 it with the ruby interpreter
    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, 1 failures, 0 errors"

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rspec-1.2.1 features/matchers/create_matcher_outside_rspec.feature
rspec-1.2.2 features/matchers/create_matcher_outside_rspec.feature