Sha256: 723ea3bd87bfa37f97ffe8ddd0d1020870b00a892d3f31bf5c1f36e237f8178c

Contents?: true

Size: 1.15 KB

Versions: 33

Compression:

Stored size: 1.15 KB

Contents

class Test::Unit::TestCase
  class << self
    # Create a test method.  +name+ is a native-language string to describe the test
    # (e.g., no more +test_this_crazy_thing_with_underscores+).
    #
    #     test "A user should not be able to delete another user" do
    #       assert_false @user.can?(:delete, @other_user)
    #     end
    #
    def test(name, opts={}, &block)
      test_name = ["test:", context_name, name].reject { |n| n == "" }.join(' ')
      # puts "running test #{test_name}"
      defined = instance_method(test_name) rescue false
      raise "#{test_name} is already defined in #{self}" if defined

      unless opts[:before].nil?
        before_should_callbacks[test_name] = opts[:before]
      end
      
      if block_given?
        define_method(test_name, &block)
      else
        define_method(test_name) do
          flunk "No implementation provided for #{name}"
        end
      end
    end
    
    %w(it should tests).each {|m| alias_method m, :test} 

    def before_test(name, &block)
      test(name, :before => block) {}
    end

    %w(before_it before_should before_tests).each {|m| alias_method m, :before_test}
  end
end

Version data entries

33 entries across 33 versions & 6 rubygems

Version Path
auser-poolparty-1.3.0 vendor/gems/context/lib/context/test.rb
auser-poolparty-1.3.1 vendor/gems/context/lib/context/test.rb
auser-poolparty-1.3.10 vendor/gems/context/lib/context/test.rb
auser-poolparty-1.3.11 vendor/gems/context/lib/context/test.rb
auser-poolparty-1.3.12 vendor/gems/context/lib/context/test.rb
auser-poolparty-1.3.13 vendor/gems/context/lib/context/test.rb
auser-poolparty-1.3.14 vendor/gems/context/lib/context/test.rb
auser-poolparty-1.3.15 vendor/gems/context/lib/context/test.rb
auser-poolparty-1.3.16 vendor/gems/context/lib/context/test.rb
auser-poolparty-1.3.17 vendor/gems/context/lib/context/test.rb
auser-poolparty-1.3.2 vendor/gems/context/lib/context/test.rb
auser-poolparty-1.3.3 vendor/gems/context/lib/context/test.rb
auser-poolparty-1.3.4 vendor/gems/context/lib/context/test.rb
auser-poolparty-1.3.5 vendor/gems/context/lib/context/test.rb
auser-poolparty-1.3.6 vendor/gems/context/lib/context/test.rb
auser-poolparty-1.3.7 vendor/gems/context/lib/context/test.rb
auser-poolparty-1.3.8 vendor/gems/context/lib/context/test.rb
djsun-context-0.5.5 lib/context/test.rb
djsun-context-0.5.6 lib/context/test.rb
fairchild-poolparty-1.3.17 vendor/gems/context/lib/context/test.rb