Sha256: aad43640212033a9a1e76ee6439847d9b6876b2126b9eef176a9eb9694522197

Contents?: true

Size: 1.05 KB

Versions: 29

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 'spec/expectations'
      
      Spec::Matchers.define :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 "ruby test_multiples.rb"
    Then the exit code should be 256
    And the stdout should include "expected 9 to be a multiple of 4"
    And the stdout should include "2 tests, 0 assertions, 1 failures, 0 errors"

Version data entries

29 entries across 29 versions & 9 rubygems

Version Path
rspec-1.3.1 features/matchers/define_matcher_outside_rspec.feature
rspec-1.3.1.rc features/matchers/define_matcher_outside_rspec.feature
rspec-1.3.0 features/matchers/define_matcher_outside_rspec.feature
hubbub-0.0.11 lib/vendor/plugins/rspec/features/matchers/define_matcher_outside_rspec.feature
hubbub-0.0.10 lib/vendor/plugins/rspec/features/matchers/define_matcher_outside_rspec.feature
hubbub-0.0.9 lib/vendor/plugins/rspec/features/matchers/define_matcher_outside_rspec.feature
hubbub-0.0.8 lib/vendor/plugins/rspec/features/matchers/define_matcher_outside_rspec.feature
hubbub-0.0.6 lib/vendor/plugins/rspec/features/matchers/define_matcher_outside_rspec.feature
simple-templater-0.0.1.4 gems/gems/rspec-1.2.9/features/matchers/define_matcher_outside_rspec.feature
media-path-0.1.2 vendor/rspec/features/matchers/define_matcher_outside_rspec.feature
simple-templater-0.0.1.3 vendor/rspec/features/matchers/define_matcher_outside_rspec.feature
pupu-0.0.2.pre vendor/rspec/features/matchers/define_matcher_outside_rspec.feature
media-path-0.1.1.pre vendor/rspec/features/matchers/define_matcher_outside_rspec.feature
simple-templater-0.0.1.2 vendor/rspec/features/matchers/define_matcher_outside_rspec.feature
media-path-0.1.1 vendor/rspec/features/matchers/define_matcher_outside_rspec.feature
simple-templater-0.0.1.1 vendor/rspec/features/matchers/define_matcher_outside_rspec.feature
pupu-0.0.2 vendor/rspec/features/matchers/define_matcher_outside_rspec.feature
rango-0.0.6 vendor/rspec/features/matchers/define_matcher_outside_rspec.feature
rango-0.1.pre vendor/rspec/features/matchers/define_matcher_outside_rspec.feature
pupu-0.0.1 vendor/rspec/features/matchers/define_matcher_outside_rspec.feature