mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
25 lines
614 B
Ruby
25 lines
614 B
Ruby
|
require 'abstract_unit'
|
||
|
require 'stringio'
|
||
|
|
||
|
class BenchmarkHelperTest < ActionView::TestCase
|
||
|
include RenderERBUtils
|
||
|
tests ActionView::Helpers::BenchmarkHelper
|
||
|
|
||
|
def test_output_in_erb
|
||
|
output = render_erb("Hello <%= benchmark do %>world<% end %>")
|
||
|
expected = 'Hello world'
|
||
|
assert_equal expected, output
|
||
|
end
|
||
|
|
||
|
def test_returns_value_from_block
|
||
|
assert_equal 'test', benchmark { 'test' }
|
||
|
end
|
||
|
|
||
|
def test_default_message
|
||
|
log = StringIO.new
|
||
|
self.stubs(:logger).returns(Logger.new(log))
|
||
|
benchmark {}
|
||
|
assert_match(log.rewind && log.read, /Benchmarking \(\d+.\d+ms\)/)
|
||
|
end
|
||
|
end
|