Sha256: e1328c19c132d0c2ffa9aa81608c0295d450cb453e32a07d3318cf169263a64f

Contents?: true

Size: 1.01 KB

Versions: 11

Compression:

Stored size: 1.01 KB

Contents

require File.expand_path('../acceptance_test_helper', __FILE__)
require 'mocha/setup'

class ThrowTest < Test::Unit::TestCase

  include AcceptanceTest

  def setup
    setup_acceptance_test
  end

  def teardown
    teardown_acceptance_test
  end

  def test_should_throw_tag
    test_result = run_as_test do
      foo = stub('foo')
      foo.stubs(:bar).throws(:tag)
      assert_throws(:tag) { foo.bar }
    end
    assert_passed(test_result)
  end

  def test_should_throw_with_return_value
    test_result = run_as_test do
      foo = stub('foo')
      foo.stubs(:bar).throws(:tag, 'return-value')
      return_value = catch(:tag) { foo.bar }
      assert_equal 'return-value', return_value
    end
    assert_passed(test_result)
  end

  def test_should_throw_two_different_tags
    test_result = run_as_test do
      foo = stub('foo')
      foo.stubs(:bar).throws(:tag_one).then.throws(:tag_two)
      assert_throws(:tag_one) { foo.bar }
      assert_throws(:tag_two) { foo.bar }
    end
    assert_passed(test_result)
  end

end

Version data entries

11 entries across 10 versions & 3 rubygems

Version Path
challah-1.0.0.beta3 vendor/bundle/gems/mocha-0.13.3/test/acceptance/throw_test.rb
mocha-0.14.0.alpha test/acceptance/throw_test.rb
challah-1.0.0.beta2 vendor/bundle/gems/mocha-0.13.3/test/acceptance/throw_test.rb
challah-1.0.0.beta vendor/bundle/gems/mocha-0.13.3/test/acceptance/throw_test.rb
mocha-0.13.3 test/acceptance/throw_test.rb
mocha-0.13.2 test/acceptance/throw_test.rb
mocha-0.13.1 test/acceptance/throw_test.rb
challah-rolls-0.2.0 vendor/bundle/gems/mocha-0.13.0/test/acceptance/throw_test.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.3/vendor/bundle/gems/mocha-0.13.0/test/acceptance/throw_test.rb
challah-0.8.3 vendor/bundle/gems/mocha-0.13.0/test/acceptance/throw_test.rb
mocha-0.13.0 test/acceptance/throw_test.rb