diff options
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/kernel_test.rb | 1 | ||||
-rw-r--r-- | activesupport/test/testing/performance_test.rb | 23 |
2 files changed, 21 insertions, 3 deletions
diff --git a/activesupport/test/core_ext/kernel_test.rb b/activesupport/test/core_ext/kernel_test.rb index 99e4506be7..439bc87323 100644 --- a/activesupport/test/core_ext/kernel_test.rb +++ b/activesupport/test/core_ext/kernel_test.rb @@ -96,7 +96,6 @@ class KernelDebuggerTest < ActiveSupport::TestCase end def test_debugger_not_available_message_to_rails_logger - Object.send(:remove_const, :Rails) if Object.const_defined?(:Rails) rails = Class.new do def self.logger @logger ||= MockStdErr.new 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 |