Sha256: fcf6ff083e0197a20f602722ed145547731c1b8709f387d47fb14f73620a5c5e

Contents?: true

Size: 1.55 KB

Versions: 13

Compression:

Stored size: 1.55 KB

Contents

require File.dirname(__FILE__) + '/../../../test_helper'

module Spec
  module Api
    module Helper
      class ThrowingTest < Test::Unit::TestCase

        # should.raise
  
        def test_should_throw_should_pass_when_proper_symbol_is_thrown
          assert_nothing_raised do
            proc { throw :foo }.should.throw :foo
          end
        end
  
        def test_should_throw_should_fail_when_wrong_exception_is_thrown
          assert_raise(ExpectationNotMetError) do
            proc { throw :bar }.should.throw :foo
          end
        end
   
        def test_should_throw_should_fail_when_no_symbol_is_thrown
          assert_raise(ExpectationNotMetError) do
            proc {''.to_s}.should.throw :foo
          end
        end

        # should.not.throw

        def test_should_not_throw_should_fail_when_specific_symbol_is_thrown
          assert_raise(ExpectationNotMetError) do
            proc { throw :foo }.should.not.throw :foo
          end
        end

        def test_should_not_throw_should_pass_when_other_symbol_is_thrown
          assert_nothing_raised do
            proc { throw :bar }.should.not.throw :foo
          end
        end

        def test_should_not_throw_should_pass_when_no_symbol_is_thrown
          assert_nothing_raised do
            proc { ''.to_s }.should.not.throw :foo
          end
        end

        def test_should_not_throw_should_pass_when_no_symbol_is_thrown_and_none_is_specified
          assert_nothing_raised do
            proc { ''.to_s }.should.not.throw
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rspec-0.5.0 test/spec/api/helper/throwing_test.rb
rspec-0.5.1 test/spec/api/helper/throwing_test.rb
rspec-0.5.10 test/spec/api/helper/throwing_test.rb
rspec-0.5.11 test/spec/api/helper/throwing_test.rb
rspec-0.5.12 test/spec/api/helper/throwing_test.rb
rspec-0.5.6 test/spec/api/helper/throwing_test.rb
rspec-0.5.8 test/spec/api/helper/throwing_test.rb
rspec-0.5.4 test/spec/api/helper/throwing_test.rb
rspec-0.5.9 test/spec/api/helper/throwing_test.rb
rspec-0.5.5 test/spec/api/helper/throwing_test.rb
rspec-0.5.7 test/spec/api/helper/throwing_test.rb
rspec-0.5.2 test/spec/api/helper/throwing_test.rb
rspec-0.5.3 test/spec/api/helper/throwing_test.rb