Sha256: aed6e96b0a7dac135869c2c357830caa5b1918f11af6a6c6be16996cb92f8e15

Contents?: true

Size: 1.64 KB

Versions: 29

Compression:

Stored size: 1.64 KB

Contents

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


if ActiveSupport.const_defined?(:Callbacks) && Test::Unit::TestCase.include?(ActiveSupport::Callbacks)

  class TestUnitTesting < Test::Unit::TestCase
    @@setup_callback_count = 0
    @@setup_method_count = 0
    @@teardown_callback_count = 0
    @@teardown_method_count = 0
    cattr_accessor :setup_callback_count, :setup_method_count, :teardown_callback_count, :teardown_method_count
    
    setup :do_some_setup
    teardown :do_some_teardown
    
    @@has_been_run = false
    def self.run?
      @@has_been_run
    end
    
    def do_some_setup
      @@setup_callback_count += 1
    end
    
    def setup
      @@setup_method_count += 1
    end
    
    def test_something
      assert_equal true, true
      @@has_been_run = true
    end
    
    def teardown
      @@teardown_method_count += 1
    end
    
    def do_some_teardown
      @@teardown_callback_count += 1
    end
  end

  module Test
    module Unit
      describe "Running TestCase tests" do
        before(:all) do
          TestUnitTesting.run unless TestUnitTesting.run?
        end
        
        it "should call the setup callbacks" do
          TestUnitTesting.setup_callback_count.should == 1
        end
        it "should still only call the normal setup method once" do
          TestUnitTesting.setup_method_count.should == 1
        end
        it "should call the teardown callbacks" do
          TestUnitTesting.teardown_callback_count.should == 1
        end
        it "should still only call the normal teardown method once" do
          TestUnitTesting.teardown_method_count.should == 1
        end
      end
    end
  end
  
end

Version data entries

29 entries across 29 versions & 6 rubygems

Version Path
dchelimsky-rspec-rails-1.1.10 spec/rails/interop/testcase_spec.rb
dchelimsky-rspec-rails-1.1.11.1 spec/rails/interop/testcase_spec.rb
dchelimsky-rspec-rails-1.1.11 spec/rails/interop/testcase_spec.rb
dchelimsky-rspec-rails-1.1.6 spec/rails/interop/testcase_spec.rb
dchelimsky-rspec-rails-1.1.7 spec/rails/interop/testcase_spec.rb
dchelimsky-rspec-rails-1.1.8 spec/rails/interop/testcase_spec.rb
dchelimsky-rspec-rails-1.1.9 spec/rails/interop/testcase_spec.rb
jnstq-acts_as_sms-0.1.0 test/vendor/plugins/rspec-rails/spec/rails/interop/testcase_spec.rb
jnstq-acts_as_sms-0.1.1 test/vendor/plugins/rspec-rails/spec/rails/interop/testcase_spec.rb
jnstq-acts_as_sms-0.1.3 test/vendor/plugins/rspec-rails/spec/rails/interop/testcase_spec.rb
jnstq-acts_as_sms-0.1.4 test/vendor/plugins/rspec-rails/spec/rails/interop/testcase_spec.rb
jstorimer-deep-test-2.0.0 sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/interop/testcase_spec.rb
jstorimer-deep-test-1.4.0 sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/interop/testcase_spec.rb
jstorimer-deep-test-1.3.0 sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/interop/testcase_spec.rb
jstorimer-deep-test-1.2.0 sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/interop/testcase_spec.rb
jstorimer-deep-test-1.1.0 sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/interop/testcase_spec.rb
jstorimer-deep-test-1.0.0 sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/interop/testcase_spec.rb
jstorimer-deep-test-0.2.0 sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/interop/testcase_spec.rb
jstorimer-deep-test-0.1.0 sample_rails_project/vendor/plugins/rspec_on_rails/spec/rails/interop/testcase_spec.rb
pictrails-0.5.0 vendor/plugins/rspec-rails/spec/rails/interop/testcase_spec.rb