Sha256: e93c4ebb1c52bdab48562ca97782295136c7feec770cf0235e7b89f5f72c13aa

Contents?: true

Size: 1.49 KB

Versions: 3

Compression:

Stored size: 1.49 KB

Contents

require 'test_helper'

class TestMatchbox < Test::Unit::TestCase
  context '#assert_accepts' do
    test 'successful assertion' do
      target = mock('target')
      matcher = mock('matcher') do
        expects(:matches?).with(target).returns(true)
        expects(:failure_message).returns('bad failure message')
      end
      
      assert_nothing_raised do
        assert_accepts matcher, target
      end
    end
    
    test 'unsuccessful assertion' do
      target = mock('target')
      matcher = mock('matcher') do
        expects(:matches?).with(target).returns(false)
        expects(:failure_message).returns('bad failure message')
      end
      
      assert_raise Test::Unit::AssertionFailedError do
        assert_accepts matcher, target
      end
    end
  end
  
  context '#assert_rejects' do
    test 'successful assertion' do
      target = mock('target')
      matcher = mock('matcher') do
        expects(:matches?).with(target).returns(false)
        expects(:negative_failure_message).returns('bad failure message')
      end
      
      assert_nothing_raised do
        assert_rejects matcher, target
      end
    end
    
    test 'unsuccessful assertion' do
      target = mock('target')
      matcher = mock('matcher') do
        expects(:matches?).with(target).returns(true)
        expects(:negative_failure_message).returns('bad failure message')
      end
      
      assert_raise Test::Unit::AssertionFailedError do
        assert_rejects matcher, target
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
matchbox-1.0.2 test/test_matchbox.rb
matchbox-1.0.1 test/test_matchbox.rb
matchbox-1.0.0 test/test_matchbox.rb