Module: Object::WithBenchmark::Etest

Defined in:
lib/vex/base/object/with_benchmark.rb

Defined Under Namespace

Classes: DL

Instance Method Summary collapse

Instance Method Details

#test_benchmarkObject


81
82
83
84
85
# File 'lib/vex/base/object/with_benchmark.rb', line 81

def test_benchmark
  s = ""
  assert_equal 6, "string".benchmark(s, "").length
  assert s.length > 0
end

#test_labelObject


87
88
89
90
91
# File 'lib/vex/base/object/with_benchmark.rb', line 87

def test_label
  App.logger.stubs(:warn).returns(nil)

  assert_equal 6, "string".benchmark("oh! a label!").length
end

#test_loggerObject


100
101
102
103
104
105
106
107
108
109
# File 'lib/vex/base/object/with_benchmark.rb', line 100

def test_logger
  s = "string"

  def s.logger; @logger ||= DL.new; end
  assert s.respond_to?(:logger)
  assert s.logger.msg.blank?

  assert_equal 6, s.benchmark.length
  assert !s.logger.msg.blank?
end

#test_resultsObject


72
73
74
75
76
77
78
79
# File 'lib/vex/base/object/with_benchmark.rb', line 72

def test_results
  App.logger.stubs(:warn).returns(nil)

  assert_equal 6, "string".benchmark.length
  assert_raise(NoMethodError) { 
    "string".benchmark.you_dont_know_me 
  }
end