Sha256: 1be9bddaf30e08fb3fe59d64672f44fab136e66fa078ff54e6c4a5433c6ede8c

Contents?: true

Size: 1.22 KB

Versions: 12

Compression:

Stored size: 1.22 KB

Contents

require 'helper'

class TestApp < Test::Unit::TestCase
  def test_root
    expected = File.expand_path("#{File.dirname(__FILE__)}/..")
    
    assert_equal expected, App::Root.find_starting_in(File.dirname(__FILE__))
    assert_equal expected, App::Root.find
    assert_equal expected, App.root

    App.root = "foo"
    assert_equal "foo", App.root

    App.root = nil
    assert_equal expected, App.root
  end

  def test_object_attributes
    a = {}
    assert_raise(NoMethodError) {  
      a.foo
    }
    
    a.define_attribute :foo, "bar"
    assert_equal("bar", a.foo)

    a.define_attribute :foo, "baz"
    assert_equal("baz", a.foo)

    a.define_attribute :foo, nil
    assert_equal(nil, a.foo)
  end

  def test_benchmark_logger
    r = []
    
    logger = Logger.new(STDERR)
    logger.formatter = proc { |_, _, _, msg| r << msg; nil }
    
    foo = logger.benchmark {
      "foo"
    }
    assert_equal("foo", foo)
    assert_equal(["Benchmark: 0 msecs"], r)

    r = []
    foo = logger.benchmark("message") { "foo" }
    assert_equal("foo", foo)
    assert_equal(["message: 0 msecs"], r)

    r = []
    foo = logger.benchmark("message", :minimum => 1) { "foo" }
    assert_equal("foo", foo)
    assert_equal([], r)
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
radiospieler-0.3.0 test/app_test.rb
radiospiel-app-0.2.10 test/app_test.rb
radiospiel-app-0.2.9 test/app_test.rb
radiospiel-app-0.2.7 test/app_test.rb
radiospiel-app-0.2.6 test/app_test.rb
radiospiel-app-0.2.5 test/app_test.rb
radiospiel-app-0.2.3 test/app_test.rb
radiospiel-app-0.2.2 test/app_test.rb
radiospiel-app-0.2.1 test/app_test.rb
radiospiel-app-0.2.0 test/app_test.rb
radiospiel-app-0.1.1 test/app_test.rb
radiospiel-app-0.1.0 test/app_test.rb