aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/testing
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/test/testing')
-rw-r--r--activesupport/test/testing/performance_test.rb23
1 files changed, 21 insertions, 2 deletions
diff --git a/activesupport/test/testing/performance_test.rb b/activesupport/test/testing/performance_test.rb
index 74d7dae9e7..53073cb8db 100644
--- a/activesupport/test/testing/performance_test.rb
+++ b/activesupport/test/testing/performance_test.rb
@@ -11,7 +11,7 @@ module ActiveSupport
assert_equal "1", amount_metric.format(1.23)
assert_equal "40,000,000", amount_metric.format(40000000)
end
-
+
def test_time_format
time_metric = ActiveSupport::Testing::Performance::Metrics[:time].new
assert_equal "0 ms", time_metric.format(0)
@@ -21,7 +21,7 @@ module ActiveSupport
assert_equal "40000.00 sec", time_metric.format(40000)
assert_equal "-5000 ms", time_metric.format(-5)
end
-
+
def test_space_format
space_metric = ActiveSupport::Testing::Performance::Metrics[:digital_information_unit].new
assert_equal "0 Bytes", space_metric.format(0)
@@ -35,6 +35,25 @@ module ActiveSupport
assert_equal "91 TB", space_metric.format(10**14)
assert_equal "910000 TB", space_metric.format(10**18)
end
+
+ def test_environment_format_without_rails
+ metric = ActiveSupport::Testing::Performance::Metrics[:time].new
+ benchmarker = ActiveSupport::Testing::Performance::Benchmarker.new(self, metric)
+ assert_equal "#{RUBY_ENGINE}-#{RUBY_VERSION}.#{RUBY_PATCHLEVEL},#{RUBY_PLATFORM}", benchmarker.environment
+ end
+
+ def test_environment_format_with_rails
+ rails, version = Module.new, Module.new
+ version.const_set :STRING, "4.0.0"
+ rails.const_set :VERSION, version
+ Object.const_set :Rails, rails
+
+ metric = ActiveSupport::Testing::Performance::Metrics[:time].new
+ benchmarker = ActiveSupport::Testing::Performance::Benchmarker.new(self, metric)
+ assert_equal "rails-4.0.0,#{RUBY_ENGINE}-#{RUBY_VERSION}.#{RUBY_PATCHLEVEL},#{RUBY_PLATFORM}", benchmarker.environment
+ ensure
+ Object.send :remove_const, :Rails
+ end
end
end
end \ No newline at end of file