Sha256: 6913c1679882b729798f1a0e98b659678e0969fb04c1f40bf070fcefbc2c53c9

Contents?: true

Size: 1.52 KB

Versions: 40

Compression:

Stored size: 1.52 KB

Contents

require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
require 'assert_error'

class AssertErrorTest < Test::Unit::TestCase

  it "specfies an error type and message that should be raised" do
    assert_error RuntimeError, "Too funky" do
      raise RuntimeError.new("Too funky")
    end
  end

  it "flunks if the error message is wrong" do
    err = assert_raise Test::Unit::AssertionFailedError do
      assert_error RuntimeError, "not good" do
        raise RuntimeError.new("Too funky")
      end
    end
    assert_match(/not good/i, err.message) 
    assert_match(/too funky/i, err.message) 
  end

  it "flunks if the error type is wrong" do
    err = assert_raise Test::Unit::AssertionFailedError do
      assert_error StandardError, "Too funky" do
        raise RuntimeError.new("Too funky")
      end
    end
    assert_match(/StandardError/i, err.message) 
    assert_match(/RuntimeError/i, err.message) 
  end

  it "can match error message text using a series of Regexps" do 
    assert_error StandardError, /too/i, /funky/i do
      raise StandardError.new("Too funky")
    end
  end

  it "flunks if the error message doesn't match all the Regexps" do
    err = assert_raise Test::Unit::AssertionFailedError do
      assert_error StandardError, /way/i, /too/i, /funky/i do
        raise StandardError.new("Too funky")
      end
    end
    assert_match(/way/i, err.message) 
  end

  it "can operate without any message specification" do
    assert_error StandardError do 
      raise StandardError.new("ooof")
    end
  end
end

Version data entries

40 entries across 37 versions & 3 rubygems

Version Path
ceedling-0.31.1 vendor/hardmock/test/functional/assert_error_test.rb
ceedling-0.31.0 vendor/hardmock/test/functional/assert_error_test.rb
ceedling-0.30.0 vendor/hardmock/test/functional/assert_error_test.rb
ceedling-0.28.3 vendor/hardmock/test/functional/assert_error_test.rb
ceedling-0.28.2 vendor/hardmock/test/functional/assert_error_test.rb
ceedling-0.28.1 vendor/hardmock/test/functional/assert_error_test.rb
ceedling-0.27.0 vendor/hardmock/test/functional/assert_error_test.rb
ceedling-0.25.0 vendor/hardmock/test/functional/assert_error_test.rb
ceedling-0.24.0 vendor/hardmock/test/functional/assert_error_test.rb
ceedling-0.22.0 vendor/hardmock/test/functional/assert_error_test.rb
ceedling-0.21.0 vendor/hardmock/test/functional/assert_error_test.rb
ceedling-0.20.3 vendor/hardmock/test/functional/assert_error_test.rb
ceedling-0.20.2 vendor/hardmock/test/functional/assert_error_test.rb
ceedling-0.19.0 vendor/hardmock/test/functional/assert_error_test.rb
ceedling-0.18.0 vendor/hardmock/test/functional/assert_error_test.rb
ceedling-0.17.0 vendor/hardmock/test/functional/assert_error_test.rb
ceedling-0.16.0 vendor/hardmock/test/functional/assert_error_test.rb
ceedling-0.15.6 vendor/hardmock/test/functional/assert_error_test.rb
ceedling-0.15.5 vendor/hardmock/test/functional/assert_error_test.rb
ceedling-0.15.4 vendor/hardmock/test/functional/assert_error_test.rb