aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/rails-2.0.2/activesupport/test
diff options
context:
space:
mode:
authorfrancis <francis>2008-01-23 01:48:14 +0000
committerfrancis <francis>2008-01-23 01:48:14 +0000
commit60eaae4f7df1f1dae91defb87d3707451c359cf4 (patch)
treee74835c37779a2f094e810960cda07b99a75330e /vendor/rails-2.0.2/activesupport/test
parent71d22c740302e1f83bbbd89b229734ea9c67493c (diff)
Freeze in rails 2.0.2 (Am I going to regret having this beast in CVS?)
Diffstat (limited to 'vendor/rails-2.0.2/activesupport/test')
-rw-r--r--vendor/rails-2.0.2/activesupport/test/abstract_unit.rb20
-rw-r--r--vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/a/b.rb2
-rw-r--r--vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/a/c/d.rb2
-rw-r--r--vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/a/c/e/f.rb2
-rw-r--r--vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/application.rb1
-rw-r--r--vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/class_folder.rb3
-rw-r--r--vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/class_folder/class_folder_subclass.rb3
-rw-r--r--vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/class_folder/inline_class.rb2
-rw-r--r--vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/class_folder/nested_class.rb7
-rw-r--r--vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/conflict.rb1
-rw-r--r--vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/counting_loader.rb5
-rw-r--r--vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/cross_site_dependency.rb2
-rw-r--r--vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/e.rb2
-rw-r--r--vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/module_folder/inline_class.rb2
-rw-r--r--vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/module_folder/nested_class.rb4
-rw-r--r--vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/module_folder/nested_sibling.rb2
-rw-r--r--vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/module_with_custom_const_missing/a/b.rb1
-rw-r--r--vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/multiple_constant_file.rb2
-rw-r--r--vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/raises_name_error.rb3
-rw-r--r--vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/raises_no_method_error.rb3
-rw-r--r--vendor/rails-2.0.2/activesupport/test/buffered_logger_test.rb107
-rw-r--r--vendor/rails-2.0.2/activesupport/test/clean_logger_test.rb57
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/array_ext_test.rb250
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/blank_test.rb19
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/cgi_ext_test.rb14
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/class/attribute_accessor_test.rb31
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/class/class_inheritable_attributes_test.rb224
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/class/delegating_attributes_test.rb105
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/class_test.rb46
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/date_ext_test.rb196
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/date_time_ext_test.rb230
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/duplicable_test.rb22
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/duration_test.rb21
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/enumerable_test.rb61
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/exception_test.rb64
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/file_test.rb29
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/float_ext_test.rb25
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/hash_ext_test.rb743
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/integer_ext_test.rb37
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/kernel_test.rb43
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/load_error_tests.rb16
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/module/attr_accessor_with_default_test.rb30
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/module/attr_internal_test.rb52
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/module/attribute_accessor_test.rb33
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/module/attribute_aliasing_test.rb58
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/module_test.rb293
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/name_error_test.rb24
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/numeric_ext_test.rb147
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/object_and_class_ext_test.rb242
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/pathname_test.rb9
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/proc_test.rb11
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/range_ext_test.rb63
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/string_ext_test.rb180
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/symbol_test.rb9
-rw-r--r--vendor/rails-2.0.2/activesupport/test/core_ext/time_ext_test.rb420
-rw-r--r--vendor/rails-2.0.2/activesupport/test/dependencies/check_warnings.rb2
-rw-r--r--vendor/rails-2.0.2/activesupport/test/dependencies/conflict.rb1
-rw-r--r--vendor/rails-2.0.2/activesupport/test/dependencies/cross_site_depender.rb3
-rw-r--r--vendor/rails-2.0.2/activesupport/test/dependencies/mutual_one.rb4
-rw-r--r--vendor/rails-2.0.2/activesupport/test/dependencies/mutual_two.rb4
-rw-r--r--vendor/rails-2.0.2/activesupport/test/dependencies/raises_exception.rb3
-rw-r--r--vendor/rails-2.0.2/activesupport/test/dependencies/requires_nonexistent0.rb1
-rw-r--r--vendor/rails-2.0.2/activesupport/test/dependencies/requires_nonexistent1.rb1
-rw-r--r--vendor/rails-2.0.2/activesupport/test/dependencies/service_one.rb5
-rw-r--r--vendor/rails-2.0.2/activesupport/test/dependencies/service_two.rb2
-rw-r--r--vendor/rails-2.0.2/activesupport/test/dependencies_test.rb751
-rw-r--r--vendor/rails-2.0.2/activesupport/test/deprecation_test.rb151
-rw-r--r--vendor/rails-2.0.2/activesupport/test/inflector_test.rb248
-rw-r--r--vendor/rails-2.0.2/activesupport/test/inflector_test_cases.rb208
-rw-r--r--vendor/rails-2.0.2/activesupport/test/json/decoding_test.rb41
-rw-r--r--vendor/rails-2.0.2/activesupport/test/json/encoding_test.rb111
-rw-r--r--vendor/rails-2.0.2/activesupport/test/multibyte_chars_test.rb173
-rw-r--r--vendor/rails-2.0.2/activesupport/test/multibyte_conformance.rb141
-rw-r--r--vendor/rails-2.0.2/activesupport/test/multibyte_handler_test.rb367
-rw-r--r--vendor/rails-2.0.2/activesupport/test/option_merger_test.rb50
-rw-r--r--vendor/rails-2.0.2/activesupport/test/ordered_options_test.rb84
-rw-r--r--vendor/rails-2.0.2/activesupport/test/test_test.rb73
-rw-r--r--vendor/rails-2.0.2/activesupport/test/time_zone_test.rb98
-rw-r--r--vendor/rails-2.0.2/activesupport/test/whiny_nil_test.rb38
79 files changed, 6540 insertions, 0 deletions
diff --git a/vendor/rails-2.0.2/activesupport/test/abstract_unit.rb b/vendor/rails-2.0.2/activesupport/test/abstract_unit.rb
new file mode 100644
index 000000000..2cfa245bc
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/abstract_unit.rb
@@ -0,0 +1,20 @@
+require 'test/unit'
+
+$:.unshift "#{File.dirname(__FILE__)}/../lib"
+$:.unshift File.dirname(__FILE__)
+require 'active_support'
+
+# Wrap tests that use Mocha and skip if unavailable.
+unless defined? uses_mocha
+ def uses_mocha(test_name)
+ require 'rubygems'
+ gem 'mocha', '>= 0.5.5'
+ require 'mocha'
+ yield
+ rescue LoadError
+ $stderr.puts "Skipping #{test_name} tests. `gem install mocha` and try again."
+ end
+end
+
+# Show backtraces for deprecated behavior for quicker cleanup.
+ActiveSupport::Deprecation.debug = true
diff --git a/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/a/b.rb b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/a/b.rb
new file mode 100644
index 000000000..9c9e6454c
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/a/b.rb
@@ -0,0 +1,2 @@
+class A::B
+end \ No newline at end of file
diff --git a/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/a/c/d.rb b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/a/c/d.rb
new file mode 100644
index 000000000..0f40d6fbc
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/a/c/d.rb
@@ -0,0 +1,2 @@
+class A::C::D
+end \ No newline at end of file
diff --git a/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/a/c/e/f.rb b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/a/c/e/f.rb
new file mode 100644
index 000000000..57dba5a30
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/a/c/e/f.rb
@@ -0,0 +1,2 @@
+class A::C::E::F
+end \ No newline at end of file
diff --git a/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/application.rb b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/application.rb
new file mode 100644
index 000000000..d7d3096dc
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/application.rb
@@ -0,0 +1 @@
+ApplicationController = 10
diff --git a/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/class_folder.rb b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/class_folder.rb
new file mode 100644
index 000000000..ad2b27be6
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/class_folder.rb
@@ -0,0 +1,3 @@
+class ClassFolder
+ ConstantInClassFolder = 'indeed'
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/class_folder/class_folder_subclass.rb b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/class_folder/class_folder_subclass.rb
new file mode 100644
index 000000000..ef66ddaac
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/class_folder/class_folder_subclass.rb
@@ -0,0 +1,3 @@
+class ClassFolder::ClassFolderSubclass < ClassFolder
+ ConstantInClassFolder
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/class_folder/inline_class.rb b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/class_folder/inline_class.rb
new file mode 100644
index 000000000..8235e9072
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/class_folder/inline_class.rb
@@ -0,0 +1,2 @@
+class ClassFolder::InlineClass
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/class_folder/nested_class.rb b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/class_folder/nested_class.rb
new file mode 100644
index 000000000..77ea230d2
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/class_folder/nested_class.rb
@@ -0,0 +1,7 @@
+class ClassFolder
+ class NestedClass
+ end
+
+ class SiblingClass
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/conflict.rb b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/conflict.rb
new file mode 100644
index 000000000..4ac620190
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/conflict.rb
@@ -0,0 +1 @@
+Conflict = 2 \ No newline at end of file
diff --git a/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/counting_loader.rb b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/counting_loader.rb
new file mode 100644
index 000000000..4225c4412
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/counting_loader.rb
@@ -0,0 +1,5 @@
+$counting_loaded_times ||= 0
+$counting_loaded_times += 1
+
+module CountingLoader
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/cross_site_dependency.rb b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/cross_site_dependency.rb
new file mode 100644
index 000000000..21ee554e9
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/cross_site_dependency.rb
@@ -0,0 +1,2 @@
+class CrossSiteDependency
+end \ No newline at end of file
diff --git a/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/e.rb b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/e.rb
new file mode 100644
index 000000000..2f59e4fb7
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/e.rb
@@ -0,0 +1,2 @@
+class E
+end \ No newline at end of file
diff --git a/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/module_folder/inline_class.rb b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/module_folder/inline_class.rb
new file mode 100644
index 000000000..ca8343704
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/module_folder/inline_class.rb
@@ -0,0 +1,2 @@
+class ModuleFolder::InlineClass
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/module_folder/nested_class.rb b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/module_folder/nested_class.rb
new file mode 100644
index 000000000..fc4076bd0
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/module_folder/nested_class.rb
@@ -0,0 +1,4 @@
+module ModuleFolder
+ class NestedClass
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/module_folder/nested_sibling.rb b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/module_folder/nested_sibling.rb
new file mode 100644
index 000000000..80244b8ba
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/module_folder/nested_sibling.rb
@@ -0,0 +1,2 @@
+class ModuleFolder::NestedSibling
+end \ No newline at end of file
diff --git a/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/module_with_custom_const_missing/a/b.rb b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/module_with_custom_const_missing/a/b.rb
new file mode 100644
index 000000000..d12d02f3a
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/module_with_custom_const_missing/a/b.rb
@@ -0,0 +1 @@
+ModuleWithCustomConstMissing::A::B = "10" \ No newline at end of file
diff --git a/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/multiple_constant_file.rb b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/multiple_constant_file.rb
new file mode 100644
index 000000000..a9ff4eb89
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/multiple_constant_file.rb
@@ -0,0 +1,2 @@
+MultipleConstantFile = 10
+SiblingConstant = MultipleConstantFile * 2
diff --git a/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/raises_name_error.rb b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/raises_name_error.rb
new file mode 100644
index 000000000..a49960abf
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/raises_name_error.rb
@@ -0,0 +1,3 @@
+class RaisesNameError
+ FooBarBaz
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/raises_no_method_error.rb b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/raises_no_method_error.rb
new file mode 100644
index 000000000..e1b8fce24
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/autoloading_fixtures/raises_no_method_error.rb
@@ -0,0 +1,3 @@
+class RaisesNoMethodError
+ self.foobar_method_doesnt_exist
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/buffered_logger_test.rb b/vendor/rails-2.0.2/activesupport/test/buffered_logger_test.rb
new file mode 100644
index 000000000..5ce197eba
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/buffered_logger_test.rb
@@ -0,0 +1,107 @@
+require File.dirname(__FILE__) + '/abstract_unit'
+require 'stringio'
+
+class BufferedLoggerTest < Test::Unit::TestCase
+ def setup
+ @message = "A debug message"
+ @integer_message = 12345
+ @output = StringIO.new
+ @logger = ActiveSupport::BufferedLogger.new(@output)
+ end
+
+ def test_should_log_debugging_message_when_debugging
+ @logger.level = Logger::DEBUG
+ @logger.add(Logger::DEBUG, @message)
+ assert @output.string.include?(@message)
+ end
+
+ def test_should_not_log_debug_messages_when_log_level_is_info
+ @logger.level = Logger::INFO
+ @logger.add(Logger::DEBUG, @message)
+ assert ! @output.string.include?(@message)
+ end
+
+ def test_should_add_message_passed_as_block_when_using_add
+ @logger.level = Logger::INFO
+ @logger.add(Logger::INFO) {@message}
+ assert @output.string.include?(@message)
+ end
+
+ def test_should_add_message_passed_as_block_when_using_shortcut
+ @logger.level = Logger::INFO
+ @logger.info {@message}
+ assert @output.string.include?(@message)
+ end
+
+ def test_should_convert_message_to_string
+ @logger.level = Logger::INFO
+ @logger.info @integer_message
+ assert @output.string.include?(@integer_message.to_s)
+ end
+
+ def test_should_convert_message_to_string_when_passed_in_block
+ @logger.level = Logger::INFO
+ @logger.info {@integer_message}
+ assert @output.string.include?(@integer_message.to_s)
+ end
+
+ def test_should_not_evaluate_block_if_message_wont_be_logged
+ @logger.level = Logger::INFO
+ evaluated = false
+ @logger.add(Logger::DEBUG) {evaluated = true}
+ assert evaluated == false
+ end
+
+ def test_should_not_mutate_message
+ message_copy = @message.dup
+ @logger.info @message
+ assert_equal message_copy, @message
+ end
+
+
+ [false, nil, 0].each do |disable|
+ define_method "test_disabling_auto_flush_with_#{disable.inspect}_should_buffer_until_explicit_flush" do
+ @logger.auto_flushing = disable
+
+ 4.times do
+ @logger.info 'wait for it..'
+ assert @output.string.empty?, @output.string
+ end
+
+ @logger.flush
+ assert !@output.string.empty?, @logger.buffer.size
+ end
+
+ define_method "test_disabling_auto_flush_with_#{disable.inspect}_should_flush_at_max_buffer_size_as_failsafe" do
+ @logger.auto_flushing = disable
+ assert_equal ActiveSupport::BufferedLogger::MAX_BUFFER_SIZE, @logger.auto_flushing
+
+ (ActiveSupport::BufferedLogger::MAX_BUFFER_SIZE - 1).times do
+ @logger.info 'wait for it..'
+ assert @output.string.empty?, @output.string
+ end
+
+ @logger.info 'there it is.'
+ assert !@output.string.empty?, @logger.buffer.size
+ end
+ end
+
+ def test_should_know_if_its_loglevel_is_below_a_given_level
+ ActiveSupport::BufferedLogger::Severity.constants.each do |level|
+ @logger.level = ActiveSupport::BufferedLogger::Severity.const_get(level) - 1
+ assert @logger.send("#{level.downcase}?"), "didn't know if it was #{level.downcase}? or below"
+ end
+ end
+
+ def test_should_auto_flush_every_n_messages
+ @logger.auto_flushing = 5
+
+ 4.times do
+ @logger.info 'wait for it..'
+ assert @output.string.empty?, @output.string
+ end
+
+ @logger.info 'there it is.'
+ assert !@output.string.empty?, @output.string
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/clean_logger_test.rb b/vendor/rails-2.0.2/activesupport/test/clean_logger_test.rb
new file mode 100644
index 000000000..5c9c8f914
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/clean_logger_test.rb
@@ -0,0 +1,57 @@
+require File.dirname(__FILE__) + '/abstract_unit'
+require 'stringio'
+
+class CleanLoggerTest < Test::Unit::TestCase
+ def setup
+ @out = StringIO.new
+ @logger = Logger.new(@out)
+ end
+
+ def test_format_message
+ @logger.error 'error'
+ assert_equal "error\n", @out.string
+ end
+
+ def test_silence
+ # Without yielding self.
+ @logger.silence do
+ @logger.debug 'debug'
+ @logger.info 'info'
+ @logger.warn 'warn'
+ @logger.error 'error'
+ @logger.fatal 'fatal'
+ end
+
+ # Yielding self.
+ @logger.silence do |logger|
+ logger.debug 'debug'
+ logger.info 'info'
+ logger.warn 'warn'
+ logger.error 'error'
+ logger.fatal 'fatal'
+ end
+
+ # Silencer off.
+ Logger.silencer = false
+ @logger.silence do |logger|
+ logger.warn 'unsilenced'
+ end
+ Logger.silencer = true
+
+ assert_equal "error\nfatal\nerror\nfatal\nunsilenced\n", @out.string
+ end
+
+ def test_datetime_format
+ @logger.formatter = Logger::Formatter.new
+ @logger.datetime_format = "%Y-%m-%d"
+ @logger.debug 'debug'
+ assert_equal "%Y-%m-%d", @logger.datetime_format
+ assert_match(/D, \[\d\d\d\d-\d\d-\d\d#\d+\] DEBUG -- : debug/, @out.string)
+ end
+
+ def test_nonstring_formatting
+ an_object = [1, 2, 3, 4, 5]
+ @logger.debug an_object
+ assert_equal("#{an_object.inspect}\n", @out.string)
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/array_ext_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/array_ext_test.rb
new file mode 100644
index 000000000..840a4c81d
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/array_ext_test.rb
@@ -0,0 +1,250 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+require 'bigdecimal'
+
+class ArrayExtAccessTests < Test::Unit::TestCase
+ def test_from
+ assert_equal %w( a b c d ), %w( a b c d ).from(0)
+ assert_equal %w( c d ), %w( a b c d ).from(2)
+ assert_nil %w( a b c d ).from(10)
+ end
+
+ def test_to
+ assert_equal %w( a ), %w( a b c d ).to(0)
+ assert_equal %w( a b c ), %w( a b c d ).to(2)
+ assert_equal %w( a b c d ), %w( a b c d ).to(10)
+ end
+end
+
+class ArrayExtToParamTests < Test::Unit::TestCase
+ class ToParam < String
+ def to_param
+ "#{self}1"
+ end
+ end
+
+ def test_string_array
+ assert_equal '', %w().to_param
+ assert_equal 'hello/world', %w(hello world).to_param
+ assert_equal 'hello/10', %w(hello 10).to_param
+ end
+
+ def test_number_array
+ assert_equal '10/20', [10, 20].to_param
+ end
+
+ def test_to_param_array
+ assert_equal 'custom1/param1', [ToParam.new('custom'), ToParam.new('param')].to_param
+ end
+end
+
+class ArrayExtToSentenceTests < Test::Unit::TestCase
+ def test_plain_array_to_sentence
+ assert_equal "", [].to_sentence
+ assert_equal "one", ['one'].to_sentence
+ assert_equal "one and two", ['one', 'two'].to_sentence
+ assert_equal "one, two, and three", ['one', 'two', 'three'].to_sentence
+ end
+
+ def test_to_sentence_with_connector
+ assert_equal "one, two, and also three", ['one', 'two', 'three'].to_sentence(:connector => 'and also')
+ assert_equal "one, two, three", ['one', 'two', 'three'].to_sentence(:connector => '')
+ assert_equal "one, two, three", ['one', 'two', 'three'].to_sentence(:connector => nil)
+ assert_equal "one, two, three", ['one', 'two', 'three'].to_sentence(:connector => ' ')
+ assert_equal "one, two, and three", ['one', 'two', 'three'].to_sentence(:connector => 'and ')
+ end
+
+ def test_to_sentence_with_skip_last_comma
+ assert_equal "one, two, and three", ['one', 'two', 'three'].to_sentence(:skip_last_comma => false)
+ end
+
+ def test_two_elements
+ assert_equal "one and two", ['one', 'two'].to_sentence
+ assert_equal "one two", ['one', 'two'].to_sentence(:connector => '')
+ end
+
+ def test_one_element
+ assert_equal "one", ['one'].to_sentence
+ end
+
+ def test_one_non_string_element
+ assert_equal '1', [1].to_sentence
+ end
+end
+
+class ArrayExtToSTests < Test::Unit::TestCase
+ def test_to_s_db
+ collection = [
+ Class.new { def id() 1 end }.new,
+ Class.new { def id() 2 end }.new,
+ Class.new { def id() 3 end }.new
+ ]
+
+ assert_equal "null", [].to_s(:db)
+ assert_equal "1,2,3", collection.to_s(:db)
+ end
+end
+
+class ArrayExtGroupingTests < Test::Unit::TestCase
+ def test_group_by_with_perfect_fit
+ groups = []
+ ('a'..'i').to_a.in_groups_of(3) do |group|
+ groups << group
+ end
+
+ assert_equal [%w(a b c), %w(d e f), %w(g h i)], groups
+ assert_equal [%w(a b c), %w(d e f), %w(g h i)], ('a'..'i').to_a.in_groups_of(3)
+ end
+
+ def test_group_by_with_padding
+ groups = []
+ ('a'..'g').to_a.in_groups_of(3) do |group|
+ groups << group
+ end
+
+ assert_equal [%w(a b c), %w(d e f), ['g', nil, nil]], groups
+ end
+
+ def test_group_by_pads_with_specified_values
+ groups = []
+
+ ('a'..'g').to_a.in_groups_of(3, 'foo') do |group|
+ groups << group
+ end
+
+ assert_equal [%w(a b c), %w(d e f), ['g', 'foo', 'foo']], groups
+ end
+
+ def test_group_without_padding
+ groups = []
+
+ ('a'..'g').to_a.in_groups_of(3, false) do |group|
+ groups << group
+ end
+
+ assert_equal [%w(a b c), %w(d e f), ['g']], groups
+ end
+end
+
+class ArraySplitTests < Test::Unit::TestCase
+ def test_split_with_empty_array
+ assert_equal [[]], [].split(0)
+ end
+
+ def test_split_with_argument
+ assert_equal [[1, 2], [4, 5]], [1, 2, 3, 4, 5].split(3)
+ assert_equal [[1, 2, 3, 4, 5]], [1, 2, 3, 4, 5].split(0)
+ end
+
+ def test_split_with_block
+ assert_equal [[1, 2], [4, 5], [7, 8], [10]], (1..10).to_a.split { |i| i % 3 == 0 }
+ end
+
+ def test_split_with_edge_values
+ assert_equal [[], [2, 3, 4, 5]], [1, 2, 3, 4, 5].split(1)
+ assert_equal [[1, 2, 3, 4], []], [1, 2, 3, 4, 5].split(5)
+ assert_equal [[], [2, 3, 4], []], [1, 2, 3, 4, 5].split { |i| i == 1 || i == 5 }
+ end
+end
+
+class ArrayToXmlTests < Test::Unit::TestCase
+ def test_to_xml
+ xml = [
+ { :name => "David", :age => 26, :age_in_millis => 820497600000 },
+ { :name => "Jason", :age => 31, :age_in_millis => BigDecimal.new('1.0') }
+ ].to_xml(:skip_instruct => true, :indent => 0)
+
+ assert_equal '<records type="array"><record>', xml.first(30)
+ assert xml.include?(%(<age type="integer">26</age>)), xml
+ assert xml.include?(%(<age-in-millis type="integer">820497600000</age-in-millis>)), xml
+ assert xml.include?(%(<name>David</name>)), xml
+ assert xml.include?(%(<age type="integer">31</age>)), xml
+ assert xml.include?(%(<age-in-millis type="decimal">1.0</age-in-millis>)), xml
+ assert xml.include?(%(<name>Jason</name>)), xml
+ end
+
+ def test_to_xml_with_dedicated_name
+ xml = [
+ { :name => "David", :age => 26, :age_in_millis => 820497600000 }, { :name => "Jason", :age => 31 }
+ ].to_xml(:skip_instruct => true, :indent => 0, :root => "people")
+
+ assert_equal '<people type="array"><person>', xml.first(29)
+ end
+
+ def test_to_xml_with_options
+ xml = [
+ { :name => "David", :street_address => "Paulina" }, { :name => "Jason", :street_address => "Evergreen" }
+ ].to_xml(:skip_instruct => true, :skip_types => true, :indent => 0)
+
+ assert_equal "<records><record>", xml.first(17)
+ assert xml.include?(%(<street-address>Paulina</street-address>))
+ assert xml.include?(%(<name>David</name>))
+ assert xml.include?(%(<street-address>Evergreen</street-address>))
+ assert xml.include?(%(<name>Jason</name>))
+ end
+
+ def test_to_xml_with_dasherize_false
+ xml = [
+ { :name => "David", :street_address => "Paulina" }, { :name => "Jason", :street_address => "Evergreen" }
+ ].to_xml(:skip_instruct => true, :skip_types => true, :indent => 0, :dasherize => false)
+
+ assert_equal "<records><record>", xml.first(17)
+ assert xml.include?(%(<street_address>Paulina</street_address>))
+ assert xml.include?(%(<street_address>Evergreen</street_address>))
+ end
+
+ def test_to_xml_with_dasherize_true
+ xml = [
+ { :name => "David", :street_address => "Paulina" }, { :name => "Jason", :street_address => "Evergreen" }
+ ].to_xml(:skip_instruct => true, :skip_types => true, :indent => 0, :dasherize => true)
+
+ assert_equal "<records><record>", xml.first(17)
+ assert xml.include?(%(<street-address>Paulina</street-address>))
+ assert xml.include?(%(<street-address>Evergreen</street-address>))
+ end
+
+ def test_to_with_instruct
+ xml = [
+ { :name => "David", :age => 26, :age_in_millis => 820497600000 },
+ { :name => "Jason", :age => 31, :age_in_millis => BigDecimal.new('1.0') }
+ ].to_xml(:skip_instruct => false, :indent => 0)
+
+ assert_match(/^<\?xml [^>]*/, xml)
+ assert_equal 0, xml.rindex(/<\?xml /)
+ end
+
+ def test_to_xml_with_block
+ xml = [
+ { :name => "David", :age => 26, :age_in_millis => 820497600000 },
+ { :name => "Jason", :age => 31, :age_in_millis => BigDecimal.new('1.0') }
+ ].to_xml(:skip_instruct => true, :indent => 0) do |builder|
+ builder.count 2
+ end
+
+ assert xml.include?(%(<count>2</count>)), xml
+ end
+end
+
+class ArrayExtractOptionsTests < Test::Unit::TestCase
+ def test_extract_options
+ assert_equal({}, [].extract_options!)
+ assert_equal({}, [1].extract_options!)
+ assert_equal({:a=>:b}, [{:a=>:b}].extract_options!)
+ assert_equal({:a=>:b}, [1, {:a=>:b}].extract_options!)
+ end
+end
+
+uses_mocha "ArrayExtRandomTests" do
+
+class ArrayExtRandomTests < Test::Unit::TestCase
+ def test_random_element_from_array
+ assert_nil [].rand
+
+ Kernel.expects(:rand).with(1).returns(0)
+ assert_equal 'x', ['x'].rand
+
+ Kernel.expects(:rand).with(3).returns(1)
+ assert_equal 2, [1, 2, 3].rand
+ end
+end
+
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/blank_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/blank_test.rb
new file mode 100644
index 000000000..27b9813ac
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/blank_test.rb
@@ -0,0 +1,19 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+class EmptyTrue
+ def empty?() true; end
+end
+
+class EmptyFalse
+ def empty?() false; end
+end
+
+class BlankTest < Test::Unit::TestCase
+ BLANK = [ EmptyTrue.new, nil, false, '', ' ', " \n\t \r ", [], {} ]
+ NOT = [ EmptyFalse.new, Object.new, true, 0, 1, 'a', [nil], { nil => 0 } ]
+
+ def test_blank
+ BLANK.each { |v| assert v.blank?, "#{v.inspect} should be blank" }
+ NOT.each { |v| assert !v.blank?, "#{v.inspect} should not be blank" }
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/cgi_ext_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/cgi_ext_test.rb
new file mode 100644
index 000000000..229715c28
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/cgi_ext_test.rb
@@ -0,0 +1,14 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+class EscapeSkippingSlashesTest < Test::Unit::TestCase
+ def test_array
+ assert_equal 'hello/world', CGI.escape_skipping_slashes(%w(hello world))
+ assert_equal 'hello+world/how/are/you', CGI.escape_skipping_slashes(['hello world', 'how', 'are', 'you'])
+ end
+
+ def test_typical
+ assert_equal 'hi', CGI.escape_skipping_slashes('hi')
+ assert_equal 'hi/world', CGI.escape_skipping_slashes('hi/world')
+ assert_equal 'hi/world+you+funky+thing', CGI.escape_skipping_slashes('hi/world you funky thing')
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/class/attribute_accessor_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/class/attribute_accessor_test.rb
new file mode 100644
index 000000000..8104c9ce8
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/class/attribute_accessor_test.rb
@@ -0,0 +1,31 @@
+require File.dirname(__FILE__) + '/../../abstract_unit'
+
+class ClassAttributeAccessorTest < Test::Unit::TestCase
+ def setup
+ @class = Class.new do
+ cattr_accessor :foo
+ cattr_accessor :bar, :instance_writer => false
+ end
+ @object = @class.new
+ end
+
+ def test_should_use_mattr_default
+ assert_nil @class.foo
+ assert_nil @object.foo
+ end
+
+ def test_should_set_mattr_value
+ @class.foo = :test
+ assert_equal :test, @object.foo
+
+ @object.foo = :test2
+ assert_equal :test2, @class.foo
+ end
+
+ def test_should_not_create_instance_writer
+ assert @class.respond_to?(:foo)
+ assert @class.respond_to?(:foo=)
+ assert @object.respond_to?(:bar)
+ assert !@object.respond_to?(:bar=)
+ end
+end \ No newline at end of file
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/class/class_inheritable_attributes_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/class/class_inheritable_attributes_test.rb
new file mode 100644
index 000000000..c0bb7acb3
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/class/class_inheritable_attributes_test.rb
@@ -0,0 +1,224 @@
+require File.dirname(__FILE__) + '/../../abstract_unit'
+
+class ClassInheritableAttributesTest < Test::Unit::TestCase
+ def setup
+ @klass = Class.new
+ end
+
+ def test_reader_declaration
+ assert_nothing_raised do
+ @klass.class_inheritable_reader :a
+ assert_respond_to @klass, :a
+ assert_respond_to @klass.new, :a
+ end
+ end
+
+ def test_writer_declaration
+ assert_nothing_raised do
+ @klass.class_inheritable_writer :a
+ assert_respond_to @klass, :a=
+ assert_respond_to @klass.new, :a=
+ end
+ end
+
+ def test_writer_declaration_without_instance_writer
+ assert_nothing_raised do
+ @klass.class_inheritable_writer :a, :instance_writer => false
+ assert_respond_to @klass, :a=
+ assert !@klass.new.respond_to?(:a=)
+ end
+ end
+
+ def test_accessor_declaration
+ assert_nothing_raised do
+ @klass.class_inheritable_accessor :a
+ assert_respond_to @klass, :a
+ assert_respond_to @klass.new, :a
+ assert_respond_to @klass, :a=
+ assert_respond_to @klass.new, :a=
+ end
+ end
+
+ def test_accessor_declaration_without_instance_writer
+ assert_nothing_raised do
+ @klass.class_inheritable_accessor :a, :instance_writer => false
+ assert_respond_to @klass, :a
+ assert_respond_to @klass.new, :a
+ assert_respond_to @klass, :a=
+ assert !@klass.new.respond_to?(:a=)
+ end
+ end
+
+ def test_array_declaration
+ assert_nothing_raised do
+ @klass.class_inheritable_array :a
+ assert_respond_to @klass, :a
+ assert_respond_to @klass.new, :a
+ assert_respond_to @klass, :a=
+ assert_respond_to @klass.new, :a=
+ end
+ end
+
+ def test_array_declaration_without_instance_writer
+ assert_nothing_raised do
+ @klass.class_inheritable_array :a, :instance_writer => false
+ assert_respond_to @klass, :a
+ assert_respond_to @klass.new, :a
+ assert_respond_to @klass, :a=
+ assert !@klass.new.respond_to?(:a=)
+ end
+ end
+
+ def test_hash_declaration
+ assert_nothing_raised do
+ @klass.class_inheritable_hash :a
+ assert_respond_to @klass, :a
+ assert_respond_to @klass.new, :a
+ assert_respond_to @klass, :a=
+ assert_respond_to @klass.new, :a=
+ end
+ end
+
+ def test_hash_declaration_without_instance_writer
+ assert_nothing_raised do
+ @klass.class_inheritable_hash :a, :instance_writer => false
+ assert_respond_to @klass, :a
+ assert_respond_to @klass.new, :a
+ assert_respond_to @klass, :a=
+ assert !@klass.new.respond_to?(:a=)
+ end
+ end
+
+ def test_reader
+ @klass.class_inheritable_reader :a
+ assert_nil @klass.a
+ assert_nil @klass.new.a
+
+ @klass.send(:write_inheritable_attribute, :a, 'a')
+
+ assert_equal 'a', @klass.a
+ assert_equal 'a', @klass.new.a
+ assert_equal @klass.a, @klass.new.a
+ assert_equal @klass.a.object_id, @klass.new.a.object_id
+ end
+
+ def test_writer
+ @klass.class_inheritable_reader :a
+ @klass.class_inheritable_writer :a
+
+ assert_nil @klass.a
+ assert_nil @klass.new.a
+
+ @klass.a = 'a'
+ assert_equal 'a', @klass.a
+ @klass.new.a = 'A'
+ assert_equal 'A', @klass.a
+ end
+
+ def test_array
+ @klass.class_inheritable_array :a
+
+ assert_nil @klass.a
+ assert_nil @klass.new.a
+
+ @klass.a = %w(a b c)
+ assert_equal %w(a b c), @klass.a
+ assert_equal %w(a b c), @klass.new.a
+
+ @klass.new.a = %w(A B C)
+ assert_equal %w(a b c A B C), @klass.a
+ assert_equal %w(a b c A B C), @klass.new.a
+ end
+
+ def test_hash
+ @klass.class_inheritable_hash :a
+
+ assert_nil @klass.a
+ assert_nil @klass.new.a
+
+ @klass.a = { :a => 'a' }
+ assert_equal({ :a => 'a' }, @klass.a)
+ assert_equal({ :a => 'a' }, @klass.new.a)
+
+ @klass.new.a = { :b => 'b' }
+ assert_equal({ :a => 'a', :b => 'b' }, @klass.a)
+ assert_equal({ :a => 'a', :b => 'b' }, @klass.new.a)
+ end
+
+ def test_inheritance
+ @klass.class_inheritable_accessor :a
+ @klass.a = 'a'
+
+ @sub = eval("class FlogMe < @klass; end; FlogMe")
+
+ @klass.class_inheritable_accessor :b
+
+ assert_respond_to @sub, :a
+ assert_respond_to @sub, :b
+ assert_equal @klass.a, @sub.a
+ assert_equal @klass.b, @sub.b
+ assert_equal 'a', @sub.a
+ assert_nil @sub.b
+
+ @klass.b = 'b'
+ assert_not_equal @klass.b, @sub.b
+ assert_equal 'b', @klass.b
+ assert_nil @sub.b
+
+ @sub.a = 'A'
+ assert_not_equal @klass.a, @sub.a
+ assert_equal 'a', @klass.a
+ assert_equal 'A', @sub.a
+
+ @sub.b = 'B'
+ assert_not_equal @klass.b, @sub.b
+ assert_equal 'b', @klass.b
+ assert_equal 'B', @sub.b
+ end
+
+ def test_array_inheritance
+ @klass.class_inheritable_accessor :a
+ @klass.a = []
+
+ @sub = eval("class SubbyArray < @klass; end; SubbyArray")
+
+ assert_equal [], @klass.a
+ assert_equal [], @sub.a
+
+ @sub.a << :first
+
+ assert_equal [:first], @sub.a
+ assert_equal [], @klass.a
+ end
+
+ def test_array_inheritance_
+ @klass.class_inheritable_accessor :a
+ @klass.a = {}
+
+ @sub = eval("class SubbyHash < @klass; end; SubbyHash")
+
+ assert_equal Hash.new, @klass.a
+ assert_equal Hash.new, @sub.a
+
+ @sub.a[:first] = :first
+
+ assert_equal 1, @sub.a.keys.size
+ assert_equal 0, @klass.a.keys.size
+ end
+
+ def test_reset_inheritable_attributes
+ @klass.class_inheritable_accessor :a
+ @klass.a = 'a'
+
+ @sub = eval("class Inheriting < @klass; end; Inheriting")
+
+ assert_equal 'a', @klass.a
+ assert_equal 'a', @sub.a
+
+ @klass.reset_inheritable_attributes
+ @sub = eval("class NotInheriting < @klass; end; NotInheriting")
+
+ assert_equal nil, @klass.a
+ assert_equal nil, @sub.a
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/class/delegating_attributes_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/class/delegating_attributes_test.rb
new file mode 100644
index 000000000..f5b14364c
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/class/delegating_attributes_test.rb
@@ -0,0 +1,105 @@
+require File.dirname(__FILE__) + '/../../abstract_unit'
+
+module DelegatingFixtures
+ class Parent
+ end
+
+ class Child < Parent
+ superclass_delegating_accessor :some_attribute
+ end
+
+ class Mokopuna < Child
+ end
+end
+
+class DelegatingAttributesTest < Test::Unit::TestCase
+ include DelegatingFixtures
+ attr_reader :single_class
+
+ def setup
+ @single_class = Class.new(Object)
+ end
+
+ def test_simple_reader_declaration
+ single_class.superclass_delegating_reader :only_reader
+ # The class and instance should have an accessor, but there
+ # should be no mutator
+ assert single_class.respond_to?(:only_reader)
+ assert single_class.public_instance_methods.map(&:to_s).include?("only_reader")
+ assert !single_class.respond_to?(:only_reader=)
+ end
+
+ def test_simple_writer_declaration
+ single_class.superclass_delegating_writer :only_writer
+ # The class should have a mutator, the instances shouldn't
+ # neither should have an accessor
+ assert single_class.respond_to?(:only_writer=)
+ assert !single_class.public_instance_methods.include?("only_writer=")
+ assert !single_class.public_instance_methods.include?("only_writer")
+ assert !single_class.respond_to?(:only_writer)
+ end
+
+ def test_simple_accessor_declaration
+ single_class.superclass_delegating_accessor :both
+ # Class should have accessor and mutator
+ # the instance should have an accessor only
+ assert single_class.respond_to?(:both)
+ assert single_class.respond_to?(:both=)
+ assert single_class.public_instance_methods.map(&:to_s).include?("both")
+ assert !single_class.public_instance_methods.map(&:to_s).include?("both=")
+ end
+
+ def test_working_with_simple_attributes
+ single_class.superclass_delegating_accessor :both
+ single_class.both= "HMMM"
+ assert_equal "HMMM", single_class.both
+ assert_equal "HMMM", single_class.new.both
+ end
+
+ def test_working_with_accessors
+ single_class.superclass_delegating_reader :only_reader
+ single_class.instance_variable_set("@only_reader", "reading only")
+ assert_equal "reading only", single_class.only_reader
+ assert_equal "reading only", single_class.new.only_reader
+ end
+
+ def test_working_with_simple_mutators
+ single_class.superclass_delegating_writer :only_writer
+ single_class.only_writer="written"
+ assert_equal "written", single_class.instance_variable_get("@only_writer")
+ end
+
+ def test_child_class_delegates_to_parent_but_can_be_overridden
+ parent = Class.new
+ parent.superclass_delegating_accessor :both
+ child = Class.new(parent)
+ parent.both= "1"
+ assert_equal "1", child.both
+
+ child.both="2"
+ assert_equal "1", parent.both
+ assert_equal "2", child.both
+
+ parent.both="3"
+ assert_equal "3", parent.both
+ assert_equal "2", child.both
+ end
+
+ def test_delegation_stops_at_the_right_level
+ assert_nil Mokopuna.some_attribute
+ assert_nil Child.some_attribute
+ Child.some_attribute="1"
+ assert_equal "1", Mokopuna.some_attribute
+ ensure
+ Child.some_attribute=nil
+ end
+
+ def test_delegation_stops_for_nil
+ Mokopuna.some_attribute = nil
+ Child.some_attribute="1"
+
+ assert_equal "1", Child.some_attribute
+ assert_nil Mokopuna.some_attribute
+ end
+
+end \ No newline at end of file
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/class_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/class_test.rb
new file mode 100644
index 000000000..e1b38a1e0
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/class_test.rb
@@ -0,0 +1,46 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+class A
+end
+
+module X
+ class B
+ end
+end
+
+module Y
+ module Z
+ class C
+ end
+ end
+end
+
+class ClassTest < Test::Unit::TestCase
+ def test_removing_class_in_root_namespace
+ assert A.is_a?(Class)
+ Class.remove_class(A)
+ assert_raises(NameError) { A.is_a?(Class) }
+ end
+
+ def test_removing_class_in_one_level_namespace
+ assert X::B.is_a?(Class)
+ Class.remove_class(X::B)
+ assert_raises(NameError) { X::B.is_a?(Class) }
+ end
+
+ def test_removing_class_in_two_level_namespace
+ assert Y::Z::C.is_a?(Class)
+ Class.remove_class(Y::Z::C)
+ assert_raises(NameError) { Y::Z::C.is_a?(Class) }
+ end
+
+ def test_retrieving_subclasses
+ @parent = eval("class D; end; D")
+ @sub = eval("class E < D; end; E")
+ @subofsub = eval("class F < E; end; F")
+ assert @parent.subclasses.all? { |i| [@sub.to_s, @subofsub.to_s].include?(i) }
+ assert_equal 2, @parent.subclasses.size
+ assert_equal [@subofsub.to_s], @sub.subclasses
+ assert_equal [], @subofsub.subclasses
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/date_ext_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/date_ext_test.rb
new file mode 100644
index 000000000..0023d48c1
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/date_ext_test.rb
@@ -0,0 +1,196 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+class DateExtCalculationsTest < Test::Unit::TestCase
+ def test_to_s
+ date = Date.new(2005, 2, 21)
+ assert_equal "2005-02-21", date.to_s
+ assert_equal "21 Feb", date.to_s(:short)
+ assert_equal "February 21, 2005", date.to_s(:long)
+ assert_equal "February 21st, 2005", date.to_s(:long_ordinal)
+ assert_equal "2005-02-21", date.to_s(:db)
+ assert_equal "21 Feb 2005", date.to_s(:rfc822)
+ end
+
+ def test_readable_inspect
+ assert_equal "Mon, 21 Feb 2005", Date.new(2005, 2, 21).readable_inspect
+ assert_equal Date.new(2005, 2, 21).readable_inspect, Date.new(2005, 2, 21).inspect
+ end
+
+ def test_to_time
+ assert_equal Time.local(2005, 2, 21), Date.new(2005, 2, 21).to_time
+ assert_equal Time.local_time(2039, 2, 21), Date.new(2039, 2, 21).to_time
+ end
+
+ def test_to_datetime
+ assert_equal DateTime.civil(2005, 2, 21), Date.new(2005, 2, 21).to_datetime
+ assert_equal 0, Date.new(2005, 2, 21).to_datetime.offset # use UTC offset
+ assert_equal ::Date::ITALY, Date.new(2005, 2, 21).to_datetime.start # use Ruby's default start value
+ end
+
+ def test_to_date
+ assert_equal Date.new(2005, 2, 21), Date.new(2005, 2, 21).to_date
+ end
+
+ def test_change
+ assert_equal Date.new(2005, 2, 21), Date.new(2005, 2, 11).change(:day => 21)
+ assert_equal Date.new(2007, 5, 11), Date.new(2005, 2, 11).change(:year => 2007, :month => 5)
+ assert_equal Date.new(2006,2,22), Date.new(2005,2,22).change(:year => 2006)
+ assert_equal Date.new(2005,6,22), Date.new(2005,2,22).change(:month => 6)
+ end
+
+ def test_beginning_of_week
+ assert_equal Date.new(2005,1,31), Date.new(2005,2,4).beginning_of_week
+ assert_equal Date.new(2005,11,28), Date.new(2005,11,28).beginning_of_week #monday
+ assert_equal Date.new(2005,11,28), Date.new(2005,11,29).beginning_of_week #tuesday
+ assert_equal Date.new(2005,11,28), Date.new(2005,11,30).beginning_of_week #wednesday
+ assert_equal Date.new(2005,11,28), Date.new(2005,12,01).beginning_of_week #thursday
+ assert_equal Date.new(2005,11,28), Date.new(2005,12,02).beginning_of_week #friday
+ assert_equal Date.new(2005,11,28), Date.new(2005,12,03).beginning_of_week #saturday
+ assert_equal Date.new(2005,11,28), Date.new(2005,12,04).beginning_of_week #sunday
+ end
+
+ def test_beginning_of_month
+ assert_equal Date.new(2005,2,1), Date.new(2005,2,22).beginning_of_month
+ end
+
+ def test_beginning_of_quarter
+ assert_equal Date.new(2005,1,1), Date.new(2005,2,15).beginning_of_quarter
+ assert_equal Date.new(2005,1,1), Date.new(2005,1,1).beginning_of_quarter
+ assert_equal Date.new(2005,10,1), Date.new(2005,12,31).beginning_of_quarter
+ assert_equal Date.new(2005,4,1), Date.new(2005,6,30).beginning_of_quarter
+ end
+
+ def test_end_of_month
+ assert_equal Date.new(2005,3,31), Date.new(2005,3,20).end_of_month
+ assert_equal Date.new(2005,2,28), Date.new(2005,2,20).end_of_month
+ assert_equal Date.new(2005,4,30), Date.new(2005,4,20).end_of_month
+
+ end
+
+ def test_beginning_of_year
+ assert_equal Date.new(2005,1,1).to_s, Date.new(2005,2,22).beginning_of_year.to_s
+ end
+
+ def test_months_ago
+ assert_equal Date.new(2005,5,5), Date.new(2005,6,5).months_ago(1)
+ assert_equal Date.new(2004,11,5), Date.new(2005,6,5).months_ago(7)
+ assert_equal Date.new(2004,12,5), Date.new(2005,6,5).months_ago(6)
+ assert_equal Date.new(2004,6,5), Date.new(2005,6,5).months_ago(12)
+ assert_equal Date.new(2003,6,5), Date.new(2005,6,5).months_ago(24)
+ end
+
+ def test_months_since
+ assert_equal Date.new(2005,7,5), Date.new(2005,6,5).months_since(1)
+ assert_equal Date.new(2006,1,5), Date.new(2005,12,5).months_since(1)
+ assert_equal Date.new(2005,12,5), Date.new(2005,6,5).months_since(6)
+ assert_equal Date.new(2006,6,5), Date.new(2005,12,5).months_since(6)
+ assert_equal Date.new(2006,1,5), Date.new(2005,6,5).months_since(7)
+ assert_equal Date.new(2006,6,5), Date.new(2005,6,5).months_since(12)
+ assert_equal Date.new(2007,6,5), Date.new(2005,6,5).months_since(24)
+ assert_equal Date.new(2005,4,30), Date.new(2005,3,31).months_since(1)
+ assert_equal Date.new(2005,2,28), Date.new(2005,1,29).months_since(1)
+ assert_equal Date.new(2005,2,28), Date.new(2005,1,30).months_since(1)
+ assert_equal Date.new(2005,2,28), Date.new(2005,1,31).months_since(1)
+ end
+
+ def test_years_ago
+ assert_equal Date.new(2004,6,5), Date.new(2005,6,5).years_ago(1)
+ assert_equal Date.new(1998,6,5), Date.new(2005,6,5).years_ago(7)
+ assert_equal Date.new(2003,2,28), Date.new(2004,2,29).years_ago(1) # 1 year ago from leap day
+ end
+
+ def test_years_since
+ assert_equal Date.new(2006,6,5), Date.new(2005,6,5).years_since(1)
+ assert_equal Date.new(2012,6,5), Date.new(2005,6,5).years_since(7)
+ assert_equal Date.new(2182,6,5), Date.new(2005,6,5).years_since(177)
+ assert_equal Date.new(2005,2,28), Date.new(2004,2,29).years_since(1) # 1 year since leap day
+ end
+
+ def test_last_year
+ assert_equal Date.new(2004,6,5), Date.new(2005,6,5).last_year
+ end
+
+ def test_next_year
+ assert_equal Date.new(2006,6,5), Date.new(2005,6,5).next_year
+ end
+
+ def test_yesterday
+ assert_equal Date.new(2005,2,21), Date.new(2005,2,22).yesterday
+ assert_equal Date.new(2005,2,28), Date.new(2005,3,2).yesterday.yesterday
+ end
+
+ def test_tomorrow
+ assert_equal Date.new(2005,2,23), Date.new(2005,2,22).tomorrow
+ assert_equal Date.new(2005,3,2), Date.new(2005,2,28).tomorrow.tomorrow
+ end
+
+ def test_advance
+ assert_equal Date.new(2006,2,28), Date.new(2005,2,28).advance(:years => 1)
+ assert_equal Date.new(2005,6,28), Date.new(2005,2,28).advance(:months => 4)
+ assert_equal Date.new(2005,3,21), Date.new(2005,2,28).advance(:weeks => 3)
+ assert_equal Date.new(2005,3,5), Date.new(2005,2,28).advance(:days => 5)
+ assert_equal Date.new(2012,9,28), Date.new(2005,2,28).advance(:years => 7, :months => 7)
+ assert_equal Date.new(2013,10,3), Date.new(2005,2,28).advance(:years => 7, :months => 19, :days => 5)
+ assert_equal Date.new(2013,10,17), Date.new(2005,2,28).advance(:years => 7, :months => 19, :weeks => 2, :days => 5)
+ assert_equal Date.new(2005,2,28), Date.new(2004,2,29).advance(:years => 1) #leap day plus one year
+ end
+
+ def test_next_week
+ assert_equal Date.new(2005,2,28), Date.new(2005,2,22).next_week
+ assert_equal Date.new(2005,3,4), Date.new(2005,2,22).next_week(:friday)
+ assert_equal Date.new(2006,10,30), Date.new(2006,10,23).next_week
+ assert_equal Date.new(2006,11,1), Date.new(2006,10,23).next_week(:wednesday)
+ end
+
+ def test_next_month_on_31st
+ assert_equal Date.new(2005, 9, 30), Date.new(2005, 8, 31).next_month
+ end
+
+ def test_last_month_on_31st
+ assert_equal Date.new(2004, 2, 29), Date.new(2004, 3, 31).last_month
+ end
+
+ def test_yesterday_constructor
+ assert_equal Date.today - 1, Date.yesterday
+ end
+
+ def test_tomorrow_constructor
+ assert_equal Date.today + 1, Date.tomorrow
+ end
+
+ def test_since
+ assert_equal Time.local(2005,2,21,0,0,45), Date.new(2005,2,21).since(45)
+ end
+
+ def test_ago
+ assert_equal Time.local(2005,2,20,23,59,15), Date.new(2005,2,21).ago(45)
+ end
+
+ def test_beginning_of_day
+ assert_equal Time.local(2005,2,21,0,0,0), Date.new(2005,2,21).beginning_of_day
+ end
+
+ def test_end_of_day
+ assert_equal Time.local(2005,2,21,23,59,59), Date.new(2005,2,21).end_of_day
+ end
+
+ def test_xmlschema
+ with_timezone 'US/Eastern' do
+ assert_match(/^1980-02-28T00:00:00-05:?00$/, Date.new(1980, 2, 28).xmlschema)
+ assert_match(/^1980-06-28T00:00:00-04:?00$/, Date.new(1980, 6, 28).xmlschema)
+ # these tests are only of interest on platforms where older dates #to_time fail over to DateTime
+ if ::DateTime === Date.new(1880, 6, 28).to_time
+ assert_match(/^1880-02-28T00:00:00-05:?00$/, Date.new(1880, 2, 28).xmlschema)
+ assert_match(/^1880-06-28T00:00:00-05:?00$/, Date.new(1880, 6, 28).xmlschema) # DateTimes aren't aware of DST rules
+ end
+ end
+ end
+
+ protected
+ def with_timezone(new_tz = 'US/Eastern')
+ old_tz, ENV['TZ'] = ENV['TZ'], new_tz
+ yield
+ ensure
+ old_tz ? ENV['TZ'] = old_tz : ENV.delete('TZ')
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/date_time_ext_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/date_time_ext_test.rb
new file mode 100644
index 000000000..57697871f
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/date_time_ext_test.rb
@@ -0,0 +1,230 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+class DateTimeExtCalculationsTest < Test::Unit::TestCase
+ def test_to_s
+ datetime = DateTime.new(2005, 2, 21, 14, 30, 0, 0)
+ assert_match(/^2005-02-21T14:30:00(Z|\+00:00)$/, datetime.to_s)
+ assert_equal "2005-02-21 14:30:00", datetime.to_s(:db)
+ assert_equal "14:30", datetime.to_s(:time)
+ assert_equal "21 Feb 14:30", datetime.to_s(:short)
+ assert_equal "February 21, 2005 14:30", datetime.to_s(:long)
+ assert_equal "Mon, 21 Feb 2005 14:30:00 +0000", datetime.to_s(:rfc822)
+ assert_equal "February 21st, 2005 14:30", datetime.to_s(:long_ordinal)
+ end
+
+ def test_readable_inspect
+ datetime = DateTime.new(2005, 2, 21, 14, 30, 0)
+ assert_equal "Mon, 21 Feb 2005 14:30:00 +0000", datetime.readable_inspect
+ assert_equal datetime.readable_inspect, datetime.inspect
+ end
+
+ def test_custom_date_format
+ Time::DATE_FORMATS[:custom] = '%Y%m%d%H%M%S'
+ assert_equal '20050221143000', DateTime.new(2005, 2, 21, 14, 30, 0).to_s(:custom)
+ Time::DATE_FORMATS.delete(:custom)
+ end
+
+ def test_to_date
+ assert_equal Date.new(2005, 2, 21), DateTime.new(2005, 2, 21).to_date
+ end
+
+ def test_to_datetime
+ assert_equal DateTime.new(2005, 2, 21), DateTime.new(2005, 2, 21).to_datetime
+ end
+
+ def test_to_time
+ assert_equal Time.utc(2005, 2, 21, 10, 11, 12), DateTime.new(2005, 2, 21, 10, 11, 12, 0, 0).to_time
+ assert_equal Time.utc_time(2039, 2, 21, 10, 11, 12), DateTime.new(2039, 2, 21, 10, 11, 12, 0, 0).to_time
+ # DateTimes with offsets other than 0 are returned unaltered
+ assert_equal DateTime.new(2005, 2, 21, 10, 11, 12, Rational(-5, 24)), DateTime.new(2005, 2, 21, 10, 11, 12, Rational(-5, 24)).to_time
+ end
+
+ def test_seconds_since_midnight
+ assert_equal 1,DateTime.civil(2005,1,1,0,0,1).seconds_since_midnight
+ assert_equal 60,DateTime.civil(2005,1,1,0,1,0).seconds_since_midnight
+ assert_equal 3660,DateTime.civil(2005,1,1,1,1,0).seconds_since_midnight
+ assert_equal 86399,DateTime.civil(2005,1,1,23,59,59).seconds_since_midnight
+ end
+
+ def test_beginning_of_week
+ assert_equal DateTime.civil(2005,1,31), DateTime.civil(2005,2,4,10,10,10).beginning_of_week
+ assert_equal DateTime.civil(2005,11,28), DateTime.civil(2005,11,28,0,0,0).beginning_of_week #monday
+ assert_equal DateTime.civil(2005,11,28), DateTime.civil(2005,11,29,0,0,0).beginning_of_week #tuesday
+ assert_equal DateTime.civil(2005,11,28), DateTime.civil(2005,11,30,0,0,0).beginning_of_week #wednesday
+ assert_equal DateTime.civil(2005,11,28), DateTime.civil(2005,12,01,0,0,0).beginning_of_week #thursday
+ assert_equal DateTime.civil(2005,11,28), DateTime.civil(2005,12,02,0,0,0).beginning_of_week #friday
+ assert_equal DateTime.civil(2005,11,28), DateTime.civil(2005,12,03,0,0,0).beginning_of_week #saturday
+ assert_equal DateTime.civil(2005,11,28), DateTime.civil(2005,12,04,0,0,0).beginning_of_week #sunday
+ end
+
+ def test_beginning_of_day
+ assert_equal DateTime.civil(2005,2,4,0,0,0), DateTime.civil(2005,2,4,10,10,10).beginning_of_day
+ end
+
+ def test_end_of_day
+ assert_equal DateTime.civil(2005,2,4,23,59,59), DateTime.civil(2005,2,4,10,10,10).end_of_day
+ end
+
+ def test_beginning_of_month
+ assert_equal DateTime.civil(2005,2,1,0,0,0), DateTime.civil(2005,2,22,10,10,10).beginning_of_month
+ end
+
+ def test_beginning_of_quarter
+ assert_equal DateTime.civil(2005,1,1,0,0,0), DateTime.civil(2005,2,15,10,10,10).beginning_of_quarter
+ assert_equal DateTime.civil(2005,1,1,0,0,0), DateTime.civil(2005,1,1,0,0,0).beginning_of_quarter
+ assert_equal DateTime.civil(2005,10,1,0,0,0), DateTime.civil(2005,12,31,10,10,10).beginning_of_quarter
+ assert_equal DateTime.civil(2005,4,1,0,0,0), DateTime.civil(2005,6,30,23,59,59).beginning_of_quarter
+ end
+
+ def test_end_of_month
+ assert_equal DateTime.civil(2005,3,31,23,59,59), DateTime.civil(2005,3,20,10,10,10).end_of_month
+ assert_equal DateTime.civil(2005,2,28,23,59,59), DateTime.civil(2005,2,20,10,10,10).end_of_month
+ assert_equal DateTime.civil(2005,4,30,23,59,59), DateTime.civil(2005,4,20,10,10,10).end_of_month
+ end
+
+ def test_beginning_of_year
+ assert_equal DateTime.civil(2005,1,1,0,0,0), DateTime.civil(2005,2,22,10,10,10).beginning_of_year
+ end
+
+ def test_months_ago
+ assert_equal DateTime.civil(2005,5,5,10), DateTime.civil(2005,6,5,10,0,0).months_ago(1)
+ assert_equal DateTime.civil(2004,11,5,10), DateTime.civil(2005,6,5,10,0,0).months_ago(7)
+ assert_equal DateTime.civil(2004,12,5,10), DateTime.civil(2005,6,5,10,0,0).months_ago(6)
+ assert_equal DateTime.civil(2004,6,5,10), DateTime.civil(2005,6,5,10,0,0).months_ago(12)
+ assert_equal DateTime.civil(2003,6,5,10), DateTime.civil(2005,6,5,10,0,0).months_ago(24)
+ end
+
+ def test_months_since
+ assert_equal DateTime.civil(2005,7,5,10), DateTime.civil(2005,6,5,10,0,0).months_since(1)
+ assert_equal DateTime.civil(2006,1,5,10), DateTime.civil(2005,12,5,10,0,0).months_since(1)
+ assert_equal DateTime.civil(2005,12,5,10), DateTime.civil(2005,6,5,10,0,0).months_since(6)
+ assert_equal DateTime.civil(2006,6,5,10), DateTime.civil(2005,12,5,10,0,0).months_since(6)
+ assert_equal DateTime.civil(2006,1,5,10), DateTime.civil(2005,6,5,10,0,0).months_since(7)
+ assert_equal DateTime.civil(2006,6,5,10), DateTime.civil(2005,6,5,10,0,0).months_since(12)
+ assert_equal DateTime.civil(2007,6,5,10), DateTime.civil(2005,6,5,10,0,0).months_since(24)
+ assert_equal DateTime.civil(2005,4,30,10), DateTime.civil(2005,3,31,10,0,0).months_since(1)
+ assert_equal DateTime.civil(2005,2,28,10), DateTime.civil(2005,1,29,10,0,0).months_since(1)
+ assert_equal DateTime.civil(2005,2,28,10), DateTime.civil(2005,1,30,10,0,0).months_since(1)
+ assert_equal DateTime.civil(2005,2,28,10), DateTime.civil(2005,1,31,10,0,0).months_since(1)
+ end
+
+ def test_years_ago
+ assert_equal DateTime.civil(2004,6,5,10), DateTime.civil(2005,6,5,10,0,0).years_ago(1)
+ assert_equal DateTime.civil(1998,6,5,10), DateTime.civil(2005,6,5,10,0,0).years_ago(7)
+ assert_equal DateTime.civil(2003,2,28,10), DateTime.civil(2004,2,29,10,0,0).years_ago(1) # 1 year ago from leap day
+ end
+
+ def test_years_since
+ assert_equal DateTime.civil(2006,6,5,10), DateTime.civil(2005,6,5,10,0,0).years_since(1)
+ assert_equal DateTime.civil(2012,6,5,10), DateTime.civil(2005,6,5,10,0,0).years_since(7)
+ assert_equal DateTime.civil(2182,6,5,10), DateTime.civil(2005,6,5,10,0,0).years_since(177)
+ assert_equal DateTime.civil(2005,2,28,10), DateTime.civil(2004,2,29,10,0,0).years_since(1) # 1 year since leap day
+ end
+
+ def test_last_year
+ assert_equal DateTime.civil(2004,6,5,10), DateTime.civil(2005,6,5,10,0,0).last_year
+ end
+
+ def test_next_year
+ assert_equal DateTime.civil(2006,6,5,10), DateTime.civil(2005,6,5,10,0,0).next_year
+ end
+
+ def test_ago
+ assert_equal DateTime.civil(2005,2,22,10,10,9), DateTime.civil(2005,2,22,10,10,10).ago(1)
+ assert_equal DateTime.civil(2005,2,22,9,10,10), DateTime.civil(2005,2,22,10,10,10).ago(3600)
+ assert_equal DateTime.civil(2005,2,20,10,10,10), DateTime.civil(2005,2,22,10,10,10).ago(86400*2)
+ assert_equal DateTime.civil(2005,2,20,9,9,45), DateTime.civil(2005,2,22,10,10,10).ago(86400*2 + 3600 + 25)
+ end
+
+ def test_since
+ assert_equal DateTime.civil(2005,2,22,10,10,11), DateTime.civil(2005,2,22,10,10,10).since(1)
+ assert_equal DateTime.civil(2005,2,22,11,10,10), DateTime.civil(2005,2,22,10,10,10).since(3600)
+ assert_equal DateTime.civil(2005,2,24,10,10,10), DateTime.civil(2005,2,22,10,10,10).since(86400*2)
+ assert_equal DateTime.civil(2005,2,24,11,10,35), DateTime.civil(2005,2,22,10,10,10).since(86400*2 + 3600 + 25)
+ assert_equal DateTime.civil(2005,2,22,10,10,11), DateTime.civil(2005,2,22,10,10,10).since(1.333)
+ assert_equal DateTime.civil(2005,2,22,10,10,12), DateTime.civil(2005,2,22,10,10,10).since(1.667)
+ end
+
+ def test_yesterday
+ assert_equal DateTime.civil(2005,2,21,10,10,10), DateTime.civil(2005,2,22,10,10,10).yesterday
+ assert_equal DateTime.civil(2005,2,28,10,10,10), DateTime.civil(2005,3,2,10,10,10).yesterday.yesterday
+ end
+
+ def test_tomorrow
+ assert_equal DateTime.civil(2005,2,23,10,10,10), DateTime.civil(2005,2,22,10,10,10).tomorrow
+ assert_equal DateTime.civil(2005,3,2,10,10,10), DateTime.civil(2005,2,28,10,10,10).tomorrow.tomorrow
+ end
+
+ def test_change
+ assert_equal DateTime.civil(2006,2,22,15,15,10), DateTime.civil(2005,2,22,15,15,10).change(:year => 2006)
+ assert_equal DateTime.civil(2005,6,22,15,15,10), DateTime.civil(2005,2,22,15,15,10).change(:month => 6)
+ assert_equal DateTime.civil(2012,9,22,15,15,10), DateTime.civil(2005,2,22,15,15,10).change(:year => 2012, :month => 9)
+ assert_equal DateTime.civil(2005,2,22,16), DateTime.civil(2005,2,22,15,15,10).change(:hour => 16)
+ assert_equal DateTime.civil(2005,2,22,16,45), DateTime.civil(2005,2,22,15,15,10).change(:hour => 16, :min => 45)
+ assert_equal DateTime.civil(2005,2,22,15,45), DateTime.civil(2005,2,22,15,15,10).change(:min => 45)
+ end
+
+ def test_advance
+ assert_equal DateTime.civil(2006,2,28,15,15,10), DateTime.civil(2005,2,28,15,15,10).advance(:years => 1)
+ assert_equal DateTime.civil(2005,6,28,15,15,10), DateTime.civil(2005,2,28,15,15,10).advance(:months => 4)
+ assert_equal DateTime.civil(2005,3,21,15,15,10), DateTime.civil(2005,2,28,15,15,10).advance(:weeks => 3)
+ assert_equal DateTime.civil(2005,3,5,15,15,10), DateTime.civil(2005,2,28,15,15,10).advance(:days => 5)
+ assert_equal DateTime.civil(2012,9,28,15,15,10), DateTime.civil(2005,2,28,15,15,10).advance(:years => 7, :months => 7)
+ assert_equal DateTime.civil(2013,10,3,15,15,10), DateTime.civil(2005,2,28,15,15,10).advance(:years => 7, :months => 19, :days => 5)
+ assert_equal DateTime.civil(2013,10,17,15,15,10), DateTime.civil(2005,2,28,15,15,10).advance(:years => 7, :months => 19, :weeks => 2, :days => 5)
+ assert_equal DateTime.civil(2001,12,27,15,15,10), DateTime.civil(2005,2,28,15,15,10).advance(:years => -3, :months => -2, :days => -1)
+ assert_equal DateTime.civil(2005,2,28,15,15,10), DateTime.civil(2004,2,29,15,15,10).advance(:years => 1) #leap day plus one year
+ assert_equal DateTime.civil(2005,2,28,20,15,10), DateTime.civil(2005,2,28,15,15,10).advance(:hours => 5)
+ assert_equal DateTime.civil(2005,2,28,15,22,10), DateTime.civil(2005,2,28,15,15,10).advance(:minutes => 7)
+ assert_equal DateTime.civil(2005,2,28,15,15,19), DateTime.civil(2005,2,28,15,15,10).advance(:seconds => 9)
+ assert_equal DateTime.civil(2005,2,28,20,22,19), DateTime.civil(2005,2,28,15,15,10).advance(:hours => 5, :minutes => 7, :seconds => 9)
+ assert_equal DateTime.civil(2005,2,28,10,8,1), DateTime.civil(2005,2,28,15,15,10).advance(:hours => -5, :minutes => -7, :seconds => -9)
+ assert_equal DateTime.civil(2013,10,17,20,22,19), DateTime.civil(2005,2,28,15,15,10).advance(:years => 7, :months => 19, :weeks => 2, :days => 5, :hours => 5, :minutes => 7, :seconds => 9)
+
+ end
+
+ def test_next_week
+ assert_equal DateTime.civil(2005,2,28), DateTime.civil(2005,2,22,15,15,10).next_week
+ assert_equal DateTime.civil(2005,3,4), DateTime.civil(2005,2,22,15,15,10).next_week(:friday)
+ assert_equal DateTime.civil(2006,10,30), DateTime.civil(2006,10,23,0,0,0).next_week
+ assert_equal DateTime.civil(2006,11,1), DateTime.civil(2006,10,23,0,0,0).next_week(:wednesday)
+ end
+
+ def test_next_month_on_31st
+ assert_equal DateTime.civil(2005, 9, 30), DateTime.civil(2005, 8, 31).next_month
+ end
+
+ def test_last_month_on_31st
+ assert_equal DateTime.civil(2004, 2, 29), DateTime.civil(2004, 3, 31).last_month
+ end
+
+ def test_xmlschema
+ assert_match(/^1880-02-28T15:15:10\+00:?00$/, DateTime.civil(1880, 2, 28, 15, 15, 10).xmlschema)
+ assert_match(/^1980-02-28T15:15:10\+00:?00$/, DateTime.civil(1980, 2, 28, 15, 15, 10).xmlschema)
+ assert_match(/^2080-02-28T15:15:10\+00:?00$/, DateTime.civil(2080, 2, 28, 15, 15, 10).xmlschema)
+ assert_match(/^1880-02-28T15:15:10-06:?00$/, DateTime.civil(1880, 2, 28, 15, 15, 10, -0.25).xmlschema)
+ assert_match(/^1980-02-28T15:15:10-06:?00$/, DateTime.civil(1980, 2, 28, 15, 15, 10, -0.25).xmlschema)
+ assert_match(/^2080-02-28T15:15:10-06:?00$/, DateTime.civil(2080, 2, 28, 15, 15, 10, -0.25).xmlschema)
+ end
+
+ def test_acts_like_time
+ assert DateTime.new.acts_like_time?
+ end
+
+ def test_local_offset
+ with_timezone 'US/Eastern' do
+ assert_equal Rational(-5, 24), DateTime.local_offset
+ end
+ with_timezone 'US/Central' do
+ assert_equal Rational(-6, 24), DateTime.local_offset
+ end
+ end
+
+ protected
+ def with_timezone(new_tz = 'US/Eastern')
+ old_tz, ENV['TZ'] = ENV['TZ'], new_tz
+ yield
+ ensure
+ old_tz ? ENV['TZ'] = old_tz : ENV.delete('TZ')
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/duplicable_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/duplicable_test.rb
new file mode 100644
index 000000000..5e34184a4
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/duplicable_test.rb
@@ -0,0 +1,22 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+class DuplicableTest < Test::Unit::TestCase
+ NO = [nil, false, true, :symbol, 1, 2.3, BigDecimal.new('4.56')]
+ YES = ['1', Object.new, /foo/, [], {}, Time.now]
+
+ def test_duplicable
+ NO.each do |v|
+ assert !v.duplicable?
+ begin
+ v.dup
+ fail
+ rescue Exception
+ end
+ end
+
+ YES.each do |v|
+ assert v.duplicable?
+ assert_nothing_raised { v.dup }
+ end
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/duration_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/duration_test.rb
new file mode 100644
index 000000000..125232bd4
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/duration_test.rb
@@ -0,0 +1,21 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+class DurationTest < Test::Unit::TestCase
+ def test_inspect
+ assert_equal '1 month', 1.month.inspect
+ assert_equal '1 month and 1 day', (1.month + 1.day).inspect
+ assert_equal '6 months and -2 days', (6.months - 2.days).inspect
+ assert_equal '10 seconds', 10.seconds.inspect
+ assert_equal '10 years, 2 months, and 1 day', (10.years + 2.months + 1.day).inspect
+ assert_equal '7 days', 1.week.inspect
+ assert_equal '14 days', 1.fortnight.inspect
+ end
+
+ def test_minus_with_duration_does_not_break_subtraction_of_date_from_date
+ assert_nothing_raised { Date.today - Date.today }
+ end
+
+ def test_plus_with_time
+ assert_equal 1 + 1.second, 1.second + 1, "Duration + Numeric should == Numeric + Duration"
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/enumerable_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/enumerable_test.rb
new file mode 100644
index 000000000..af183dace
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/enumerable_test.rb
@@ -0,0 +1,61 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+Payment = Struct.new(:price)
+class SummablePayment < Payment
+ def +(p) self.class.new(price + p.price) end
+end
+
+class EnumerableTests < Test::Unit::TestCase
+ def test_group_by
+ names = %w(marcel sam david jeremy)
+ klass = Struct.new(:name)
+ objects = (1..50).inject([]) do |people,|
+ p = klass.new
+ p.name = names.sort_by { rand }.first
+ people << p
+ end
+
+ objects.group_by {|object| object.name}.each do |name, group|
+ assert group.all? {|person| person.name == name}
+ end
+ end
+
+ def test_sums
+ assert_equal 30, [5, 15, 10].sum
+ assert_equal 30, [5, 15, 10].sum { |i| i }
+
+ assert_equal 'abc', %w(a b c).sum
+ assert_equal 'abc', %w(a b c).sum { |i| i }
+
+ payments = [ Payment.new(5), Payment.new(15), Payment.new(10) ]
+ assert_equal 30, payments.sum(&:price)
+ assert_equal 60, payments.sum { |p| p.price * 2 }
+
+ payments = [ SummablePayment.new(5), SummablePayment.new(15) ]
+ assert_equal SummablePayment.new(20), payments.sum
+ assert_equal SummablePayment.new(20), payments.sum { |p| p }
+ end
+
+ def test_nil_sums
+ expected_raise = TypeError
+
+ assert_raise(expected_raise) { [5, 15, nil].sum }
+
+ payments = [ Payment.new(5), Payment.new(15), Payment.new(10), Payment.new(nil) ]
+ assert_raise(expected_raise) { payments.sum(&:price) }
+
+ assert_equal 60, payments.sum { |p| p.price.to_i * 2 }
+ end
+
+ def test_empty_sums
+ assert_equal 0, [].sum
+ assert_equal 0, [].sum { |i| i }
+ assert_equal Payment.new(0), [].sum(Payment.new(0))
+ end
+
+ def test_index_by
+ payments = [ Payment.new(5), Payment.new(15), Payment.new(10) ]
+ assert_equal({ 5 => payments[0], 15 => payments[1], 10 => payments[2] },
+ payments.index_by { |p| p.price })
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/exception_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/exception_test.rb
new file mode 100644
index 000000000..b1ea564a0
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/exception_test.rb
@@ -0,0 +1,64 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+class ExceptionExtTests < Test::Unit::TestCase
+
+ def get_exception(cls = RuntimeError, msg = nil, trace = nil)
+ begin raise cls, msg, (trace || caller)
+ rescue Exception => e # passed Exception
+ return e
+ end
+ end
+
+ def setup
+ Exception::TraceSubstitutions.clear
+ end
+
+ def test_clean_backtrace
+ Exception::TraceSubstitutions << [/\s*hidden.*/, '']
+ e = get_exception RuntimeError, 'RAWR', ['bhal.rb', 'rawh hid den stuff is not here', 'almost all']
+ assert_kind_of Exception, e
+ assert_equal ['bhal.rb', 'rawh hid den stuff is not here', 'almost all'], e.clean_backtrace
+ end
+
+ def test_app_backtrace
+ Exception::TraceSubstitutions << [/\s*hidden.*/, '']
+ e = get_exception RuntimeError, 'RAWR', ['bhal.rb', ' vendor/file.rb some stuff', 'almost all']
+ assert_kind_of Exception, e
+ assert_equal ['bhal.rb', 'almost all'], e.application_backtrace
+ end
+
+ def test_app_backtrace_with_before
+ Exception::TraceSubstitutions << [/\s*hidden.*/, '']
+ e = get_exception RuntimeError, 'RAWR', ['vendor/file.rb some stuff', 'bhal.rb', ' vendor/file.rb some stuff', 'almost all']
+ assert_kind_of Exception, e
+ assert_equal ['vendor/file.rb some stuff', 'bhal.rb', 'almost all'], e.application_backtrace
+ end
+
+ def test_framework_backtrace_with_before
+ Exception::TraceSubstitutions << [/\s*hidden.*/, '']
+ e = get_exception RuntimeError, 'RAWR', ['vendor/file.rb some stuff', 'bhal.rb', ' vendor/file.rb some stuff', 'almost all']
+ assert_kind_of Exception, e
+ assert_equal ['vendor/file.rb some stuff', ' vendor/file.rb some stuff'], e.framework_backtrace
+ end
+
+ def test_backtrace_should_clean_paths
+ Exception::TraceSubstitutions << [/\s*hidden.*/, '']
+ e = get_exception RuntimeError, 'RAWR', ['a/b/c/../d/../../../bhal.rb', 'rawh hid den stuff is not here', 'almost all']
+ assert_kind_of Exception, e
+ assert_equal ['bhal.rb', 'rawh hid den stuff is not here', 'almost all'], e.clean_backtrace
+ end
+
+ def test_clean_message_should_clean_paths
+ Exception::TraceSubstitutions << [/\s*hidden.*/, '']
+ e = get_exception RuntimeError, "I dislike a/z/x/../../b/y/../c", ['a/b/c/../d/../../../bhal.rb', 'rawh hid den stuff is not here', 'almost all']
+ assert_kind_of Exception, e
+ assert_equal "I dislike a/b/c", e.clean_message
+ end
+
+ def test_app_trace_should_be_empty_when_no_app_frames
+ Exception::TraceSubstitutions << [/\s*hidden.*/, '']
+ e = get_exception RuntimeError, 'RAWR', ['vendor/file.rb some stuff', 'generated/bhal.rb', ' vendor/file.rb some stuff', 'generated/almost all']
+ assert_kind_of Exception, e
+ assert_equal [], e.application_backtrace
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/file_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/file_test.rb
new file mode 100644
index 000000000..110253887
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/file_test.rb
@@ -0,0 +1,29 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+class AtomicWriteTest < Test::Unit::TestCase
+
+ def test_atomic_write_without_errors
+ contents = "Atomic Text"
+ File.atomic_write(file_name, Dir.pwd) do |file|
+ file.write(contents)
+ assert !File.exist?(file_name)
+ end
+ assert File.exist?(file_name)
+ assert_equal contents, File.read(file_name)
+ ensure
+ File.unlink(file_name) rescue nil
+ end
+
+ def test_atomic_write_doesnt_write_when_block_raises
+ File.atomic_write(file_name) do |file|
+ file.write("testing")
+ raise "something bad"
+ end
+ rescue
+ assert !File.exist?(file_name)
+ end
+
+ def file_name
+ "atomic.file"
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/float_ext_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/float_ext_test.rb
new file mode 100644
index 000000000..b74add519
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/float_ext_test.rb
@@ -0,0 +1,25 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+class FloatExtRoundingTests < Test::Unit::TestCase
+ def test_round_for_positive_number
+ assert_equal 1, 1.4.round
+ assert_equal 2, 1.6.round
+ assert_equal 2, 1.6.round(0)
+ assert_equal 1.4, 1.4.round(1)
+ assert_equal 1.4, 1.4.round(3)
+ assert_equal 1.5, 1.45.round(1)
+ assert_equal 1.45, 1.445.round(2)
+ end
+
+ def test_round_for_negative_number
+ assert_equal( -1, -1.4.round )
+ assert_equal( -2, -1.6.round )
+ assert_equal( -1.4, -1.4.round(1) )
+ assert_equal( -1.5, -1.45.round(1) )
+ end
+
+ def test_round_with_negative_precision
+ assert_equal 123460.0, 123456.0.round(-1)
+ assert_equal 123500.0, 123456.0.round(-2)
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/hash_ext_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/hash_ext_test.rb
new file mode 100644
index 000000000..4d01faa5d
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/hash_ext_test.rb
@@ -0,0 +1,743 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+class HashExtTest < Test::Unit::TestCase
+ def setup
+ @strings = { 'a' => 1, 'b' => 2 }
+ @symbols = { :a => 1, :b => 2 }
+ @mixed = { :a => 1, 'b' => 2 }
+ @fixnums = { 0 => 1, 1 => 2 }
+ end
+
+ def test_methods
+ h = {}
+ assert_respond_to h, :symbolize_keys
+ assert_respond_to h, :symbolize_keys!
+ assert_respond_to h, :stringify_keys
+ assert_respond_to h, :stringify_keys!
+ assert_respond_to h, :to_options
+ assert_respond_to h, :to_options!
+ end
+
+ def test_symbolize_keys
+ assert_equal @symbols, @symbols.symbolize_keys
+ assert_equal @symbols, @strings.symbolize_keys
+ assert_equal @symbols, @mixed.symbolize_keys
+
+ assert_raises(NoMethodError) { { [] => 1 }.symbolize_keys }
+ end
+
+ def test_symbolize_keys!
+ assert_equal @symbols, @symbols.dup.symbolize_keys!
+ assert_equal @symbols, @strings.dup.symbolize_keys!
+ assert_equal @symbols, @mixed.dup.symbolize_keys!
+
+ assert_raises(NoMethodError) { { [] => 1 }.symbolize_keys }
+ end
+
+ def test_symbolize_keys_preserves_fixnum_keys
+ assert_equal @fixnums, @fixnums.symbolize_keys
+ assert_equal @fixnums, @fixnums.dup.symbolize_keys!
+ end
+
+ def test_stringify_keys
+ assert_equal @strings, @symbols.stringify_keys
+ assert_equal @strings, @strings.stringify_keys
+ assert_equal @strings, @mixed.stringify_keys
+ end
+
+ def test_stringify_keys!
+ assert_equal @strings, @symbols.dup.stringify_keys!
+ assert_equal @strings, @strings.dup.stringify_keys!
+ assert_equal @strings, @mixed.dup.stringify_keys!
+ end
+
+ def test_indifferent_assorted
+ @strings = @strings.with_indifferent_access
+ @symbols = @symbols.with_indifferent_access
+ @mixed = @mixed.with_indifferent_access
+
+ assert_equal 'a', @strings.send!(:convert_key, :a)
+
+ assert_equal 1, @strings.fetch('a')
+ assert_equal 1, @strings.fetch(:a.to_s)
+ assert_equal 1, @strings.fetch(:a)
+
+ hashes = { :@strings => @strings, :@symbols => @symbols, :@mixed => @mixed }
+ method_map = { :'[]' => 1, :fetch => 1, :values_at => [1],
+ :has_key? => true, :include? => true, :key? => true,
+ :member? => true }
+
+ hashes.each do |name, hash|
+ method_map.sort_by { |m| m.to_s }.each do |meth, expected|
+ assert_equal(expected, hash.send!(meth, 'a'),
+ "Calling #{name}.#{meth} 'a'")
+ assert_equal(expected, hash.send!(meth, :a),
+ "Calling #{name}.#{meth} :a")
+ end
+ end
+
+ assert_equal [1, 2], @strings.values_at('a', 'b')
+ assert_equal [1, 2], @strings.values_at(:a, :b)
+ assert_equal [1, 2], @symbols.values_at('a', 'b')
+ assert_equal [1, 2], @symbols.values_at(:a, :b)
+ assert_equal [1, 2], @mixed.values_at('a', 'b')
+ assert_equal [1, 2], @mixed.values_at(:a, :b)
+ end
+
+ def test_indifferent_reading
+ hash = HashWithIndifferentAccess.new
+ hash["a"] = 1
+ hash["b"] = true
+ hash["c"] = false
+ hash["d"] = nil
+
+ assert_equal 1, hash[:a]
+ assert_equal true, hash[:b]
+ assert_equal false, hash[:c]
+ assert_equal nil, hash[:d]
+ assert_equal nil, hash[:e]
+ end
+
+ def test_indifferent_reading_with_nonnil_default
+ hash = HashWithIndifferentAccess.new(1)
+ hash["a"] = 1
+ hash["b"] = true
+ hash["c"] = false
+ hash["d"] = nil
+
+ assert_equal 1, hash[:a]
+ assert_equal true, hash[:b]
+ assert_equal false, hash[:c]
+ assert_equal nil, hash[:d]
+ assert_equal 1, hash[:e]
+ end
+
+ def test_indifferent_writing
+ hash = HashWithIndifferentAccess.new
+ hash[:a] = 1
+ hash['b'] = 2
+ hash[3] = 3
+
+ assert_equal hash['a'], 1
+ assert_equal hash['b'], 2
+ assert_equal hash[:a], 1
+ assert_equal hash[:b], 2
+ assert_equal hash[3], 3
+ end
+
+ def test_indifferent_update
+ hash = HashWithIndifferentAccess.new
+ hash[:a] = 'a'
+ hash['b'] = 'b'
+
+ updated_with_strings = hash.update(@strings)
+ updated_with_symbols = hash.update(@symbols)
+ updated_with_mixed = hash.update(@mixed)
+
+ assert_equal updated_with_strings[:a], 1
+ assert_equal updated_with_strings['a'], 1
+ assert_equal updated_with_strings['b'], 2
+
+ assert_equal updated_with_symbols[:a], 1
+ assert_equal updated_with_symbols['b'], 2
+ assert_equal updated_with_symbols[:b], 2
+
+ assert_equal updated_with_mixed[:a], 1
+ assert_equal updated_with_mixed['b'], 2
+
+ assert [updated_with_strings, updated_with_symbols, updated_with_mixed].all? { |h| h.keys.size == 2 }
+ end
+
+ def test_indifferent_merging
+ hash = HashWithIndifferentAccess.new
+ hash[:a] = 'failure'
+ hash['b'] = 'failure'
+
+ other = { 'a' => 1, :b => 2 }
+
+ merged = hash.merge(other)
+
+ assert_equal HashWithIndifferentAccess, merged.class
+ assert_equal 1, merged[:a]
+ assert_equal 2, merged['b']
+
+ hash.update(other)
+
+ assert_equal 1, hash[:a]
+ assert_equal 2, hash['b']
+ end
+
+ def test_indifferent_deleting
+ get_hash = proc{ { :a => 'foo' }.with_indifferent_access }
+ hash = get_hash.call
+ assert_equal hash.delete(:a), 'foo'
+ assert_equal hash.delete(:a), nil
+ hash = get_hash.call
+ assert_equal hash.delete('a'), 'foo'
+ assert_equal hash.delete('a'), nil
+ end
+
+ def test_indifferent_to_hash
+ # Should convert to a Hash with String keys.
+ assert_equal @strings, @mixed.with_indifferent_access.to_hash
+
+ # Should preserve the default value.
+ mixed_with_default = @mixed.dup
+ mixed_with_default.default = '1234'
+ roundtrip = mixed_with_default.with_indifferent_access.to_hash
+ assert_equal @strings, roundtrip
+ assert_equal '1234', roundtrip.default
+ end
+
+ def test_indifferent_hash_with_array_of_hashes
+ hash = { "urls" => { "url" => [ { "address" => "1" }, { "address" => "2" } ] }}.with_indifferent_access
+ assert_equal "1", hash[:urls][:url].first[:address]
+ end
+
+ def test_stringify_and_symbolize_keys_on_indifferent_preserves_hash
+ h = HashWithIndifferentAccess.new
+ h[:first] = 1
+ h.stringify_keys!
+ assert_equal 1, h['first']
+ h = HashWithIndifferentAccess.new
+ h['first'] = 1
+ h.symbolize_keys!
+ assert_equal 1, h[:first]
+ end
+
+ def test_to_options_on_indifferent_preserves_hash
+ h = HashWithIndifferentAccess.new
+ h['first'] = 1
+ h.to_options!
+ assert_equal 1, h['first']
+ end
+
+
+ def test_indifferent_subhashes
+ h = {'user' => {'id' => 5}}.with_indifferent_access
+ ['user', :user].each {|user| [:id, 'id'].each {|id| assert_equal 5, h[user][id], "h[#{user.inspect}][#{id.inspect}] should be 5"}}
+
+ h = {:user => {:id => 5}}.with_indifferent_access
+ ['user', :user].each {|user| [:id, 'id'].each {|id| assert_equal 5, h[user][id], "h[#{user.inspect}][#{id.inspect}] should be 5"}}
+ end
+
+ def test_assert_valid_keys
+ assert_nothing_raised do
+ { :failure => "stuff", :funny => "business" }.assert_valid_keys([ :failure, :funny ])
+ { :failure => "stuff", :funny => "business" }.assert_valid_keys(:failure, :funny)
+ end
+
+ assert_raises(ArgumentError, "Unknown key(s): failore") do
+ { :failore => "stuff", :funny => "business" }.assert_valid_keys([ :failure, :funny ])
+ { :failore => "stuff", :funny => "business" }.assert_valid_keys(:failure, :funny)
+ end
+ end
+
+ def test_assorted_keys_not_stringified
+ original = {Object.new => 2, 1 => 2, [] => true}
+ indiff = original.with_indifferent_access
+ assert(!indiff.keys.any? {|k| k.kind_of? String}, "A key was converted to a string!")
+ end
+
+ def test_reverse_merge
+ defaults = { :a => "x", :b => "y", :c => 10 }.freeze
+ options = { :a => 1, :b => 2 }
+ expected = { :a => 1, :b => 2, :c => 10 }
+
+ # Should merge defaults into options, creating a new hash.
+ assert_equal expected, options.reverse_merge(defaults)
+ assert_not_equal expected, options
+
+ # Should merge! defaults into options, replacing options.
+ merged = options.dup
+ assert_equal expected, merged.reverse_merge!(defaults)
+ assert_equal expected, merged
+
+ # Should be an alias for reverse_merge!
+ merged = options.dup
+ assert_equal expected, merged.reverse_update(defaults)
+ assert_equal expected, merged
+ end
+
+ def test_diff
+ assert_equal({ :a => 2 }, { :a => 2, :b => 5 }.diff({ :a => 1, :b => 5 }))
+ end
+
+ def test_slice
+ original = { :a => 'x', :b => 'y', :c => 10 }
+ expected = { :a => 'x', :b => 'y' }
+
+ # Should return a new hash with only the given keys.
+ assert_equal expected, original.slice(:a, :b)
+ assert_not_equal expected, original
+
+ # Should replace the hash with only the given keys.
+ assert_equal expected, original.slice!(:a, :b)
+ assert_equal expected, original
+ end
+
+ def test_indifferent_slice
+ original = { :a => 'x', :b => 'y', :c => 10 }.with_indifferent_access
+ expected = { :a => 'x', :b => 'y' }.with_indifferent_access
+
+ [['a', 'b'], [:a, :b]].each do |keys|
+ # Should return a new hash with only the given keys.
+ assert_equal expected, original.slice(*keys), keys.inspect
+ assert_not_equal expected, original
+
+ # Should replace the hash with only the given keys.
+ copy = original.dup
+ assert_equal expected, copy.slice!(*keys)
+ assert_equal expected, copy
+ end
+ end
+
+ def test_except
+ original = { :a => 'x', :b => 'y', :c => 10 }
+ expected = { :a => 'x', :b => 'y' }
+
+ # Should return a new hash with only the given keys.
+ assert_equal expected, original.except(:c)
+ assert_not_equal expected, original
+
+ # Should replace the hash with only the given keys.
+ assert_equal expected, original.except!(:c)
+ assert_equal expected, original
+ end
+end
+
+class IWriteMyOwnXML
+ def to_xml(options = {})
+ options[:indent] ||= 2
+ xml = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
+ xml.instruct! unless options[:skip_instruct]
+ xml.level_one do
+ xml.tag!(:second_level, 'content')
+ end
+ end
+end
+
+class HashToXmlTest < Test::Unit::TestCase
+ def setup
+ @xml_options = { :root => :person, :skip_instruct => true, :indent => 0 }
+ end
+
+ def test_one_level
+ xml = { :name => "David", :street => "Paulina" }.to_xml(@xml_options)
+ assert_equal "<person>", xml.first(8)
+ assert xml.include?(%(<street>Paulina</street>))
+ assert xml.include?(%(<name>David</name>))
+ end
+
+ def test_one_level_dasherize_false
+ xml = { :name => "David", :street_name => "Paulina" }.to_xml(@xml_options.merge(:dasherize => false))
+ assert_equal "<person>", xml.first(8)
+ assert xml.include?(%(<street_name>Paulina</street_name>))
+ assert xml.include?(%(<name>David</name>))
+ end
+
+ def test_one_level_dasherize_true
+ xml = { :name => "David", :street_name => "Paulina" }.to_xml(@xml_options.merge(:dasherize => true))
+ assert_equal "<person>", xml.first(8)
+ assert xml.include?(%(<street-name>Paulina</street-name>))
+ assert xml.include?(%(<name>David</name>))
+ end
+
+ def test_one_level_with_types
+ xml = { :name => "David", :street => "Paulina", :age => 26, :age_in_millis => 820497600000, :moved_on => Date.new(2005, 11, 15), :resident => :yes }.to_xml(@xml_options)
+ assert_equal "<person>", xml.first(8)
+ assert xml.include?(%(<street>Paulina</street>))
+ assert xml.include?(%(<name>David</name>))
+ assert xml.include?(%(<age type="integer">26</age>))
+ assert xml.include?(%(<age-in-millis type="integer">820497600000</age-in-millis>))
+ assert xml.include?(%(<moved-on type="date">2005-11-15</moved-on>))
+ assert xml.include?(%(<resident type="symbol">yes</resident>))
+ end
+
+ def test_one_level_with_nils
+ xml = { :name => "David", :street => "Paulina", :age => nil }.to_xml(@xml_options)
+ assert_equal "<person>", xml.first(8)
+ assert xml.include?(%(<street>Paulina</street>))
+ assert xml.include?(%(<name>David</name>))
+ assert xml.include?(%(<age nil="true"></age>))
+ end
+
+ def test_one_level_with_skipping_types
+ xml = { :name => "David", :street => "Paulina", :age => nil }.to_xml(@xml_options.merge(:skip_types => true))
+ assert_equal "<person>", xml.first(8)
+ assert xml.include?(%(<street>Paulina</street>))
+ assert xml.include?(%(<name>David</name>))
+ assert xml.include?(%(<age nil="true"></age>))
+ end
+
+ def test_one_level_with_yielding
+ xml = { :name => "David", :street => "Paulina" }.to_xml(@xml_options) do |x|
+ x.creator("Rails")
+ end
+
+ assert_equal "<person>", xml.first(8)
+ assert xml.include?(%(<street>Paulina</street>))
+ assert xml.include?(%(<name>David</name>))
+ assert xml.include?(%(<creator>Rails</creator>))
+ end
+
+ def test_two_levels
+ xml = { :name => "David", :address => { :street => "Paulina" } }.to_xml(@xml_options)
+ assert_equal "<person>", xml.first(8)
+ assert xml.include?(%(<address><street>Paulina</street></address>))
+ assert xml.include?(%(<name>David</name>))
+ end
+
+ def test_two_levels_with_second_level_overriding_to_xml
+ xml = { :name => "David", :address => { :street => "Paulina" }, :child => IWriteMyOwnXML.new }.to_xml(@xml_options)
+ assert_equal "<person>", xml.first(8)
+ assert xml.include?(%(<address><street>Paulina</street></address>))
+ assert xml.include?(%(<level_one><second_level>content</second_level></level_one>))
+ end
+
+ def test_two_levels_with_array
+ xml = { :name => "David", :addresses => [{ :street => "Paulina" }, { :street => "Evergreen" }] }.to_xml(@xml_options)
+ assert_equal "<person>", xml.first(8)
+ assert xml.include?(%(<addresses type="array"><address>))
+ assert xml.include?(%(<address><street>Paulina</street></address>))
+ assert xml.include?(%(<address><street>Evergreen</street></address>))
+ assert xml.include?(%(<name>David</name>))
+ end
+
+ def test_three_levels_with_array
+ xml = { :name => "David", :addresses => [{ :streets => [ { :name => "Paulina" }, { :name => "Paulina" } ] } ] }.to_xml(@xml_options)
+ assert xml.include?(%(<addresses type="array"><address><streets type="array"><street><name>))
+ end
+
+ def test_single_record_from_xml
+ topic_xml = <<-EOT
+ <topic>
+ <title>The First Topic</title>
+ <author-name>David</author-name>
+ <id type="integer">1</id>
+ <approved type="boolean"> true </approved>
+ <replies-count type="integer">0</replies-count>
+ <replies-close-in type="integer">2592000000</replies-close-in>
+ <written-on type="date">2003-07-16</written-on>
+ <viewed-at type="datetime">2003-07-16T09:28:00+0000</viewed-at>
+ <content type="yaml">--- \n1: should be an integer\n:message: Have a nice day\narray: \n- should-have-dashes: true\n should_have_underscores: true\n</content>
+ <author-email-address>david@loudthinking.com</author-email-address>
+ <parent-id></parent-id>
+ <ad-revenue type="decimal">1.5</ad-revenue>
+ <optimum-viewing-angle type="float">135</optimum-viewing-angle>
+ <resident type="symbol">yes</resident>
+ </topic>
+ EOT
+
+ expected_topic_hash = {
+ :title => "The First Topic",
+ :author_name => "David",
+ :id => 1,
+ :approved => true,
+ :replies_count => 0,
+ :replies_close_in => 2592000000,
+ :written_on => Date.new(2003, 7, 16),
+ :viewed_at => Time.utc(2003, 7, 16, 9, 28),
+ :content => { :message => "Have a nice day", 1 => "should be an integer", "array" => [{ "should-have-dashes" => true, "should_have_underscores" => true }] },
+ :author_email_address => "david@loudthinking.com",
+ :parent_id => nil,
+ :ad_revenue => BigDecimal("1.50"),
+ :optimum_viewing_angle => 135.0,
+ :resident => :yes
+ }.stringify_keys
+
+ assert_equal expected_topic_hash, Hash.from_xml(topic_xml)["topic"]
+ end
+
+ def test_single_record_from_xml_with_nil_values
+ topic_xml = <<-EOT
+ <topic>
+ <title></title>
+ <id type="integer"></id>
+ <approved type="boolean"></approved>
+ <written-on type="date"></written-on>
+ <viewed-at type="datetime"></viewed-at>
+ <content type="yaml"></content>
+ <parent-id></parent-id>
+ </topic>
+ EOT
+
+ expected_topic_hash = {
+ :title => nil,
+ :id => nil,
+ :approved => nil,
+ :written_on => nil,
+ :viewed_at => nil,
+ :content => nil,
+ :parent_id => nil
+ }.stringify_keys
+
+ assert_equal expected_topic_hash, Hash.from_xml(topic_xml)["topic"]
+ end
+
+ def test_multiple_records_from_xml
+ topics_xml = <<-EOT
+ <topics type="array">
+ <topic>
+ <title>The First Topic</title>
+ <author-name>David</author-name>
+ <id type="integer">1</id>
+ <approved type="boolean">false</approved>
+ <replies-count type="integer">0</replies-count>
+ <replies-close-in type="integer">2592000000</replies-close-in>
+ <written-on type="date">2003-07-16</written-on>
+ <viewed-at type="datetime">2003-07-16T09:28:00+0000</viewed-at>
+ <content>Have a nice day</content>
+ <author-email-address>david@loudthinking.com</author-email-address>
+ <parent-id nil="true"></parent-id>
+ </topic>
+ <topic>
+ <title>The Second Topic</title>
+ <author-name>Jason</author-name>
+ <id type="integer">1</id>
+ <approved type="boolean">false</approved>
+ <replies-count type="integer">0</replies-count>
+ <replies-close-in type="integer">2592000000</replies-close-in>
+ <written-on type="date">2003-07-16</written-on>
+ <viewed-at type="datetime">2003-07-16T09:28:00+0000</viewed-at>
+ <content>Have a nice day</content>
+ <author-email-address>david@loudthinking.com</author-email-address>
+ <parent-id></parent-id>
+ </topic>
+ </topics>
+ EOT
+
+ expected_topic_hash = {
+ :title => "The First Topic",
+ :author_name => "David",
+ :id => 1,
+ :approved => false,
+ :replies_count => 0,
+ :replies_close_in => 2592000000,
+ :written_on => Date.new(2003, 7, 16),
+ :viewed_at => Time.utc(2003, 7, 16, 9, 28),
+ :content => "Have a nice day",
+ :author_email_address => "david@loudthinking.com",
+ :parent_id => nil
+ }.stringify_keys
+
+ assert_equal expected_topic_hash, Hash.from_xml(topics_xml)["topics"].first
+ end
+
+ def test_single_record_from_xml_with_attributes_other_than_type
+ topic_xml = <<-EOT
+ <rsp stat="ok">
+ <photos page="1" pages="1" perpage="100" total="16">
+ <photo id="175756086" owner="55569174@N00" secret="0279bf37a1" server="76" title="Colored Pencil PhotoBooth Fun" ispublic="1" isfriend="0" isfamily="0"/>
+ </photos>
+ </rsp>
+ EOT
+
+ expected_topic_hash = {
+ :id => "175756086",
+ :owner => "55569174@N00",
+ :secret => "0279bf37a1",
+ :server => "76",
+ :title => "Colored Pencil PhotoBooth Fun",
+ :ispublic => "1",
+ :isfriend => "0",
+ :isfamily => "0",
+ }.stringify_keys
+
+ assert_equal expected_topic_hash, Hash.from_xml(topic_xml)["rsp"]["photos"]["photo"]
+ end
+
+ def test_empty_array_from_xml
+ blog_xml = <<-XML
+ <blog>
+ <posts type="array"></posts>
+ </blog>
+ XML
+ expected_blog_hash = {"blog" => {"posts" => []}}
+ assert_equal expected_blog_hash, Hash.from_xml(blog_xml)
+ end
+
+ def test_empty_array_with_whitespace_from_xml
+ blog_xml = <<-XML
+ <blog>
+ <posts type="array">
+ </posts>
+ </blog>
+ XML
+ expected_blog_hash = {"blog" => {"posts" => []}}
+ assert_equal expected_blog_hash, Hash.from_xml(blog_xml)
+ end
+
+ def test_array_with_one_entry_from_xml
+ blog_xml = <<-XML
+ <blog>
+ <posts type="array">
+ <post>a post</post>
+ </posts>
+ </blog>
+ XML
+ expected_blog_hash = {"blog" => {"posts" => ["a post"]}}
+ assert_equal expected_blog_hash, Hash.from_xml(blog_xml)
+ end
+
+ def test_array_with_multiple_entries_from_xml
+ blog_xml = <<-XML
+ <blog>
+ <posts type="array">
+ <post>a post</post>
+ <post>another post</post>
+ </posts>
+ </blog>
+ XML
+ expected_blog_hash = {"blog" => {"posts" => ["a post", "another post"]}}
+ assert_equal expected_blog_hash, Hash.from_xml(blog_xml)
+ end
+
+ def test_xsd_like_types_from_xml
+ bacon_xml = <<-EOT
+ <bacon>
+ <weight type="double">0.5</weight>
+ <price type="decimal">12.50</price>
+ <chunky type="boolean"> 1 </chunky>
+ <expires-at type="dateTime">2007-12-25T12:34:56+0000</expires-at>
+ <notes type="string"></notes>
+ <illustration type="base64Binary">YmFiZS5wbmc=</illustration>
+ </bacon>
+ EOT
+
+ expected_bacon_hash = {
+ :weight => 0.5,
+ :chunky => true,
+ :price => BigDecimal("12.50"),
+ :expires_at => Time.utc(2007,12,25,12,34,56),
+ :notes => "",
+ :illustration => "babe.png"
+ }.stringify_keys
+
+ assert_equal expected_bacon_hash, Hash.from_xml(bacon_xml)["bacon"]
+ end
+
+ def test_type_trickles_through_when_unknown
+ product_xml = <<-EOT
+ <product>
+ <weight type="double">0.5</weight>
+ <image type="ProductImage"><filename>image.gif</filename></image>
+
+ </product>
+ EOT
+
+ expected_product_hash = {
+ :weight => 0.5,
+ :image => {'type' => 'ProductImage', 'filename' => 'image.gif' },
+ }.stringify_keys
+
+ assert_equal expected_product_hash, Hash.from_xml(product_xml)["product"]
+ end
+
+ def test_should_use_default_value_for_unknown_key
+ hash_wia = HashWithIndifferentAccess.new(3)
+ assert_equal 3, hash_wia[:new_key]
+ end
+
+ def test_should_use_default_value_if_no_key_is_supplied
+ hash_wia = HashWithIndifferentAccess.new(3)
+ assert_equal 3, hash_wia.default
+ end
+
+ def test_should_nil_if_no_default_value_is_supplied
+ hash_wia = HashWithIndifferentAccess.new
+ assert_nil hash_wia.default
+ end
+
+ def test_should_copy_the_default_value_when_converting_to_hash_with_indifferent_access
+ hash = Hash.new(3)
+ hash_wia = hash.with_indifferent_access
+ assert_equal 3, hash_wia.default
+ end
+
+ # The XML builder seems to fail miserably when trying to tag something
+ # with the same name as a Kernel method (throw, test, loop, select ...)
+ def test_kernel_method_names_to_xml
+ hash = { :throw => { :ball => 'red' } }
+ expected = '<person><throw><ball>red</ball></throw></person>'
+
+ assert_nothing_raised do
+ assert_equal expected, hash.to_xml(@xml_options)
+ end
+ end
+
+ def test_empty_string_works_for_typecast_xml_value
+ assert_nothing_raised do
+ Hash.send!(:typecast_xml_value, "")
+ end
+ end
+
+ def test_escaping_to_xml
+ hash = {
+ :bare_string => 'First & Last Name',
+ :pre_escaped_string => 'First &amp; Last Name'
+ }.stringify_keys
+
+ expected_xml = '<person><bare-string>First &amp; Last Name</bare-string><pre-escaped-string>First &amp;amp; Last Name</pre-escaped-string></person>'
+ assert_equal expected_xml, hash.to_xml(@xml_options)
+ end
+
+ def test_unescaping_from_xml
+ xml_string = '<person><bare-string>First &amp; Last Name</bare-string><pre-escaped-string>First &amp;amp; Last Name</pre-escaped-string></person>'
+ expected_hash = {
+ :bare_string => 'First & Last Name',
+ :pre_escaped_string => 'First &amp; Last Name'
+ }.stringify_keys
+ assert_equal expected_hash, Hash.from_xml(xml_string)['person']
+ end
+
+ def test_roundtrip_to_xml_from_xml
+ hash = {
+ :bare_string => 'First & Last Name',
+ :pre_escaped_string => 'First &amp; Last Name'
+ }.stringify_keys
+
+ assert_equal hash, Hash.from_xml(hash.to_xml(@xml_options))['person']
+ end
+end
+
+class QueryTest < Test::Unit::TestCase
+ def test_simple_conversion
+ assert_query_equal 'a=10', :a => 10
+ end
+
+ def test_cgi_escaping
+ assert_query_equal 'a%3Ab=c+d', 'a:b' => 'c d'
+ end
+
+ def test_nil_parameter_value
+ empty = Object.new
+ def empty.to_param; nil end
+ assert_query_equal 'a=', 'a' => empty
+ end
+
+ def test_nested_conversion
+ assert_query_equal 'person%5Blogin%5D=seckar&person%5Bname%5D=Nicholas',
+ :person => {:name => 'Nicholas', :login => 'seckar'}
+ end
+
+ def test_multiple_nested
+ assert_query_equal 'account%5Bperson%5D%5Bid%5D=20&person%5Bid%5D=10',
+ :person => {:id => 10}, :account => {:person => {:id => 20}}
+ end
+
+ def test_array_values
+ assert_query_equal 'person%5Bid%5D%5B%5D=10&person%5Bid%5D%5B%5D=20',
+ :person => {:id => [10, 20]}
+ end
+
+ def test_array_values_are_not_sorted
+ assert_query_equal 'person%5Bid%5D%5B%5D=20&person%5Bid%5D%5B%5D=10',
+ :person => {:id => [20, 10]}
+ end
+
+ private
+ def assert_query_equal(expected, actual, message = nil)
+ assert_equal expected.split('&'), actual.to_query.split('&')
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/integer_ext_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/integer_ext_test.rb
new file mode 100644
index 000000000..6d6b79686
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/integer_ext_test.rb
@@ -0,0 +1,37 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+class IntegerExtTest < Test::Unit::TestCase
+ def test_even
+ assert [ -2, 0, 2, 4 ].all? { |i| i.even? }
+ assert ![ -1, 1, 3 ].all? { |i| i.even? }
+
+ assert 22953686867719691230002707821868552601124472329079.odd?
+ assert !22953686867719691230002707821868552601124472329079.even?
+ assert 22953686867719691230002707821868552601124472329080.even?
+ assert !22953686867719691230002707821868552601124472329080.odd?
+ end
+
+ def test_odd
+ assert ![ -2, 0, 2, 4 ].all? { |i| i.odd? }
+ assert [ -1, 1, 3 ].all? { |i| i.odd? }
+ assert 1000000000000000000000000000000000000000000000000000000001.odd?
+ end
+
+ def test_multiple_of
+ [ -7, 0, 7, 14 ].each { |i| assert i.multiple_of?(7) }
+ [ -7, 7, 14 ].each { |i| assert ! i.multiple_of?(6) }
+ # test with a prime
+ assert !22953686867719691230002707821868552601124472329079.multiple_of?(2)
+ assert !22953686867719691230002707821868552601124472329079.multiple_of?(3)
+ assert !22953686867719691230002707821868552601124472329079.multiple_of?(5)
+ assert !22953686867719691230002707821868552601124472329079.multiple_of?(7)
+ end
+
+ def test_ordinalize
+ # These tests are mostly just to ensure that the ordinalize method exists
+ # It's results are tested comprehensively in the inflector test cases.
+ assert_equal '1st', 1.ordinalize
+ assert_equal '8th', 8.ordinalize
+ 1000000000000000000000000000000000000000000000000000000000000000000000.ordinalize
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/kernel_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/kernel_test.rb
new file mode 100644
index 000000000..92d904706
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/kernel_test.rb
@@ -0,0 +1,43 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+class KernelTest < Test::Unit::TestCase
+ def test_silence_warnings
+ silence_warnings { assert_nil $VERBOSE }
+ assert_equal 1234, silence_warnings { 1234 }
+ end
+
+ def test_silence_warnings_verbose_invariant
+ old_verbose = $VERBOSE
+ silence_warnings { raise }
+ flunk
+ rescue
+ assert_equal old_verbose, $VERBOSE
+ end
+
+
+ def test_enable_warnings
+ enable_warnings { assert_equal true, $VERBOSE }
+ assert_equal 1234, enable_warnings { 1234 }
+ end
+
+ def test_enable_warnings_verbose_invariant
+ old_verbose = $VERBOSE
+ enable_warnings { raise }
+ flunk
+ rescue
+ assert_equal old_verbose, $VERBOSE
+ end
+
+
+ def test_silence_stderr
+ old_stderr_position = STDERR.tell
+ silence_stderr { STDERR.puts 'hello world' }
+ assert_equal old_stderr_position, STDERR.tell
+ rescue Errno::ESPIPE
+ # Skip if we can't STDERR.tell
+ end
+
+ def test_silence_stderr_with_return_value
+ assert_equal 1, silence_stderr { 1 }
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/load_error_tests.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/load_error_tests.rb
new file mode 100644
index 000000000..34c5cb4cd
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/load_error_tests.rb
@@ -0,0 +1,16 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+class TestMissingSourceFile < Test::Unit::TestCase
+ def test_with_require
+ assert_raises(MissingSourceFile) { require 'no_this_file_don\'t_exist' }
+ end
+ def test_with_load
+ assert_raises(MissingSourceFile) { load 'nor_does_this_one' }
+ end
+ def test_path
+ begin load 'nor/this/one.rb'
+ rescue MissingSourceFile => e
+ assert_equal 'nor/this/one.rb', e.path
+ end
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/module/attr_accessor_with_default_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/module/attr_accessor_with_default_test.rb
new file mode 100644
index 000000000..71039c0ef
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/module/attr_accessor_with_default_test.rb
@@ -0,0 +1,30 @@
+require File.dirname(__FILE__) + '/../../abstract_unit'
+
+class AttrAccessorWithDefaultTest < Test::Unit::TestCase
+ def setup
+ @target = Class.new do
+ def helper
+ 'helper'
+ end
+ end
+ @instance = @target.new
+ end
+
+ def test_default_arg
+ @target.attr_accessor_with_default :foo, :bar
+ assert_equal(:bar, @instance.foo)
+ @instance.foo = nil
+ assert_nil(@instance.foo)
+ end
+
+ def test_default_proc
+ @target.attr_accessor_with_default(:foo) {helper.upcase}
+ assert_equal('HELPER', @instance.foo)
+ @instance.foo = nil
+ assert_nil(@instance.foo)
+ end
+
+ def test_invalid_args
+ assert_raise(RuntimeError) {@target.attr_accessor_with_default :foo}
+ end
+end \ No newline at end of file
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/module/attr_internal_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/module/attr_internal_test.rb
new file mode 100644
index 000000000..1bf831e49
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/module/attr_internal_test.rb
@@ -0,0 +1,52 @@
+require File.dirname(__FILE__) + '/../../abstract_unit'
+
+class AttrInternalTest < Test::Unit::TestCase
+ def setup
+ @target = Class.new
+ @instance = @target.new
+ end
+
+ def test_reader
+ assert_nothing_raised { @target.attr_internal_reader :foo }
+
+ assert !@instance.instance_variable_defined?('@_foo')
+ assert_raise(NoMethodError) { @instance.foo = 1 }
+
+ @instance.instance_variable_set('@_foo', 1)
+ assert_nothing_raised { assert_equal 1, @instance.foo }
+ end
+
+ def test_writer
+ assert_nothing_raised { @target.attr_internal_writer :foo }
+
+ assert !@instance.instance_variable_defined?('@_foo')
+ assert_nothing_raised { assert_equal 1, @instance.foo = 1 }
+
+ assert_equal 1, @instance.instance_variable_get('@_foo')
+ assert_raise(NoMethodError) { @instance.foo }
+ end
+
+ def test_accessor
+ assert_nothing_raised { @target.attr_internal :foo }
+
+ assert !@instance.instance_variable_defined?('@_foo')
+ assert_nothing_raised { assert_equal 1, @instance.foo = 1 }
+
+ assert_equal 1, @instance.instance_variable_get('@_foo')
+ assert_nothing_raised { assert_equal 1, @instance.foo }
+ end
+
+ def test_naming_format
+ assert_equal '@_%s', @target.attr_internal_naming_format
+ assert_nothing_raised { @target.attr_internal_naming_format = '@abc%sdef' }
+ @target.attr_internal :foo
+
+ assert !@instance.instance_variable_defined?('@_foo')
+ assert !@instance.instance_variable_defined?('@abcfoodef')
+ assert_nothing_raised { @instance.foo = 1 }
+ assert !@instance.instance_variable_defined?('@_foo')
+ assert @instance.instance_variable_defined?('@abcfoodef')
+ ensure
+ @target.attr_internal_naming_format = '@_%s'
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/module/attribute_accessor_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/module/attribute_accessor_test.rb
new file mode 100644
index 000000000..7296cc5f8
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/module/attribute_accessor_test.rb
@@ -0,0 +1,33 @@
+require File.dirname(__FILE__) + '/../../abstract_unit'
+
+class ModuleAttributeAccessorTest < Test::Unit::TestCase
+ def setup
+ m = @module = Module.new do
+ mattr_accessor :foo
+ mattr_accessor :bar, :instance_writer => false
+ end
+ @class = Class.new
+ @class.instance_eval { include m }
+ @object = @class.new
+ end
+
+ def test_should_use_mattr_default
+ assert_nil @module.foo
+ assert_nil @object.foo
+ end
+
+ def test_should_set_mattr_value
+ @module.foo = :test
+ assert_equal :test, @object.foo
+
+ @object.foo = :test2
+ assert_equal :test2, @module.foo
+ end
+
+ def test_should_not_create_instance_writer
+ assert @module.respond_to?(:foo)
+ assert @module.respond_to?(:foo=)
+ assert @object.respond_to?(:bar)
+ assert !@object.respond_to?(:bar=)
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/module/attribute_aliasing_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/module/attribute_aliasing_test.rb
new file mode 100644
index 000000000..bd2387951
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/module/attribute_aliasing_test.rb
@@ -0,0 +1,58 @@
+require File.dirname(__FILE__) + '/../../abstract_unit'
+
+module AttributeAliasing
+ class Content
+ attr_accessor :title, :Data
+
+ def initialize
+ @title, @Data = nil, nil
+ end
+
+ def title?
+ !title.nil?
+ end
+
+ def Data?
+ !self.Data.nil?
+ end
+ end
+
+ class Email < Content
+ alias_attribute :subject, :title
+ alias_attribute :body, :Data
+ end
+end
+
+class AttributeAliasingTest < Test::Unit::TestCase
+ def test_attribute_alias
+ e = AttributeAliasing::Email.new
+
+ assert !e.subject?
+
+ e.title = "Upgrade computer"
+ assert_equal "Upgrade computer", e.subject
+ assert e.subject?
+
+ e.subject = "We got a long way to go"
+ assert_equal "We got a long way to go", e.title
+ assert e.title?
+ end
+
+ def test_aliasing_to_uppercase_attributes
+ # Although it's very un-Ruby, some people's AR-mapped tables have
+ # upper-case attributes, and when people want to alias those names
+ # to more sensible ones, everything goes *foof*.
+ e = AttributeAliasing::Email.new
+
+ assert !e.body?
+ assert !e.Data?
+
+ e.body = "No, really, this is not a joke."
+ assert_equal "No, really, this is not a joke.", e.Data
+ assert e.Data?
+
+ e.Data = "Uppercased methods are teh suck"
+ assert_equal "Uppercased methods are teh suck", e.body
+ assert e.body?
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/module_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/module_test.rb
new file mode 100644
index 000000000..fd1f99b31
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/module_test.rb
@@ -0,0 +1,293 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+module One
+ Constant1 = "Hello World"
+ Constant2 = "What's up?"
+end
+
+class Ab
+ include One
+ Constant1 = "Hello World" # Will have different object id than One::Constant1
+ Constant3 = "Goodbye World"
+end
+
+module Xy
+ class Bc
+ include One
+ end
+end
+
+module Yz
+ module Zy
+ class Cd
+ include One
+ end
+ end
+end
+
+class De
+end
+
+Somewhere = Struct.new(:street, :city)
+
+Someone = Struct.new(:name, :place) do
+ delegate :street, :city, :to => :place
+ delegate :state, :to => :@place
+ delegate :upcase, :to => "place.city"
+end
+
+class Name
+ delegate :upcase, :to => :@full_name
+
+ def initialize(first, last)
+ @full_name = "#{first} #{last}"
+ end
+end
+
+$nowhere = <<-EOF
+class Name
+ delegate :nowhere
+end
+EOF
+
+$noplace = <<-EOF
+class Name
+ delegate :noplace, :tos => :hollywood
+end
+EOF
+
+class ModuleTest < Test::Unit::TestCase
+ def test_included_in_classes
+ assert One.included_in_classes.include?(Ab)
+ assert One.included_in_classes.include?(Xy::Bc)
+ assert One.included_in_classes.include?(Yz::Zy::Cd)
+ assert !One.included_in_classes.include?(De)
+ end
+
+ def test_delegation_to_methods
+ david = Someone.new("David", Somewhere.new("Paulina", "Chicago"))
+ assert_equal "Paulina", david.street
+ assert_equal "Chicago", david.city
+ end
+
+ def test_delegation_down_hierarchy
+ david = Someone.new("David", Somewhere.new("Paulina", "Chicago"))
+ assert_equal "CHICAGO", david.upcase
+ end
+
+ def test_delegation_to_instance_variable
+ david = Name.new("David", "Hansson")
+ assert_equal "DAVID HANSSON", david.upcase
+ end
+
+ def test_missing_delegation_target
+ assert_raises(ArgumentError) { eval($nowhere) }
+ assert_raises(ArgumentError) { eval($noplace) }
+ end
+
+ def test_parent
+ assert_equal Yz::Zy, Yz::Zy::Cd.parent
+ assert_equal Yz, Yz::Zy.parent
+ assert_equal Object, Yz.parent
+ end
+
+ def test_parents
+ assert_equal [Yz::Zy, Yz, Object], Yz::Zy::Cd.parents
+ assert_equal [Yz, Object], Yz::Zy.parents
+ end
+
+ def test_local_constants
+ assert_equal %w(Constant1 Constant3), Ab.local_constants.sort.map(&:to_s)
+ end
+
+ def test_as_load_path
+ assert_equal 'yz/zy', Yz::Zy.as_load_path
+ assert_equal 'yz', Yz.as_load_path
+ end
+end
+
+module BarMethodAliaser
+ def self.included(foo_class)
+ foo_class.class_eval do
+ include BarMethods
+ alias_method_chain :bar, :baz
+ end
+ end
+end
+
+module BarMethods
+ def bar_with_baz
+ bar_without_baz << '_with_baz'
+ end
+
+ def quux_with_baz!
+ quux_without_baz! << '_with_baz'
+ end
+
+ def quux_with_baz?
+ false
+ end
+
+ def quux_with_baz=(v)
+ send(:quux_without_baz=, v) << '_with_baz'
+ end
+
+ def duck_with_orange
+ duck_without_orange << '_with_orange'
+ end
+end
+
+class MethodAliasingTest < Test::Unit::TestCase
+ def setup
+ Object.const_set :FooClassWithBarMethod, Class.new { def bar() 'bar' end }
+ @instance = FooClassWithBarMethod.new
+ end
+
+ def teardown
+ Object.instance_eval { remove_const :FooClassWithBarMethod }
+ end
+
+ def test_alias_method_chain
+ assert @instance.respond_to?(:bar)
+ feature_aliases = [:bar_with_baz, :bar_without_baz]
+
+ feature_aliases.each do |method|
+ assert !@instance.respond_to?(method)
+ end
+
+ assert_equal 'bar', @instance.bar
+
+ FooClassWithBarMethod.class_eval { include BarMethodAliaser }
+
+ feature_aliases.each do |method|
+ assert @instance.respond_to?(method)
+ end
+
+ assert_equal 'bar_with_baz', @instance.bar
+ assert_equal 'bar', @instance.bar_without_baz
+ end
+
+ def test_alias_method_chain_with_punctuation_method
+ FooClassWithBarMethod.class_eval do
+ def quux!; 'quux' end
+ end
+
+ assert !@instance.respond_to?(:quux_with_baz!)
+ FooClassWithBarMethod.class_eval do
+ include BarMethodAliaser
+ alias_method_chain :quux!, :baz
+ end
+ assert @instance.respond_to?(:quux_with_baz!)
+
+ assert_equal 'quux_with_baz', @instance.quux!
+ assert_equal 'quux', @instance.quux_without_baz!
+ end
+
+ def test_alias_method_chain_with_same_names_between_predicates_and_bang_methods
+ FooClassWithBarMethod.class_eval do
+ def quux!; 'quux!' end
+ def quux?; true end
+ def quux=(v); 'quux=' end
+ end
+
+ assert !@instance.respond_to?(:quux_with_baz!)
+ assert !@instance.respond_to?(:quux_with_baz?)
+ assert !@instance.respond_to?(:quux_with_baz=)
+
+ FooClassWithBarMethod.class_eval { include BarMethodAliaser }
+ assert @instance.respond_to?(:quux_with_baz!)
+ assert @instance.respond_to?(:quux_with_baz?)
+ assert @instance.respond_to?(:quux_with_baz=)
+
+
+ FooClassWithBarMethod.alias_method_chain :quux!, :baz
+ assert_equal 'quux!_with_baz', @instance.quux!
+ assert_equal 'quux!', @instance.quux_without_baz!
+
+ FooClassWithBarMethod.alias_method_chain :quux?, :baz
+ assert_equal false, @instance.quux?
+ assert_equal true, @instance.quux_without_baz?
+
+ FooClassWithBarMethod.alias_method_chain :quux=, :baz
+ assert_equal 'quux=_with_baz', @instance.send(:quux=, 1234)
+ assert_equal 'quux=', @instance.send(:quux_without_baz=, 1234)
+ end
+
+ def test_alias_method_chain_with_feature_punctuation
+ FooClassWithBarMethod.class_eval do
+ def quux; 'quux' end
+ def quux?; 'quux?' end
+ include BarMethodAliaser
+ alias_method_chain :quux, :baz!
+ end
+
+ assert_nothing_raised do
+ assert_equal 'quux_with_baz', @instance.quux_with_baz!
+ end
+
+ assert_raise(NameError) do
+ FooClassWithBarMethod.alias_method_chain :quux?, :baz!
+ end
+ end
+
+ def test_alias_method_chain_yields_target_and_punctuation
+ args = nil
+
+ FooClassWithBarMethod.class_eval do
+ def quux?; end
+ include BarMethods
+
+ FooClassWithBarMethod.alias_method_chain :quux?, :baz do |target, punctuation|
+ args = [target, punctuation]
+ end
+ end
+
+ assert_not_nil args
+ assert_equal 'quux', args[0]
+ assert_equal '?', args[1]
+ end
+
+ def test_alias_method_chain_preserves_private_method_status
+ FooClassWithBarMethod.class_eval do
+ def duck; 'duck' end
+ include BarMethodAliaser
+ private :duck
+ alias_method_chain :duck, :orange
+ end
+
+ assert_raises NoMethodError do
+ @instance.duck
+ end
+
+ assert_equal 'duck_with_orange', @instance.instance_eval { duck }
+ assert FooClassWithBarMethod.private_method_defined?(:duck)
+ end
+
+ def test_alias_method_chain_preserves_protected_method_status
+ FooClassWithBarMethod.class_eval do
+ def duck; 'duck' end
+ include BarMethodAliaser
+ protected :duck
+ alias_method_chain :duck, :orange
+ end
+
+ assert_raises NoMethodError do
+ @instance.duck
+ end
+
+ assert_equal 'duck_with_orange', @instance.instance_eval { duck }
+ assert FooClassWithBarMethod.protected_method_defined?(:duck)
+ end
+
+ def test_alias_method_chain_preserves_public_method_status
+ FooClassWithBarMethod.class_eval do
+ def duck; 'duck' end
+ include BarMethodAliaser
+ public :duck
+ alias_method_chain :duck, :orange
+ end
+
+ assert_equal 'duck_with_orange', @instance.duck
+ assert FooClassWithBarMethod.public_method_defined?(:duck)
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/name_error_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/name_error_test.rb
new file mode 100644
index 000000000..d03887530
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/name_error_test.rb
@@ -0,0 +1,24 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+class NameErrorTest < Test::Unit::TestCase
+ def test_name_error_should_set_missing_name
+ begin
+ SomeNameThatNobodyWillUse____Really ? 1 : 0
+ flunk "?!?!"
+ rescue NameError => exc
+ assert_equal "NameErrorTest::SomeNameThatNobodyWillUse____Really", exc.missing_name
+ assert exc.missing_name?(:SomeNameThatNobodyWillUse____Really)
+ assert exc.missing_name?("NameErrorTest::SomeNameThatNobodyWillUse____Really")
+ end
+ end
+
+ def test_missing_method_should_ignore_missing_name
+ begin
+ some_method_that_does_not_exist
+ flunk "?!?!"
+ rescue NameError => exc
+ assert_equal nil, exc.missing_name
+ assert ! exc.missing_name?(:Foo)
+ end
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/numeric_ext_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/numeric_ext_test.rb
new file mode 100644
index 000000000..a773339b2
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/numeric_ext_test.rb
@@ -0,0 +1,147 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+class NumericExtTimeAndDateTimeTest < Test::Unit::TestCase
+ def setup
+ @now = Time.now
+ @dtnow = DateTime.now
+ @seconds = {
+ 1.minute => 60,
+ 10.minutes => 600,
+ 1.hour + 15.minutes => 4500,
+ 2.days + 4.hours + 30.minutes => 189000,
+ 5.years + 1.month + 1.fortnight => 161589600
+ }
+ end
+
+ def test_units
+ @seconds.each do |actual, expected|
+ assert_equal expected, actual
+ end
+ end
+
+ def test_intervals
+ @seconds.values.each do |seconds|
+ assert_equal seconds.since(@now), @now + seconds
+ assert_equal seconds.until(@now), @now - seconds
+ end
+ end
+
+ # Test intervals based from Time.now
+ def test_now
+ @seconds.values.each do |seconds|
+ now = Time.now
+ assert seconds.ago >= now - seconds
+ now = Time.now
+ assert seconds.from_now >= now + seconds
+ end
+ end
+
+ def test_irregular_durations
+ assert_equal @now.advance(:days => 3000), 3000.days.since(@now)
+ assert_equal @now.advance(:months => 1), 1.month.since(@now)
+ assert_equal @now.advance(:months => -1), 1.month.until(@now)
+ assert_equal @now.advance(:years => 20), 20.years.since(@now)
+ assert_equal @dtnow.advance(:days => 3000), 3000.days.since(@dtnow)
+ assert_equal @dtnow.advance(:months => 1), 1.month.since(@dtnow)
+ assert_equal @dtnow.advance(:months => -1), 1.month.until(@dtnow)
+ assert_equal @dtnow.advance(:years => 20), 20.years.since(@dtnow)
+ end
+
+ def test_duration_addition
+ assert_equal @now.advance(:days => 1).advance(:months => 1), (1.day + 1.month).since(@now)
+ assert_equal @now.advance(:days => 7), (1.week + 5.seconds - 5.seconds).since(@now)
+ assert_equal @now.advance(:years => 2), (4.years - 2.years).since(@now)
+ assert_equal @dtnow.advance(:days => 1).advance(:months => 1), (1.day + 1.month).since(@dtnow)
+ assert_equal @dtnow.advance(:days => 7), (1.week + 5.seconds - 5.seconds).since(@dtnow)
+ assert_equal @dtnow.advance(:years => 2), (4.years - 2.years).since(@dtnow)
+ end
+
+ def test_time_plus_duration
+ assert_equal @now + 8, @now + 8.seconds
+ assert_equal @now + 22.9, @now + 22.9.seconds
+ assert_equal @now.advance(:days => 15), @now + 15.days
+ assert_equal @now.advance(:months => 1), @now + 1.month
+ assert_equal @dtnow.since(8), @dtnow + 8.seconds
+ assert_equal @dtnow.since(22.9), @dtnow + 22.9.seconds
+ assert_equal @dtnow.advance(:days => 15), @dtnow + 15.days
+ assert_equal @dtnow.advance(:months => 1), @dtnow + 1.month
+ end
+
+ def test_chaining_duration_operations
+ assert_equal @now.advance(:days => 2).advance(:months => -3), @now + 2.days - 3.months
+ assert_equal @now.advance(:days => 1).advance(:months => 2), @now + 1.day + 2.months
+ assert_equal @dtnow.advance(:days => 2).advance(:months => -3), @dtnow + 2.days - 3.months
+ assert_equal @dtnow.advance(:days => 1).advance(:months => 2), @dtnow + 1.day + 2.months
+ end
+
+ def test_duration_after_convertion_is_no_longer_accurate
+ assert_equal 30.days.to_i.since(@now), 1.month.to_i.since(@now)
+ assert_equal 365.25.days.to_f.since(@now), 1.year.to_f.since(@now)
+ assert_equal 30.days.to_i.since(@dtnow), 1.month.to_i.since(@dtnow)
+ assert_equal 365.25.days.to_f.since(@dtnow), 1.year.to_f.since(@dtnow)
+ end
+
+ def test_add_one_year_to_leap_day
+ assert_equal Time.utc(2005,2,28,15,15,10), Time.utc(2004,2,29,15,15,10) + 1.year
+ assert_equal DateTime.civil(2005,2,28,15,15,10), DateTime.civil(2004,2,29,15,15,10) + 1.year
+ end
+end
+
+class NumericExtDateTest < Test::Unit::TestCase
+ def setup
+ @today = Date.today
+ end
+
+ def test_date_plus_duration
+ assert_equal @today + 1, @today + 1.day
+ assert_equal @today >> 1, @today + 1.month
+ assert_equal @today.to_time.since(1), @today + 1.second
+ assert_equal @today.to_time.since(60), @today + 1.minute
+ assert_equal @today.to_time.since(60*60), @today + 1.hour
+ end
+
+ def test_chaining_duration_operations
+ assert_equal @today.advance(:days => 2).advance(:months => -3), @today + 2.days - 3.months
+ assert_equal @today.advance(:days => 1).advance(:months => 2), @today + 1.day + 2.months
+ end
+
+ def test_add_one_year_to_leap_day
+ assert_equal Date.new(2005,2,28), Date.new(2004,2,29) + 1.year
+ end
+end
+
+class NumericExtSizeTest < Test::Unit::TestCase
+ def test_unit_in_terms_of_another
+ relationships = {
+ 1024.bytes => 1.kilobyte,
+ 1024.kilobytes => 1.megabyte,
+ 3584.0.kilobytes => 3.5.megabytes,
+ 3584.0.megabytes => 3.5.gigabytes,
+ 1.kilobyte ** 4 => 1.terabyte,
+ 1024.kilobytes + 2.megabytes => 3.megabytes,
+ 2.gigabytes / 4 => 512.megabytes,
+ 256.megabytes * 20 + 5.gigabytes => 10.gigabytes,
+ 1.kilobyte ** 5 => 1.petabyte,
+ 1.kilobyte ** 6 => 1.exabyte
+ }
+
+ relationships.each do |left, right|
+ assert_equal right, left
+ end
+ end
+
+ def test_units_as_bytes_independently
+ assert_equal 3145728, 3.megabytes
+ assert_equal 3145728, 3.megabyte
+ assert_equal 3072, 3.kilobytes
+ assert_equal 3072, 3.kilobyte
+ assert_equal 3221225472, 3.gigabytes
+ assert_equal 3221225472, 3.gigabyte
+ assert_equal 3298534883328, 3.terabytes
+ assert_equal 3298534883328, 3.terabyte
+ assert_equal 3377699720527872, 3.petabytes
+ assert_equal 3377699720527872, 3.petabyte
+ assert_equal 3458764513820540928, 3.exabytes
+ assert_equal 3458764513820540928, 3.exabyte
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/object_and_class_ext_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/object_and_class_ext_test.rb
new file mode 100644
index 000000000..f885d94be
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/object_and_class_ext_test.rb
@@ -0,0 +1,242 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+class ClassA; end
+class ClassB < ClassA; end
+class ClassC < ClassB; end
+class ClassD < ClassA; end
+
+class ClassI; end
+class ClassJ < ClassI; end
+
+class ClassK
+end
+module Nested
+ class << self
+ def on_const_missing(&callback)
+ @on_const_missing = callback
+ end
+ private
+ def const_missing(mod_id)
+ @on_const_missing[mod_id] if @on_const_missing
+ super
+ end
+ end
+ class ClassL < ClassK
+ end
+end
+
+module Bar
+ def bar; end
+end
+
+module Baz
+ def baz; end
+end
+
+class Foo
+ include Bar
+end
+
+class ClassExtTest < Test::Unit::TestCase
+ def test_methods
+ assert defined?(ClassB)
+ assert defined?(ClassC)
+ assert defined?(ClassD)
+
+ ClassA.remove_subclasses
+
+ assert !defined?(ClassB)
+ assert !defined?(ClassC)
+ assert !defined?(ClassD)
+ end
+
+ def test_subclasses_of
+ cj = ClassJ
+ assert_equal [ClassJ], Object.subclasses_of(ClassI)
+ ClassI.remove_subclasses
+ assert_equal [], Object.subclasses_of(ClassI)
+ ensure
+ Object.const_set :ClassJ, cj
+ end
+
+ def test_subclasses_of_should_find_nested_classes
+ assert Object.subclasses_of(ClassK).include?(Nested::ClassL)
+ end
+
+ def test_subclasses_of_should_not_return_removed_classes
+ # First create the removed class
+ old_class = Nested.class_eval { remove_const :ClassL }
+ new_class = Class.new(ClassK)
+ Nested.const_set :ClassL, new_class
+ assert_equal "Nested::ClassL", new_class.name # Sanity check
+
+ subclasses = Object.subclasses_of(ClassK)
+ assert subclasses.include?(new_class)
+ assert ! subclasses.include?(old_class)
+ ensure
+ Nested.const_set :ClassL, old_class unless defined?(Nested::ClassL)
+ end
+
+ def test_subclasses_of_should_not_trigger_const_missing
+ const_missing = false
+ Nested.on_const_missing { const_missing = true }
+
+ subclasses = Object.subclasses_of ClassK
+ assert !const_missing
+ assert_equal [ Nested::ClassL ], subclasses
+
+ removed = Nested.class_eval { remove_const :ClassL } # keep it in memory
+ subclasses = Object.subclasses_of ClassK
+ assert !const_missing
+ assert subclasses.empty?
+ ensure
+ Nested.const_set :ClassL, removed unless defined?(Nested::ClassL)
+ end
+
+ def test_subclasses_of_with_multiple_roots
+ classes = Object.subclasses_of(ClassI, ClassK)
+ assert_equal %w(ClassJ Nested::ClassL), classes.collect(&:to_s).sort
+ end
+
+ def test_subclasses_of_doesnt_find_anonymous_classes
+ assert_equal [], Object.subclasses_of(Foo)
+ bar = Class.new(Foo)
+ assert_nothing_raised do
+ assert_equal [bar], Object.subclasses_of(Foo)
+ end
+ end
+end
+
+class ObjectTests < Test::Unit::TestCase
+ def test_send_bang_aliases_send_before_19
+ assert_respond_to 'a', :send!
+ assert_equal 1, 'a'.send!(:size)
+ end
+
+ def test_suppress_re_raises
+ assert_raises(LoadError) { suppress(ArgumentError) {raise LoadError} }
+ end
+ def test_suppress_supresses
+ suppress(ArgumentError) { raise ArgumentError }
+ suppress(LoadError) { raise LoadError }
+ suppress(LoadError, ArgumentError) { raise LoadError }
+ suppress(LoadError, ArgumentError) { raise ArgumentError }
+ end
+
+ def test_extended_by
+ foo = Foo.new
+ assert foo.extended_by.include?(Bar)
+ foo.extend(Baz)
+ assert(([Bar, Baz] - foo.extended_by).empty?, "Expected Bar, Baz in #{foo.extended_by.inspect}")
+ end
+
+ def test_extend_with_included_modules_from
+ foo, object = Foo.new, Object.new
+ assert !object.respond_to?(:bar)
+ assert !object.respond_to?(:baz)
+
+ object.extend_with_included_modules_from(foo)
+ assert object.respond_to?(:bar)
+ assert !object.respond_to?(:baz)
+
+ foo.extend(Baz)
+ object.extend_with_included_modules_from(foo)
+ assert object.respond_to?(:bar)
+ assert object.respond_to?(:baz)
+ end
+
+ class DuckTime
+ def acts_like_time?
+ true
+ end
+ end
+
+ def test_duck_typing
+ object = Object.new
+ time = Time.now
+ date = Date.today
+ dt = DateTime.new
+ duck = DuckTime.new
+
+ assert !object.acts_like?(:time)
+ assert !object.acts_like?(:date)
+
+ assert time.acts_like?(:time)
+ assert !time.acts_like?(:date)
+
+ assert !date.acts_like?(:time)
+ assert date.acts_like?(:date)
+
+ assert dt.acts_like?(:time)
+ assert dt.acts_like?(:date)
+
+ assert duck.acts_like?(:time)
+ assert !duck.acts_like?(:date)
+ end
+end
+
+class ObjectInstanceVariableTest < Test::Unit::TestCase
+ def setup
+ @source, @dest = Object.new, Object.new
+ @source.instance_variable_set(:@bar, 'bar')
+ @source.instance_variable_set(:@baz, 'baz')
+ end
+
+ def test_instance_variable_defined
+ assert @source.instance_variable_defined?('@bar')
+ assert @source.instance_variable_defined?(:@bar)
+ assert !@source.instance_variable_defined?(:@foo)
+ assert !@source.instance_variable_defined?('@foo')
+ end
+
+ def test_copy_instance_variables_from_without_explicit_excludes
+ assert_equal [], @dest.instance_variables
+ @dest.copy_instance_variables_from(@source)
+
+ assert_equal %w(@bar @baz), @dest.instance_variables.sort.map(&:to_s)
+ %w(@bar @baz).each do |name|
+ assert_equal @source.instance_variable_get(name).object_id,
+ @dest.instance_variable_get(name).object_id
+ end
+ end
+
+ def test_copy_instance_variables_from_with_explicit_excludes
+ @dest.copy_instance_variables_from(@source, ['@baz'])
+ assert !@dest.instance_variable_defined?('@baz')
+ assert_equal 'bar', @dest.instance_variable_get('@bar')
+ end
+
+ def test_copy_instance_variables_automatically_excludes_protected_instance_variables
+ @source.instance_variable_set(:@quux, 'quux')
+ class << @source
+ def protected_instance_variables
+ ['@bar', :@quux]
+ end
+ end
+
+ @dest.copy_instance_variables_from(@source)
+ assert !@dest.instance_variable_defined?('@bar')
+ assert !@dest.instance_variable_defined?('@quux')
+ assert_equal 'baz', @dest.instance_variable_get('@baz')
+ end
+
+ def test_instance_values
+ object = Object.new
+ object.instance_variable_set :@a, 1
+ object.instance_variable_set :@b, 2
+ assert_equal({'a' => 1, 'b' => 2}, object.instance_values)
+ end
+
+ def test_instance_exec_passes_arguments_to_block
+ assert_equal %w(hello goodbye), 'hello'.instance_exec('goodbye') { |v| [self, v] }
+ end
+
+ def test_instance_exec_with_frozen_obj
+ assert_equal %w(olleh goodbye), 'hello'.freeze.instance_exec('goodbye') { |v| [reverse, v] }
+ end
+
+ def test_instance_exec_nested
+ assert_equal %w(goodbye olleh bar), 'hello'.instance_exec('goodbye') { |arg|
+ [arg] + instance_exec('bar') { |v| [reverse, v] } }
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/pathname_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/pathname_test.rb
new file mode 100644
index 000000000..2933e2d61
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/pathname_test.rb
@@ -0,0 +1,9 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+class TestPathname < Test::Unit::TestCase
+ def test_clean_within
+ assert_equal "Hi", Pathname.clean_within("Hi")
+ assert_equal "Hi", Pathname.clean_within("Hi/a/b/../..")
+ assert_equal "Hello\nWorld", Pathname.clean_within("Hello/a/b/../..\na/b/../../World/c/..")
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/proc_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/proc_test.rb
new file mode 100644
index 000000000..f63cd82d2
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/proc_test.rb
@@ -0,0 +1,11 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+class ProcTests < Test::Unit::TestCase
+ def test_bind_returns_method_with_changed_self
+ block = Proc.new { self }
+ assert_equal self, block.call
+ bound_block = block.bind("hello")
+ assert_not_equal block, bound_block
+ assert_equal "hello", bound_block.call
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/range_ext_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/range_ext_test.rb
new file mode 100644
index 000000000..acb6baf43
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/range_ext_test.rb
@@ -0,0 +1,63 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+class RangeTest < Test::Unit::TestCase
+ def test_to_s_from_dates
+ date_range = Date.new(2005, 12, 10)..Date.new(2005, 12, 12)
+ assert_equal "BETWEEN '2005-12-10' AND '2005-12-12'", date_range.to_s(:db)
+ end
+
+ def test_to_s_from_times
+ date_range = Time.utc(2005, 12, 10, 15, 30)..Time.utc(2005, 12, 10, 17, 30)
+ assert_equal "BETWEEN '2005-12-10 15:30:00' AND '2005-12-10 17:30:00'", date_range.to_s(:db)
+ end
+
+ def test_overlaps_last_inclusive
+ assert((1..5).overlaps?(5..10))
+ end
+
+ def test_overlaps_last_exclusive
+ assert !(1...5).overlaps?(5..10)
+ end
+
+ def test_overlaps_first_inclusive
+ assert((5..10).overlaps?(1..5))
+ end
+
+ def test_overlaps_first_exclusive
+ assert !(5..10).overlaps?(1...5)
+ end
+
+ def test_should_include_identical_inclusive
+ assert((1..10).include?(1..10))
+ end
+
+ def test_should_include_identical_exclusive
+ assert((1...10).include?(1...10))
+ end
+
+ def test_should_include_other_with_exlusive_end
+ assert((1..10).include?(1...10))
+ end
+
+ def test_exclusive_end_should_not_include_identical_with_inclusive_end
+ assert !(1...10).include?(1..10)
+ end
+
+ def test_should_not_include_overlapping_first
+ assert !(2..8).include?(1..3)
+ end
+
+ def test_should_not_include_overlapping_last
+ assert !(2..8).include?(5..9)
+ end
+
+ def test_blockless_step
+ assert_equal [1,3,5,7,9], (1..10).step(2)
+ end
+
+ def test_original_step
+ array = []
+ (1..10).step(2) {|i| array << i }
+ assert_equal [1,3,5,7,9], array
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/string_ext_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/string_ext_test.rb
new file mode 100644
index 000000000..427e7dfc5
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/string_ext_test.rb
@@ -0,0 +1,180 @@
+require 'date'
+require File.dirname(__FILE__) + '/../abstract_unit'
+require 'inflector_test_cases'
+
+class StringInflectionsTest < Test::Unit::TestCase
+ include InflectorTestCases
+
+ def test_pluralize
+ SingularToPlural.each do |singular, plural|
+ assert_equal(plural, singular.pluralize)
+ end
+
+ assert_equal("plurals", "plurals".pluralize)
+ end
+
+ def test_singularize
+ SingularToPlural.each do |singular, plural|
+ assert_equal(singular, plural.singularize)
+ end
+ end
+
+ def test_titleize
+ MixtureToTitleCase.each do |before, titleized|
+ assert_equal(titleized, before.titleize)
+ end
+ end
+
+ def test_camelize
+ CamelToUnderscore.each do |camel, underscore|
+ assert_equal(camel, underscore.camelize)
+ end
+ end
+
+ def test_underscore
+ CamelToUnderscore.each do |camel, underscore|
+ assert_equal(underscore, camel.underscore)
+ end
+
+ assert_equal "html_tidy", "HTMLTidy".underscore
+ assert_equal "html_tidy_generator", "HTMLTidyGenerator".underscore
+ end
+
+ def test_underscore_to_lower_camel
+ UnderscoreToLowerCamel.each do |underscored, lower_camel|
+ assert_equal(lower_camel, underscored.camelize(:lower))
+ end
+ end
+
+ def test_demodulize
+ assert_equal "Account", "MyApplication::Billing::Account".demodulize
+ end
+
+ def test_foreign_key
+ ClassNameToForeignKeyWithUnderscore.each do |klass, foreign_key|
+ assert_equal(foreign_key, klass.foreign_key)
+ end
+
+ ClassNameToForeignKeyWithoutUnderscore.each do |klass, foreign_key|
+ assert_equal(foreign_key, klass.foreign_key(false))
+ end
+ end
+
+ def test_tableize
+ ClassNameToTableName.each do |class_name, table_name|
+ assert_equal(table_name, class_name.tableize)
+ end
+ end
+
+ def test_classify
+ ClassNameToTableName.each do |class_name, table_name|
+ assert_equal(class_name, table_name.classify)
+ end
+ end
+
+ def test_humanize
+ UnderscoreToHuman.each do |underscore, human|
+ assert_equal(human, underscore.humanize)
+ end
+ end
+
+ def test_ord
+ assert_equal 97, 'a'.ord
+ assert_equal 97, 'abc'.ord
+ end
+
+ def test_string_to_time
+ assert_equal Time.utc(2005, 2, 27, 23, 50), "2005-02-27 23:50".to_time
+ assert_equal Time.local(2005, 2, 27, 23, 50), "2005-02-27 23:50".to_time(:local)
+ assert_equal DateTime.civil(2039, 2, 27, 23, 50), "2039-02-27 23:50".to_time
+ assert_equal Time.local_time(2039, 2, 27, 23, 50), "2039-02-27 23:50".to_time(:local)
+ end
+
+ def test_string_to_datetime
+ assert_equal DateTime.civil(2039, 2, 27, 23, 50), "2039-02-27 23:50".to_datetime
+ assert_equal 0, "2039-02-27 23:50".to_datetime.offset # use UTC offset
+ assert_equal ::Date::ITALY, "2039-02-27 23:50".to_datetime.start # use Ruby's default start value
+ end
+
+ def test_string_to_date
+ assert_equal Date.new(2005, 2, 27), "2005-02-27".to_date
+ end
+
+ def test_access
+ s = "hello"
+ assert_equal "h", s.at(0)
+
+ assert_equal "llo", s.from(2)
+ assert_equal "hel", s.to(2)
+
+ assert_equal "h", s.first
+ assert_equal "he", s.first(2)
+
+ assert_equal "o", s.last
+ assert_equal "llo", s.last(3)
+ assert_equal "hello", s.last(10)
+
+ assert_equal 'x', 'x'.first
+ assert_equal 'x', 'x'.first(4)
+
+ assert_equal 'x', 'x'.last
+ assert_equal 'x', 'x'.last(4)
+ end
+
+ def test_access_returns_a_real_string
+ hash = {}
+ hash["h"] = true
+ hash["hello123".at(0)] = true
+ assert_equal %w(h), hash.keys
+
+ hash = {}
+ hash["llo"] = true
+ hash["hello".from(2)] = true
+ assert_equal %w(llo), hash.keys
+
+ hash = {}
+ hash["hel"] = true
+ hash["hello".to(2)] = true
+ assert_equal %w(hel), hash.keys
+
+ hash = {}
+ hash["hello"] = true
+ hash["123hello".last(5)] = true
+ assert_equal %w(hello), hash.keys
+
+ hash = {}
+ hash["hello"] = true
+ hash["hello123".first(5)] = true
+ assert_equal %w(hello), hash.keys
+ end
+
+ def test_starts_ends_with_alias
+ s = "hello"
+ assert s.starts_with?('h')
+ assert s.starts_with?('hel')
+ assert !s.starts_with?('el')
+
+ assert s.start_with?('h')
+ assert s.start_with?('hel')
+ assert !s.start_with?('el')
+
+ assert s.ends_with?('o')
+ assert s.ends_with?('lo')
+ assert !s.ends_with?('el')
+
+ assert s.end_with?('o')
+ assert s.end_with?('lo')
+ assert !s.end_with?('el')
+ end
+
+ # FIXME: Ruby 1.9
+ def test_each_char_with_utf8_string_when_kcode_is_utf8
+ old_kcode, $KCODE = $KCODE, 'UTF8'
+ '€2.99'.each_char do |char|
+ assert_not_equal 1, char.length
+ break
+ end
+ ensure
+ $KCODE = old_kcode
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/symbol_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/symbol_test.rb
new file mode 100644
index 000000000..943133496
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/symbol_test.rb
@@ -0,0 +1,9 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+class SymbolTests < Test::Unit::TestCase
+ def test_to_proc
+ assert_equal %w(one two three), [:one, :two, :three].map(&:to_s)
+ assert_equal(%w(one two three),
+ {1 => "one", 2 => "two", 3 => "three"}.sort_by(&:first).map(&:last))
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/core_ext/time_ext_test.rb b/vendor/rails-2.0.2/activesupport/test/core_ext/time_ext_test.rb
new file mode 100644
index 000000000..c0bd12d2a
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/core_ext/time_ext_test.rb
@@ -0,0 +1,420 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+class TimeExtCalculationsTest < Test::Unit::TestCase
+ def test_seconds_since_midnight
+ assert_equal 1,Time.local(2005,1,1,0,0,1).seconds_since_midnight
+ assert_equal 60,Time.local(2005,1,1,0,1,0).seconds_since_midnight
+ assert_equal 3660,Time.local(2005,1,1,1,1,0).seconds_since_midnight
+ assert_equal 86399,Time.local(2005,1,1,23,59,59).seconds_since_midnight
+ assert_equal 60.00001,Time.local(2005,1,1,0,1,0,10).seconds_since_midnight
+ end
+
+ def test_seconds_since_midnight_at_daylight_savings_time_start
+ with_timezone 'US/Eastern' do
+ # dt: US: 2005 April 3rd 2:00am ST => April 3rd 3:00am DT
+ assert_equal 2*3600-1, Time.local(2005,4,3,1,59,59).seconds_since_midnight, 'just before DST start'
+ assert_equal 2*3600+1, Time.local(2005,4,3,3, 0, 1).seconds_since_midnight, 'just after DST start'
+ end
+
+ with_timezone 'NZ' do
+ # dt: New Zealand: 2006 October 1st 2:00am ST => October 1st 3:00am DT
+ assert_equal 2*3600-1, Time.local(2006,10,1,1,59,59).seconds_since_midnight, 'just before DST start'
+ assert_equal 2*3600+1, Time.local(2006,10,1,3, 0, 1).seconds_since_midnight, 'just after DST start'
+ end
+ end
+
+ def test_seconds_since_midnight_at_daylight_savings_time_end
+ with_timezone 'US/Eastern' do
+ # st: US: 2005 October 30th 2:00am DT => October 30th 1:00am ST
+ # avoid setting a time between 1:00 and 2:00 since that requires specifying whether DST is active
+ assert_equal 1*3600-1, Time.local(2005,10,30,0,59,59).seconds_since_midnight, 'just before DST end'
+ assert_equal 3*3600+1, Time.local(2005,10,30,2, 0, 1).seconds_since_midnight, 'just after DST end'
+
+ # now set a time between 1:00 and 2:00 by specifying whether DST is active
+ # uses: Time.local( sec, min, hour, day, month, year, wday, yday, isdst, tz )
+ assert_equal 1*3600+30*60, Time.local(0,30,1,30,10,2005,0,0,true,ENV['TZ']).seconds_since_midnight, 'before DST end'
+ assert_equal 2*3600+30*60, Time.local(0,30,1,30,10,2005,0,0,false,ENV['TZ']).seconds_since_midnight, 'after DST end'
+ end
+
+ with_timezone 'NZ' do
+ # st: New Zealand: 2006 March 19th 3:00am DT => March 19th 2:00am ST
+ # avoid setting a time between 2:00 and 3:00 since that requires specifying whether DST is active
+ assert_equal 2*3600-1, Time.local(2006,3,19,1,59,59).seconds_since_midnight, 'just before DST end'
+ assert_equal 4*3600+1, Time.local(2006,3,19,3, 0, 1).seconds_since_midnight, 'just after DST end'
+
+ # now set a time between 2:00 and 3:00 by specifying whether DST is active
+ # uses: Time.local( sec, min, hour, day, month, year, wday, yday, isdst, tz )
+ assert_equal 2*3600+30*60, Time.local(0,30,2,19,3,2006,0,0,true, ENV['TZ']).seconds_since_midnight, 'before DST end'
+ assert_equal 3*3600+30*60, Time.local(0,30,2,19,3,2006,0,0,false,ENV['TZ']).seconds_since_midnight, 'after DST end'
+ end
+ end
+
+ def test_beginning_of_week
+ assert_equal Time.local(2005,1,31), Time.local(2005,2,4,10,10,10).beginning_of_week
+ assert_equal Time.local(2005,11,28), Time.local(2005,11,28,0,0,0).beginning_of_week #monday
+ assert_equal Time.local(2005,11,28), Time.local(2005,11,29,0,0,0).beginning_of_week #tuesday
+ assert_equal Time.local(2005,11,28), Time.local(2005,11,30,0,0,0).beginning_of_week #wednesday
+ assert_equal Time.local(2005,11,28), Time.local(2005,12,01,0,0,0).beginning_of_week #thursday
+ assert_equal Time.local(2005,11,28), Time.local(2005,12,02,0,0,0).beginning_of_week #friday
+ assert_equal Time.local(2005,11,28), Time.local(2005,12,03,0,0,0).beginning_of_week #saturday
+ assert_equal Time.local(2005,11,28), Time.local(2005,12,04,0,0,0).beginning_of_week #sunday
+ end
+
+ def test_beginning_of_day
+ assert_equal Time.local(2005,2,4,0,0,0), Time.local(2005,2,4,10,10,10).beginning_of_day
+ with_timezone 'US/Eastern' do
+ assert_equal Time.local(2006,4,2,0,0,0), Time.local(2006,4,2,10,10,10).beginning_of_day, 'start DST'
+ assert_equal Time.local(2006,10,29,0,0,0), Time.local(2006,10,29,10,10,10).beginning_of_day, 'ends DST'
+ end
+ with_timezone 'NZ' do
+ assert_equal Time.local(2006,3,19,0,0,0), Time.local(2006,3,19,10,10,10).beginning_of_day, 'ends DST'
+ assert_equal Time.local(2006,10,1,0,0,0), Time.local(2006,10,1,10,10,10).beginning_of_day, 'start DST'
+ end
+ end
+
+ def test_beginning_of_month
+ assert_equal Time.local(2005,2,1,0,0,0), Time.local(2005,2,22,10,10,10).beginning_of_month
+ end
+
+ def test_beginning_of_quarter
+ assert_equal Time.local(2005,1,1,0,0,0), Time.local(2005,2,15,10,10,10).beginning_of_quarter
+ assert_equal Time.local(2005,1,1,0,0,0), Time.local(2005,1,1,0,0,0).beginning_of_quarter
+ assert_equal Time.local(2005,10,1,0,0,0), Time.local(2005,12,31,10,10,10).beginning_of_quarter
+ assert_equal Time.local(2005,4,1,0,0,0), Time.local(2005,6,30,23,59,59).beginning_of_quarter
+ end
+
+ def test_end_of_month
+ assert_equal Time.local(2005,3,31,23,59,59), Time.local(2005,3,20,10,10,10).end_of_month
+ assert_equal Time.local(2005,2,28,23,59,59), Time.local(2005,2,20,10,10,10).end_of_month
+ assert_equal Time.local(2005,4,30,23,59,59), Time.local(2005,4,20,10,10,10).end_of_month
+ end
+
+ def test_beginning_of_year
+ assert_equal Time.local(2005,1,1,0,0,0), Time.local(2005,2,22,10,10,10).beginning_of_year
+ end
+
+ def test_months_ago
+ assert_equal Time.local(2005,5,5,10), Time.local(2005,6,5,10,0,0).months_ago(1)
+ assert_equal Time.local(2004,11,5,10), Time.local(2005,6,5,10,0,0).months_ago(7)
+ assert_equal Time.local(2004,12,5,10), Time.local(2005,6,5,10,0,0).months_ago(6)
+ assert_equal Time.local(2004,6,5,10), Time.local(2005,6,5,10,0,0).months_ago(12)
+ assert_equal Time.local(2003,6,5,10), Time.local(2005,6,5,10,0,0).months_ago(24)
+ end
+
+ def test_months_since
+ assert_equal Time.local(2005,7,5,10), Time.local(2005,6,5,10,0,0).months_since(1)
+ assert_equal Time.local(2006,1,5,10), Time.local(2005,12,5,10,0,0).months_since(1)
+ assert_equal Time.local(2005,12,5,10), Time.local(2005,6,5,10,0,0).months_since(6)
+ assert_equal Time.local(2006,6,5,10), Time.local(2005,12,5,10,0,0).months_since(6)
+ assert_equal Time.local(2006,1,5,10), Time.local(2005,6,5,10,0,0).months_since(7)
+ assert_equal Time.local(2006,6,5,10), Time.local(2005,6,5,10,0,0).months_since(12)
+ assert_equal Time.local(2007,6,5,10), Time.local(2005,6,5,10,0,0).months_since(24)
+ assert_equal Time.local(2005,4,30,10), Time.local(2005,3,31,10,0,0).months_since(1)
+ assert_equal Time.local(2005,2,28,10), Time.local(2005,1,29,10,0,0).months_since(1)
+ assert_equal Time.local(2005,2,28,10), Time.local(2005,1,30,10,0,0).months_since(1)
+ assert_equal Time.local(2005,2,28,10), Time.local(2005,1,31,10,0,0).months_since(1)
+ end
+
+ def test_years_ago
+ assert_equal Time.local(2004,6,5,10), Time.local(2005,6,5,10,0,0).years_ago(1)
+ assert_equal Time.local(1998,6,5,10), Time.local(2005,6,5,10,0,0).years_ago(7)
+ assert_equal Time.local(2003,2,28,10), Time.local(2004,2,29,10,0,0).years_ago(1) # 1 year ago from leap day
+ end
+
+ def test_years_since
+ assert_equal Time.local(2006,6,5,10), Time.local(2005,6,5,10,0,0).years_since(1)
+ assert_equal Time.local(2012,6,5,10), Time.local(2005,6,5,10,0,0).years_since(7)
+ assert_equal Time.local(2005,2,28,10), Time.local(2004,2,29,10,0,0).years_since(1) # 1 year since leap day
+ # Failure because of size limitations of numeric?
+ # assert_equal Time.local(2182,6,5,10), Time.local(2005,6,5,10,0,0).years_since(177)
+ end
+
+ def test_last_year
+ assert_equal Time.local(2004,6,5,10), Time.local(2005,6,5,10,0,0).last_year
+ end
+
+ def test_next_year
+ assert_equal Time.local(2006,6,5,10), Time.local(2005,6,5,10,0,0).next_year
+ end
+
+ def test_ago
+ assert_equal Time.local(2005,2,22,10,10,9), Time.local(2005,2,22,10,10,10).ago(1)
+ assert_equal Time.local(2005,2,22,9,10,10), Time.local(2005,2,22,10,10,10).ago(3600)
+ assert_equal Time.local(2005,2,20,10,10,10), Time.local(2005,2,22,10,10,10).ago(86400*2)
+ assert_equal Time.local(2005,2,20,9,9,45), Time.local(2005,2,22,10,10,10).ago(86400*2 + 3600 + 25)
+ end
+
+ def test_daylight_savings_time_crossings_backward_start
+ with_timezone 'US/Eastern' do
+ # dt: US: 2005 April 3rd 4:18am
+ assert_equal Time.local(2005,4,2,4,18,0), Time.local(2005,4,3,4,18,0).ago(86400), 'dt-1.day=>st'
+ assert_equal Time.local(2005,4,1,4,18,0), Time.local(2005,4,2,4,18,0).ago(86400), 'st-1.day=>st'
+ end
+ with_timezone 'NZ' do
+ # dt: New Zealand: 2006 October 1st 4:18am
+ assert_equal Time.local(2006,9,30,4,18,0), Time.local(2006,10,1,4,18,0).ago(86400), 'dt-1.day=>st'
+ assert_equal Time.local(2006,9,29,4,18,0), Time.local(2006,9,30,4,18,0).ago(86400), 'st-1.day=>st'
+ end
+ end
+
+ def test_daylight_savings_time_crossings_backward_end
+ with_timezone 'US/Eastern' do
+ # st: US: 2005 October 30th 4:03am
+ assert_equal Time.local(2005,10,29,4,3), Time.local(2005,10,30,4,3,0).ago(86400), 'st-1.day=>dt'
+ assert_equal Time.local(2005,10,28,4,3), Time.local(2005,10,29,4,3,0).ago(86400), 'dt-1.day=>dt'
+ end
+ with_timezone 'NZ' do
+ # st: New Zealand: 2006 March 19th 4:03am
+ assert_equal Time.local(2006,3,18,4,3), Time.local(2006,3,19,4,3,0).ago(86400), 'st-1.day=>dt'
+ assert_equal Time.local(2006,3,17,4,3), Time.local(2006,3,18,4,3,0).ago(86400), 'dt-1.day=>dt'
+ end
+ end
+
+ def test_since
+ assert_equal Time.local(2005,2,22,10,10,11), Time.local(2005,2,22,10,10,10).since(1)
+ assert_equal Time.local(2005,2,22,11,10,10), Time.local(2005,2,22,10,10,10).since(3600)
+ assert_equal Time.local(2005,2,24,10,10,10), Time.local(2005,2,22,10,10,10).since(86400*2)
+ assert_equal Time.local(2005,2,24,11,10,35), Time.local(2005,2,22,10,10,10).since(86400*2 + 3600 + 25)
+ # when out of range of Time, returns a DateTime
+ assert_equal DateTime.civil(2038,1,20,11,59,59), Time.utc(2038,1,18,11,59,59).since(86400*2)
+ end
+
+ def test_daylight_savings_time_crossings_forward_start
+ with_timezone 'US/Eastern' do
+ # st: US: 2005 April 2nd 7:27pm
+ assert_equal Time.local(2005,4,3,19,27,0), Time.local(2005,4,2,19,27,0).since(86400), 'st+1.day=>dt'
+ assert_equal Time.local(2005,4,4,19,27,0), Time.local(2005,4,3,19,27,0).since(86400), 'dt+1.day=>dt'
+ end
+ with_timezone 'NZ' do
+ # st: New Zealand: 2006 September 30th 7:27pm
+ assert_equal Time.local(2006,10,1,19,27,0), Time.local(2006,9,30,19,27,0).since(86400), 'st+1.day=>dt'
+ assert_equal Time.local(2006,10,2,19,27,0), Time.local(2006,10,1,19,27,0).since(86400), 'dt+1.day=>dt'
+ end
+ end
+
+ def test_daylight_savings_time_crossings_forward_end
+ with_timezone 'US/Eastern' do
+ # dt: US: 2005 October 30th 12:45am
+ assert_equal Time.local(2005,10,31,0,45,0), Time.local(2005,10,30,0,45,0).since(86400), 'dt+1.day=>st'
+ assert_equal Time.local(2005,11, 1,0,45,0), Time.local(2005,10,31,0,45,0).since(86400), 'st+1.day=>st'
+ end
+ with_timezone 'NZ' do
+ # dt: New Zealand: 2006 March 19th 1:45am
+ assert_equal Time.local(2006,3,20,1,45,0), Time.local(2006,3,19,1,45,0).since(86400), 'dt+1.day=>st'
+ assert_equal Time.local(2006,3,21,1,45,0), Time.local(2006,3,20,1,45,0).since(86400), 'st+1.day=>st'
+ end
+ end
+
+ def test_yesterday
+ assert_equal Time.local(2005,2,21,10,10,10), Time.local(2005,2,22,10,10,10).yesterday
+ assert_equal Time.local(2005,2,28,10,10,10), Time.local(2005,3,2,10,10,10).yesterday.yesterday
+ end
+
+ def test_tomorrow
+ assert_equal Time.local(2005,2,23,10,10,10), Time.local(2005,2,22,10,10,10).tomorrow
+ assert_equal Time.local(2005,3,2,10,10,10), Time.local(2005,2,28,10,10,10).tomorrow.tomorrow
+ end
+
+ def test_change
+ assert_equal Time.local(2006,2,22,15,15,10), Time.local(2005,2,22,15,15,10).change(:year => 2006)
+ assert_equal Time.local(2005,6,22,15,15,10), Time.local(2005,2,22,15,15,10).change(:month => 6)
+ assert_equal Time.local(2012,9,22,15,15,10), Time.local(2005,2,22,15,15,10).change(:year => 2012, :month => 9)
+ assert_equal Time.local(2005,2,22,16), Time.local(2005,2,22,15,15,10).change(:hour => 16)
+ assert_equal Time.local(2005,2,22,16,45), Time.local(2005,2,22,15,15,10).change(:hour => 16, :min => 45)
+ assert_equal Time.local(2005,2,22,15,45), Time.local(2005,2,22,15,15,10).change(:min => 45)
+
+ assert_equal Time.local(2005,1,2, 5, 0, 0, 0), Time.local(2005,1,2,11,22,33,44).change(:hour => 5)
+ assert_equal Time.local(2005,1,2,11, 6, 0, 0), Time.local(2005,1,2,11,22,33,44).change(:min => 6)
+ assert_equal Time.local(2005,1,2,11,22, 7, 0), Time.local(2005,1,2,11,22,33,44).change(:sec => 7)
+ assert_equal Time.local(2005,1,2,11,22,33, 8), Time.local(2005,1,2,11,22,33,44).change(:usec => 8)
+ end
+
+ def test_utc_change
+ assert_equal Time.utc(2006,2,22,15,15,10), Time.utc(2005,2,22,15,15,10).change(:year => 2006)
+ assert_equal Time.utc(2005,6,22,15,15,10), Time.utc(2005,2,22,15,15,10).change(:month => 6)
+ assert_equal Time.utc(2012,9,22,15,15,10), Time.utc(2005,2,22,15,15,10).change(:year => 2012, :month => 9)
+ assert_equal Time.utc(2005,2,22,16), Time.utc(2005,2,22,15,15,10).change(:hour => 16)
+ assert_equal Time.utc(2005,2,22,16,45), Time.utc(2005,2,22,15,15,10).change(:hour => 16, :min => 45)
+ assert_equal Time.utc(2005,2,22,15,45), Time.utc(2005,2,22,15,15,10).change(:min => 45)
+ end
+
+ def test_advance
+ assert_equal Time.local(2006,2,28,15,15,10), Time.local(2005,2,28,15,15,10).advance(:years => 1)
+ assert_equal Time.local(2005,6,28,15,15,10), Time.local(2005,2,28,15,15,10).advance(:months => 4)
+ assert_equal Time.local(2005,3,21,15,15,10), Time.local(2005,2,28,15,15,10).advance(:weeks => 3)
+ assert_equal Time.local(2005,3,5,15,15,10), Time.local(2005,2,28,15,15,10).advance(:days => 5)
+ assert_equal Time.local(2012,9,28,15,15,10), Time.local(2005,2,28,15,15,10).advance(:years => 7, :months => 7)
+ assert_equal Time.local(2013,10,3,15,15,10), Time.local(2005,2,28,15,15,10).advance(:years => 7, :months => 19, :days => 5)
+ assert_equal Time.local(2013,10,17,15,15,10), Time.local(2005,2,28,15,15,10).advance(:years => 7, :months => 19, :weeks => 2, :days => 5)
+ assert_equal Time.local(2001,12,27,15,15,10), Time.local(2005,2,28,15,15,10).advance(:years => -3, :months => -2, :days => -1)
+ assert_equal Time.local(2005,2,28,15,15,10), Time.local(2004,2,29,15,15,10).advance(:years => 1) #leap day plus one year
+ assert_equal Time.local(2005,2,28,20,15,10), Time.local(2005,2,28,15,15,10).advance(:hours => 5)
+ assert_equal Time.local(2005,2,28,15,22,10), Time.local(2005,2,28,15,15,10).advance(:minutes => 7)
+ assert_equal Time.local(2005,2,28,15,15,19), Time.local(2005,2,28,15,15,10).advance(:seconds => 9)
+ assert_equal Time.local(2005,2,28,20,22,19), Time.local(2005,2,28,15,15,10).advance(:hours => 5, :minutes => 7, :seconds => 9)
+ assert_equal Time.local(2005,2,28,10,8,1), Time.local(2005,2,28,15,15,10).advance(:hours => -5, :minutes => -7, :seconds => -9)
+ assert_equal Time.local(2013,10,17,20,22,19), Time.local(2005,2,28,15,15,10).advance(:years => 7, :months => 19, :weeks => 2, :days => 5, :hours => 5, :minutes => 7, :seconds => 9)
+ end
+
+ def test_utc_advance
+ assert_equal Time.utc(2006,2,22,15,15,10), Time.utc(2005,2,22,15,15,10).advance(:years => 1)
+ assert_equal Time.utc(2005,6,22,15,15,10), Time.utc(2005,2,22,15,15,10).advance(:months => 4)
+ assert_equal Time.utc(2005,3,21,15,15,10), Time.utc(2005,2,28,15,15,10).advance(:weeks => 3)
+ assert_equal Time.utc(2005,3,5,15,15,10), Time.utc(2005,2,28,15,15,10).advance(:days => 5)
+ assert_equal Time.utc(2012,9,22,15,15,10), Time.utc(2005,2,22,15,15,10).advance(:years => 7, :months => 7)
+ assert_equal Time.utc(2013,10,3,15,15,10), Time.utc(2005,2,22,15,15,10).advance(:years => 7, :months => 19, :days => 11)
+ assert_equal Time.utc(2013,10,17,15,15,10), Time.utc(2005,2,28,15,15,10).advance(:years => 7, :months => 19, :weeks => 2, :days => 5)
+ assert_equal Time.utc(2001,12,27,15,15,10), Time.utc(2005,2,28,15,15,10).advance(:years => -3, :months => -2, :days => -1)
+ assert_equal Time.utc(2005,2,28,15,15,10), Time.utc(2004,2,29,15,15,10).advance(:years => 1) #leap day plus one year
+ assert_equal Time.utc(2005,2,28,20,15,10), Time.utc(2005,2,28,15,15,10).advance(:hours => 5)
+ assert_equal Time.utc(2005,2,28,15,22,10), Time.utc(2005,2,28,15,15,10).advance(:minutes => 7)
+ assert_equal Time.utc(2005,2,28,15,15,19), Time.utc(2005,2,28,15,15,10).advance(:seconds => 9)
+ assert_equal Time.utc(2005,2,28,20,22,19), Time.utc(2005,2,28,15,15,10).advance(:hours => 5, :minutes => 7, :seconds => 9)
+ assert_equal Time.utc(2005,2,28,10,8,1), Time.utc(2005,2,28,15,15,10).advance(:hours => -5, :minutes => -7, :seconds => -9)
+ assert_equal Time.utc(2013,10,17,20,22,19), Time.utc(2005,2,28,15,15,10).advance(:years => 7, :months => 19, :weeks => 2, :days => 5, :hours => 5, :minutes => 7, :seconds => 9)
+ end
+
+ def test_next_week
+ with_timezone 'US/Eastern' do
+ assert_equal Time.local(2005,2,28), Time.local(2005,2,22,15,15,10).next_week
+ assert_equal Time.local(2005,2,29), Time.local(2005,2,22,15,15,10).next_week(:tuesday)
+ assert_equal Time.local(2005,3,4), Time.local(2005,2,22,15,15,10).next_week(:friday)
+ assert_equal Time.local(2006,10,30), Time.local(2006,10,23,0,0,0).next_week
+ assert_equal Time.local(2006,11,1), Time.local(2006,10,23,0,0,0).next_week(:wednesday)
+ end
+ end
+
+ def test_next_week_near_daylight_start
+ with_timezone 'US/Eastern' do
+ assert_equal Time.local(2006,4,3), Time.local(2006,4,2,23,1,0).next_week, 'just crossed standard => daylight'
+ end
+ with_timezone 'NZ' do
+ assert_equal Time.local(2006,10,2), Time.local(2006,10,1,23,1,0).next_week, 'just crossed standard => daylight'
+ end
+ end
+
+ def test_next_week_near_daylight_end
+ with_timezone 'US/Eastern' do
+ assert_equal Time.local(2006,10,30), Time.local(2006,10,29,23,1,0).next_week, 'just crossed daylight => standard'
+ end
+ with_timezone 'NZ' do
+ assert_equal Time.local(2006,3,20), Time.local(2006,3,19,23,1,0).next_week, 'just crossed daylight => standard'
+ end
+ end
+
+ def test_to_s
+ time = Time.utc(2005, 2, 21, 17, 44, 30)
+ assert_equal time.to_default_s, time.to_s
+ assert_equal time.to_default_s, time.to_s(:doesnt_exist)
+ assert_equal "2005-02-21 17:44:30", time.to_s(:db)
+ assert_equal "21 Feb 17:44", time.to_s(:short)
+ assert_equal "17:44", time.to_s(:time)
+ assert_equal "February 21, 2005 17:44", time.to_s(:long)
+ assert_equal "February 21st, 2005 17:44", time.to_s(:long_ordinal)
+ with_timezone "UTC" do
+ assert_equal "Mon, 21 Feb 2005 17:44:30 +0000", time.to_s(:rfc822)
+ end
+ end
+
+ def test_custom_date_format
+ Time::DATE_FORMATS[:custom] = '%Y%m%d%H%M%S'
+ assert_equal '20050221143000', Time.local(2005, 2, 21, 14, 30, 0).to_s(:custom)
+ Time::DATE_FORMATS.delete(:custom)
+ end
+
+ def test_to_date
+ assert_equal Date.new(2005, 2, 21), Time.local(2005, 2, 21, 17, 44, 30).to_date
+ end
+
+ def test_to_datetime
+ assert_equal Time.utc(2005, 2, 21, 17, 44, 30).to_datetime, DateTime.civil(2005, 2, 21, 17, 44, 30, 0, 0)
+ with_timezone 'US/Eastern' do
+ assert_equal Time.local(2005, 2, 21, 17, 44, 30).to_datetime, DateTime.civil(2005, 2, 21, 17, 44, 30, Rational(Time.local(2005, 2, 21, 17, 44, 30).utc_offset, 86400), 0)
+ end
+ with_timezone 'NZ' do
+ assert_equal Time.local(2005, 2, 21, 17, 44, 30).to_datetime, DateTime.civil(2005, 2, 21, 17, 44, 30, Rational(Time.local(2005, 2, 21, 17, 44, 30).utc_offset, 86400), 0)
+ end
+ assert_equal ::Date::ITALY, Time.utc(2005, 2, 21, 17, 44, 30).to_datetime.start # use Ruby's default start value
+ end
+
+ def test_to_time
+ assert_equal Time.local(2005, 2, 21, 17, 44, 30), Time.local(2005, 2, 21, 17, 44, 30).to_time
+ end
+
+ # NOTE: this test seems to fail (changeset 1958) only on certain platforms,
+ # like OSX, and FreeBSD 5.4.
+ def test_fp_inaccuracy_ticket_1836
+ midnight = Time.local(2005, 2, 21, 0, 0, 0)
+ assert_equal midnight.midnight, (midnight + 1.hour + 0.000001).midnight
+ end
+
+ def test_days_in_month
+ assert_equal 31, Time.days_in_month(1, 2005)
+
+ assert_equal 28, Time.days_in_month(2, 2005)
+ assert_equal 29, Time.days_in_month(2, 2004)
+ assert_equal 29, Time.days_in_month(2, 2000)
+ assert_equal 28, Time.days_in_month(2, 1900)
+
+ assert_equal 31, Time.days_in_month(3, 2005)
+ assert_equal 30, Time.days_in_month(4, 2005)
+ assert_equal 31, Time.days_in_month(5, 2005)
+ assert_equal 30, Time.days_in_month(6, 2005)
+ assert_equal 31, Time.days_in_month(7, 2005)
+ assert_equal 31, Time.days_in_month(8, 2005)
+ assert_equal 30, Time.days_in_month(9, 2005)
+ assert_equal 31, Time.days_in_month(10, 2005)
+ assert_equal 30, Time.days_in_month(11, 2005)
+ assert_equal 31, Time.days_in_month(12, 2005)
+ end
+
+ def test_time_with_datetime_fallback
+ assert_equal Time.time_with_datetime_fallback(:utc, 2005, 2, 21, 17, 44, 30), Time.utc(2005, 2, 21, 17, 44, 30)
+ assert_equal Time.time_with_datetime_fallback(:local, 2005, 2, 21, 17, 44, 30), Time.local(2005, 2, 21, 17, 44, 30)
+ assert_equal Time.time_with_datetime_fallback(:utc, 2039, 2, 21, 17, 44, 30), DateTime.civil(2039, 2, 21, 17, 44, 30, 0, 0)
+ assert_equal Time.time_with_datetime_fallback(:local, 2039, 2, 21, 17, 44, 30), DateTime.civil(2039, 2, 21, 17, 44, 30, DateTime.now.offset, 0)
+ assert_equal Time.time_with_datetime_fallback(:utc, 1900, 2, 21, 17, 44, 30), DateTime.civil(1900, 2, 21, 17, 44, 30, 0, 0)
+ assert_equal Time.time_with_datetime_fallback(:local, 1900, 2, 21, 17, 44, 30), DateTime.civil(1900, 2, 21, 17, 44, 30, DateTime.now.offset, 0)
+ assert_equal Time.time_with_datetime_fallback(:utc, 2005), Time.utc(2005)
+ assert_equal Time.time_with_datetime_fallback(:utc, 2039), DateTime.civil(2039, 1, 1, 0, 0, 0, 0, 0)
+ assert_equal Time.time_with_datetime_fallback(:utc, 2005, 2, 21, 17, 44, 30, 1), Time.utc(2005, 2, 21, 17, 44, 30, 1) #with usec
+ assert_equal Time.time_with_datetime_fallback(:utc, 2039, 2, 21, 17, 44, 30, 1), DateTime.civil(2039, 2, 21, 17, 44, 30, 0, 0)
+ assert_equal ::Date::ITALY, Time.time_with_datetime_fallback(:utc, 2039, 2, 21, 17, 44, 30, 1).start # use Ruby's default start value
+ end
+
+ def test_utc_time
+ assert_equal Time.utc_time(2005, 2, 21, 17, 44, 30), Time.utc(2005, 2, 21, 17, 44, 30)
+ assert_equal Time.utc_time(2039, 2, 21, 17, 44, 30), DateTime.civil(2039, 2, 21, 17, 44, 30, 0, 0)
+ assert_equal Time.utc_time(1901, 2, 21, 17, 44, 30), DateTime.civil(1901, 2, 21, 17, 44, 30, 0, 0)
+ end
+
+ def test_local_time
+ assert_equal Time.local_time(2005, 2, 21, 17, 44, 30), Time.local(2005, 2, 21, 17, 44, 30)
+ assert_equal Time.local_time(2039, 2, 21, 17, 44, 30), DateTime.civil(2039, 2, 21, 17, 44, 30, DateTime.local_offset, 0)
+ assert_equal Time.local_time(1901, 2, 21, 17, 44, 30), DateTime.civil(1901, 2, 21, 17, 44, 30, DateTime.local_offset, 0)
+ end
+
+ def test_next_month_on_31st
+ assert_equal Time.local(2005, 9, 30), Time.local(2005, 8, 31).next_month
+ end
+
+ def test_last_month_on_31st
+ assert_equal Time.local(2004, 2, 29), Time.local(2004, 3, 31).last_month
+ end
+
+ def test_xmlschema_is_available
+ assert_nothing_raised { Time.now.xmlschema }
+ end
+
+ def test_acts_like_time
+ assert Time.new.acts_like_time?
+ end
+
+ protected
+ def with_timezone(new_tz = 'US/Eastern')
+ old_tz, ENV['TZ'] = ENV['TZ'], new_tz
+ yield
+ ensure
+ old_tz ? ENV['TZ'] = old_tz : ENV.delete('TZ')
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/dependencies/check_warnings.rb b/vendor/rails-2.0.2/activesupport/test/dependencies/check_warnings.rb
new file mode 100644
index 000000000..03c3dca1d
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/dependencies/check_warnings.rb
@@ -0,0 +1,2 @@
+$check_warnings_load_count += 1
+$checked_verbose = $VERBOSE
diff --git a/vendor/rails-2.0.2/activesupport/test/dependencies/conflict.rb b/vendor/rails-2.0.2/activesupport/test/dependencies/conflict.rb
new file mode 100644
index 000000000..e888b7b54
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/dependencies/conflict.rb
@@ -0,0 +1 @@
+Conflict = 1 \ No newline at end of file
diff --git a/vendor/rails-2.0.2/activesupport/test/dependencies/cross_site_depender.rb b/vendor/rails-2.0.2/activesupport/test/dependencies/cross_site_depender.rb
new file mode 100644
index 000000000..a31015fc5
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/dependencies/cross_site_depender.rb
@@ -0,0 +1,3 @@
+class CrossSiteDepender
+ CrossSiteDependency
+end \ No newline at end of file
diff --git a/vendor/rails-2.0.2/activesupport/test/dependencies/mutual_one.rb b/vendor/rails-2.0.2/activesupport/test/dependencies/mutual_one.rb
new file mode 100644
index 000000000..576eb3171
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/dependencies/mutual_one.rb
@@ -0,0 +1,4 @@
+$mutual_dependencies_count += 1
+require_dependency 'mutual_two'
+require_dependency 'mutual_two.rb'
+require_dependency 'mutual_two'
diff --git a/vendor/rails-2.0.2/activesupport/test/dependencies/mutual_two.rb b/vendor/rails-2.0.2/activesupport/test/dependencies/mutual_two.rb
new file mode 100644
index 000000000..fdbc2dcd8
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/dependencies/mutual_two.rb
@@ -0,0 +1,4 @@
+$mutual_dependencies_count += 1
+require_dependency 'mutual_one.rb'
+require_dependency 'mutual_one'
+require_dependency 'mutual_one.rb'
diff --git a/vendor/rails-2.0.2/activesupport/test/dependencies/raises_exception.rb b/vendor/rails-2.0.2/activesupport/test/dependencies/raises_exception.rb
new file mode 100644
index 000000000..dd745ac20
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/dependencies/raises_exception.rb
@@ -0,0 +1,3 @@
+$raises_exception_load_count += 1
+raise Exception, 'Loading me failed, so do not add to loaded or history.'
+$raises_exception_load_count += 1
diff --git a/vendor/rails-2.0.2/activesupport/test/dependencies/requires_nonexistent0.rb b/vendor/rails-2.0.2/activesupport/test/dependencies/requires_nonexistent0.rb
new file mode 100644
index 000000000..7e24b3916
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/dependencies/requires_nonexistent0.rb
@@ -0,0 +1 @@
+require 'RMagickDontExistDude'
diff --git a/vendor/rails-2.0.2/activesupport/test/dependencies/requires_nonexistent1.rb b/vendor/rails-2.0.2/activesupport/test/dependencies/requires_nonexistent1.rb
new file mode 100644
index 000000000..41e666816
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/dependencies/requires_nonexistent1.rb
@@ -0,0 +1 @@
+require_dependency 'requires_nonexistent0'
diff --git a/vendor/rails-2.0.2/activesupport/test/dependencies/service_one.rb b/vendor/rails-2.0.2/activesupport/test/dependencies/service_one.rb
new file mode 100644
index 000000000..f43bfea23
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/dependencies/service_one.rb
@@ -0,0 +1,5 @@
+$loaded_service_one ||= 0
+$loaded_service_one += 1
+
+class ServiceOne
+end \ No newline at end of file
diff --git a/vendor/rails-2.0.2/activesupport/test/dependencies/service_two.rb b/vendor/rails-2.0.2/activesupport/test/dependencies/service_two.rb
new file mode 100644
index 000000000..5205a78bb
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/dependencies/service_two.rb
@@ -0,0 +1,2 @@
+class ServiceTwo
+end \ No newline at end of file
diff --git a/vendor/rails-2.0.2/activesupport/test/dependencies_test.rb b/vendor/rails-2.0.2/activesupport/test/dependencies_test.rb
new file mode 100644
index 000000000..76f8453c3
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/dependencies_test.rb
@@ -0,0 +1,751 @@
+require File.dirname(__FILE__) + '/abstract_unit'
+require 'pp'
+
+module ModuleWithMissing
+ mattr_accessor :missing_count
+ def self.const_missing(name)
+ self.missing_count += 1
+ name
+ end
+end
+
+module ModuleWithConstant
+ InheritedConstant = "Hello"
+end
+
+class DependenciesTest < Test::Unit::TestCase
+ def teardown
+ Dependencies.clear
+ end
+
+ def with_loading(*from)
+ old_mechanism, Dependencies.mechanism = Dependencies.mechanism, :load
+ dir = File.dirname(__FILE__)
+ prior_load_paths = Dependencies.load_paths
+ Dependencies.load_paths = from.collect { |f| "#{dir}/#{f}" }
+ yield
+ ensure
+ Dependencies.load_paths = prior_load_paths
+ Dependencies.mechanism = old_mechanism
+ Dependencies.explicitly_unloadable_constants = []
+ end
+
+ def test_tracking_loaded_files
+ require_dependency(File.dirname(__FILE__) + "/dependencies/service_one")
+ require_dependency(File.dirname(__FILE__) + "/dependencies/service_two")
+ assert_equal 2, Dependencies.loaded.size
+ end
+
+ def test_tracking_identical_loaded_files
+ require_dependency(File.dirname(__FILE__) + "/dependencies/service_one")
+ require_dependency(File.dirname(__FILE__) + "/dependencies/service_one")
+ assert_equal 1, Dependencies.loaded.size
+ end
+
+ def test_missing_dependency_raises_missing_source_file
+ assert_raises(MissingSourceFile) { require_dependency("missing_service") }
+ end
+
+ def test_missing_association_raises_nothing
+ assert_nothing_raised { require_association("missing_model") }
+ end
+
+ def test_dependency_which_raises_exception_isnt_added_to_loaded_set
+ with_loading do
+ filename = "#{File.dirname(__FILE__)}/dependencies/raises_exception"
+ $raises_exception_load_count = 0
+
+ 5.times do |count|
+ begin
+ require_dependency filename
+ flunk 'should have loaded dependencies/raises_exception which raises an exception'
+ rescue Exception => e
+ assert_equal 'Loading me failed, so do not add to loaded or history.', e.message
+ end
+ assert_equal count + 1, $raises_exception_load_count
+
+ assert !Dependencies.loaded.include?(filename)
+ assert !Dependencies.history.include?(filename)
+ end
+ end
+ end
+
+ def test_warnings_should_be_enabled_on_first_load
+ with_loading 'dependencies' do
+ old_warnings, Dependencies.warnings_on_first_load = Dependencies.warnings_on_first_load, true
+
+ filename = "check_warnings"
+ expanded = File.expand_path("test/dependencies/#{filename}")
+ $check_warnings_load_count = 0
+
+ assert !Dependencies.loaded.include?(expanded)
+ assert !Dependencies.history.include?(expanded)
+
+ silence_warnings { require_dependency filename }
+ assert_equal 1, $check_warnings_load_count
+ assert_equal true, $checked_verbose, 'On first load warnings should be enabled.'
+
+ assert Dependencies.loaded.include?(expanded)
+ Dependencies.clear
+ assert !Dependencies.loaded.include?(expanded)
+ assert Dependencies.history.include?(expanded)
+
+ silence_warnings { require_dependency filename }
+ assert_equal 2, $check_warnings_load_count
+ assert_equal nil, $checked_verbose, 'After first load warnings should be left alone.'
+
+ assert Dependencies.loaded.include?(expanded)
+ Dependencies.clear
+ assert !Dependencies.loaded.include?(expanded)
+ assert Dependencies.history.include?(expanded)
+
+ enable_warnings { require_dependency filename }
+ assert_equal 3, $check_warnings_load_count
+ assert_equal true, $checked_verbose, 'After first load warnings should be left alone.'
+
+ assert Dependencies.loaded.include?(expanded)
+ end
+ end
+
+ def test_mutual_dependencies_dont_infinite_loop
+ with_loading 'dependencies' do
+ $mutual_dependencies_count = 0
+ assert_nothing_raised { require_dependency 'mutual_one' }
+ assert_equal 2, $mutual_dependencies_count
+
+ Dependencies.clear
+
+ $mutual_dependencies_count = 0
+ assert_nothing_raised { require_dependency 'mutual_two' }
+ assert_equal 2, $mutual_dependencies_count
+ end
+ end
+
+ def test_as_load_path
+ assert_equal '', DependenciesTest.as_load_path
+ end
+
+ def test_module_loading
+ with_loading 'autoloading_fixtures' do
+ assert_kind_of Module, A
+ assert_kind_of Class, A::B
+ assert_kind_of Class, A::C::D
+ assert_kind_of Class, A::C::E::F
+ end
+ end
+
+ def test_non_existing_const_raises_name_error
+ with_loading 'autoloading_fixtures' do
+ assert_raises(NameError) { DoesNotExist }
+ assert_raises(NameError) { NoModule::DoesNotExist }
+ assert_raises(NameError) { A::DoesNotExist }
+ assert_raises(NameError) { A::B::DoesNotExist }
+ end
+ end
+
+ def test_directories_manifest_as_modules_unless_const_defined
+ with_loading 'autoloading_fixtures' do
+ assert_kind_of Module, ModuleFolder
+ Object.send! :remove_const, :ModuleFolder
+ end
+ end
+
+ def test_module_with_nested_class
+ with_loading 'autoloading_fixtures' do
+ assert_kind_of Class, ModuleFolder::NestedClass
+ Object.send! :remove_const, :ModuleFolder
+ end
+ end
+
+ def test_module_with_nested_inline_class
+ with_loading 'autoloading_fixtures' do
+ assert_kind_of Class, ModuleFolder::InlineClass
+ Object.send! :remove_const, :ModuleFolder
+ end
+ end
+
+ def test_directories_may_manifest_as_nested_classes
+ with_loading 'autoloading_fixtures' do
+ assert_kind_of Class, ClassFolder
+ Object.send! :remove_const, :ClassFolder
+ end
+ end
+
+ def test_class_with_nested_class
+ with_loading 'autoloading_fixtures' do
+ assert_kind_of Class, ClassFolder::NestedClass
+ Object.send! :remove_const, :ClassFolder
+ end
+ end
+
+ def test_class_with_nested_inline_class
+ with_loading 'autoloading_fixtures' do
+ assert_kind_of Class, ClassFolder::InlineClass
+ Object.send! :remove_const, :ClassFolder
+ end
+ end
+
+ def test_class_with_nested_inline_subclass_of_parent
+ with_loading 'autoloading_fixtures' do
+ assert_kind_of Class, ClassFolder::ClassFolderSubclass
+ assert_kind_of Class, ClassFolder
+ assert_equal 'indeed', ClassFolder::ClassFolderSubclass::ConstantInClassFolder
+ Object.send! :remove_const, :ClassFolder
+ end
+ end
+
+ def test_nested_class_can_access_sibling
+ with_loading 'autoloading_fixtures' do
+ sibling = ModuleFolder::NestedClass.class_eval "NestedSibling"
+ assert defined?(ModuleFolder::NestedSibling)
+ assert_equal ModuleFolder::NestedSibling, sibling
+ Object.send! :remove_const, :ModuleFolder
+ end
+ end
+
+ def failing_test_access_thru_and_upwards_fails
+ with_loading 'autoloading_fixtures' do
+ assert ! defined?(ModuleFolder)
+ assert_raises(NameError) { ModuleFolder::Object }
+ assert_raises(NameError) { ModuleFolder::NestedClass::Object }
+ Object.send! :remove_const, :ModuleFolder
+ end
+ end
+
+ def test_non_existing_const_raises_name_error_with_fully_qualified_name
+ with_loading 'autoloading_fixtures' do
+ begin
+ A::DoesNotExist.nil?
+ flunk "No raise!!"
+ rescue NameError => e
+ assert_equal "uninitialized constant A::DoesNotExist", e.message
+ end
+ begin
+ A::B::DoesNotExist.nil?
+ flunk "No raise!!"
+ rescue NameError => e
+ assert_equal "uninitialized constant A::B::DoesNotExist", e.message
+ end
+ end
+ end
+
+ def test_smart_name_error_strings
+ begin
+ Object.module_eval "ImaginaryObject"
+ flunk "No raise!!"
+ rescue NameError => e
+ assert e.message.include?("uninitialized constant ImaginaryObject")
+ end
+ end
+
+ def test_loadable_constants_for_path_should_handle_empty_autoloads
+ assert_equal [], Dependencies.loadable_constants_for_path('hello')
+ end
+
+ def test_loadable_constants_for_path_should_handle_relative_paths
+ fake_root = 'dependencies'
+ relative_root = File.dirname(__FILE__) + '/dependencies'
+ ['', '/'].each do |suffix|
+ with_loading fake_root + suffix do
+ assert_equal ["A::B"], Dependencies.loadable_constants_for_path(relative_root + '/a/b')
+ end
+ end
+ end
+
+ def test_loadable_constants_for_path_should_provide_all_results
+ fake_root = '/usr/apps/backpack'
+ with_loading fake_root, fake_root + '/lib' do
+ root = Dependencies.load_paths.first
+ assert_equal ["Lib::A::B", "A::B"], Dependencies.loadable_constants_for_path(root + '/lib/a/b')
+ end
+ end
+
+ def test_loadable_constants_for_path_should_uniq_results
+ fake_root = '/usr/apps/backpack/lib'
+ with_loading fake_root, fake_root + '/' do
+ root = Dependencies.load_paths.first
+ assert_equal ["A::B"], Dependencies.loadable_constants_for_path(root + '/a/b')
+ end
+ end
+
+ def test_loadable_constants_with_load_path_without_trailing_slash
+ path = File.dirname(__FILE__) + '/autoloading_fixtures/class_folder/inline_class.rb'
+ with_loading 'autoloading_fixtures/class/' do
+ assert_equal [], Dependencies.loadable_constants_for_path(path)
+ end
+ end
+
+ def test_qualified_const_defined
+ assert Dependencies.qualified_const_defined?("Object")
+ assert Dependencies.qualified_const_defined?("::Object")
+ assert Dependencies.qualified_const_defined?("::Object::Kernel")
+ assert Dependencies.qualified_const_defined?("::Object::Dependencies")
+ assert Dependencies.qualified_const_defined?("::Test::Unit::TestCase")
+ end
+
+ def test_qualified_const_defined_should_not_call_method_missing
+ ModuleWithMissing.missing_count = 0
+ assert ! Dependencies.qualified_const_defined?("ModuleWithMissing::A")
+ assert_equal 0, ModuleWithMissing.missing_count
+ assert ! Dependencies.qualified_const_defined?("ModuleWithMissing::A::B")
+ assert_equal 0, ModuleWithMissing.missing_count
+ end
+
+ def test_autoloaded?
+ with_loading 'autoloading_fixtures' do
+ assert ! Dependencies.autoloaded?("ModuleFolder")
+ assert ! Dependencies.autoloaded?("ModuleFolder::NestedClass")
+
+ assert Dependencies.autoloaded?(ModuleFolder)
+
+ assert Dependencies.autoloaded?("ModuleFolder")
+ assert ! Dependencies.autoloaded?("ModuleFolder::NestedClass")
+
+ assert Dependencies.autoloaded?(ModuleFolder::NestedClass)
+
+ assert Dependencies.autoloaded?("ModuleFolder")
+ assert Dependencies.autoloaded?("ModuleFolder::NestedClass")
+
+ assert Dependencies.autoloaded?("::ModuleFolder")
+ assert Dependencies.autoloaded?(:ModuleFolder)
+
+ # Anonymous modules aren't autoloaded.
+ assert !Dependencies.autoloaded?(Module.new)
+
+ nil_name = Module.new
+ def nil_name.name() nil end
+ assert !Dependencies.autoloaded?(nil_name)
+
+ Object.class_eval { remove_const :ModuleFolder }
+ end
+ end
+
+ def test_qualified_name_for
+ assert_equal "A", Dependencies.qualified_name_for(Object, :A)
+ assert_equal "A", Dependencies.qualified_name_for(:Object, :A)
+ assert_equal "A", Dependencies.qualified_name_for("Object", :A)
+ assert_equal "A", Dependencies.qualified_name_for("::Object", :A)
+ assert_equal "A", Dependencies.qualified_name_for("::Kernel", :A)
+
+ assert_equal "Dependencies::A", Dependencies.qualified_name_for(:Dependencies, :A)
+ assert_equal "Dependencies::A", Dependencies.qualified_name_for(Dependencies, :A)
+ end
+
+ def test_file_search
+ with_loading 'dependencies' do
+ root = Dependencies.load_paths.first
+ assert_equal nil, Dependencies.search_for_file('service_three')
+ assert_equal nil, Dependencies.search_for_file('service_three.rb')
+ assert_equal root + '/service_one.rb', Dependencies.search_for_file('service_one')
+ assert_equal root + '/service_one.rb', Dependencies.search_for_file('service_one.rb')
+ end
+ end
+
+ def test_file_search_uses_first_in_load_path
+ with_loading 'dependencies', 'autoloading_fixtures' do
+ deps, autoload = Dependencies.load_paths
+ assert_match %r/dependencies/, deps
+ assert_match %r/autoloading_fixtures/, autoload
+
+ assert_equal deps + '/conflict.rb', Dependencies.search_for_file('conflict')
+ end
+ with_loading 'autoloading_fixtures', 'dependencies' do
+ autoload, deps = Dependencies.load_paths
+ assert_match %r/dependencies/, deps
+ assert_match %r/autoloading_fixtures/, autoload
+
+ assert_equal autoload + '/conflict.rb', Dependencies.search_for_file('conflict')
+ end
+
+ end
+
+ def test_custom_const_missing_should_work
+ Object.module_eval <<-end_eval
+ module ModuleWithCustomConstMissing
+ def self.const_missing(name)
+ const_set name, name.to_s.hash
+ end
+
+ module A
+ end
+ end
+ end_eval
+
+ with_loading 'autoloading_fixtures' do
+ assert_kind_of Integer, ::ModuleWithCustomConstMissing::B
+ assert_kind_of Module, ::ModuleWithCustomConstMissing::A
+ assert_kind_of String, ::ModuleWithCustomConstMissing::A::B
+ end
+ end
+
+ def test_const_missing_should_not_double_load
+ $counting_loaded_times = 0
+ with_loading 'autoloading_fixtures' do
+ require_dependency '././counting_loader'
+ assert_equal 1, $counting_loaded_times
+ assert_raises(ArgumentError) { Dependencies.load_missing_constant Object, :CountingLoader }
+ assert_equal 1, $counting_loaded_times
+ end
+ end
+
+ def test_const_missing_within_anonymous_module
+ $counting_loaded_times = 0
+ m = Module.new
+ m.module_eval "def a() CountingLoader; end"
+ extend m
+ kls = nil
+ with_loading 'autoloading_fixtures' do
+ kls = nil
+ assert_nothing_raised { kls = a }
+ assert_equal "CountingLoader", kls.name
+ assert_equal 1, $counting_loaded_times
+
+ assert_nothing_raised { kls = a }
+ assert_equal 1, $counting_loaded_times
+ end
+ end
+
+ def test_removal_from_tree_should_be_detected
+ with_loading 'dependencies' do
+ root = Dependencies.load_paths.first
+ c = ServiceOne
+ Dependencies.clear
+ assert ! defined?(ServiceOne)
+ begin
+ Dependencies.load_missing_constant(c, :FakeMissing)
+ flunk "Expected exception"
+ rescue ArgumentError => e
+ assert_match %r{ServiceOne has been removed from the module tree}i, e.message
+ end
+ end
+ end
+
+ def test_nested_load_error_isnt_rescued
+ with_loading 'dependencies' do
+ assert_raises(MissingSourceFile) do
+ RequiresNonexistent1
+ end
+ end
+ end
+
+ def test_load_once_paths_do_not_add_to_autoloaded_constants
+ with_loading 'autoloading_fixtures' do
+ Dependencies.load_once_paths = Dependencies.load_paths.dup
+
+ assert ! Dependencies.autoloaded?("ModuleFolder")
+ assert ! Dependencies.autoloaded?("ModuleFolder::NestedClass")
+ assert ! Dependencies.autoloaded?(ModuleFolder)
+
+ 1 if ModuleFolder::NestedClass # 1 if to avoid warning
+ assert ! Dependencies.autoloaded?(ModuleFolder::NestedClass)
+ end
+ ensure
+ Object.class_eval { remove_const :ModuleFolder }
+ Dependencies.load_once_paths = []
+ end
+
+ def test_application_should_special_case_application_controller
+ with_loading 'autoloading_fixtures' do
+ require_dependency 'application'
+ assert_equal 10, ApplicationController
+ assert Dependencies.autoloaded?(:ApplicationController)
+ end
+ end
+
+ def test_const_missing_on_kernel_should_fallback_to_object
+ with_loading 'autoloading_fixtures' do
+ kls = Kernel::E
+ assert_equal "E", kls.name
+ assert_equal kls.object_id, Kernel::E.object_id
+ end
+ end
+
+ def test_preexisting_constants_are_not_marked_as_autoloaded
+ with_loading 'autoloading_fixtures' do
+ require_dependency 'e'
+ assert Dependencies.autoloaded?(:E)
+ Dependencies.clear
+ end
+
+ Object.const_set :E, Class.new
+ with_loading 'autoloading_fixtures' do
+ require_dependency 'e'
+ assert ! Dependencies.autoloaded?(:E), "E shouldn't be marked autoloaded!"
+ Dependencies.clear
+ end
+
+ ensure
+ Object.class_eval { remove_const :E }
+ end
+
+ def test_unloadable
+ with_loading 'autoloading_fixtures' do
+ Object.const_set :M, Module.new
+ M.unloadable
+
+ Dependencies.clear
+ assert ! defined?(M)
+
+ Object.const_set :M, Module.new
+ Dependencies.clear
+ assert ! defined?(M), "Dependencies should unload unloadable constants each time"
+ end
+ end
+
+ def test_unloadable_should_fail_with_anonymous_modules
+ with_loading 'autoloading_fixtures' do
+ m = Module.new
+ assert_raises(ArgumentError) { m.unloadable }
+ end
+ end
+
+ def test_unloadable_should_return_change_flag
+ with_loading 'autoloading_fixtures' do
+ Object.const_set :M, Module.new
+ assert_equal true, M.unloadable
+ assert_equal false, M.unloadable
+ end
+ end
+
+ def test_new_contants_in_without_constants
+ assert_equal [], (Dependencies.new_constants_in(Object) { })
+ assert Dependencies.constant_watch_stack.empty?
+ end
+
+ def test_new_constants_in_with_a_single_constant
+ assert_equal ["Hello"], Dependencies.new_constants_in(Object) {
+ Object.const_set :Hello, 10
+ }.map(&:to_s)
+ assert Dependencies.constant_watch_stack.empty?
+ ensure
+ Object.class_eval { remove_const :Hello }
+ end
+
+ def test_new_constants_in_with_nesting
+ outer = Dependencies.new_constants_in(Object) do
+ Object.const_set :OuterBefore, 10
+
+ assert_equal ["Inner"], Dependencies.new_constants_in(Object) {
+ Object.const_set :Inner, 20
+ }.map(&:to_s)
+
+ Object.const_set :OuterAfter, 30
+ end
+
+ assert_equal ["OuterAfter", "OuterBefore"], outer.sort.map(&:to_s)
+ assert Dependencies.constant_watch_stack.empty?
+ ensure
+ %w(OuterBefore Inner OuterAfter).each do |name|
+ Object.class_eval { remove_const name if const_defined?(name) }
+ end
+ end
+
+ def test_new_constants_in_module
+ Object.const_set :M, Module.new
+
+ outer = Dependencies.new_constants_in(M) do
+ M.const_set :OuterBefore, 10
+
+ inner = Dependencies.new_constants_in(M) do
+ M.const_set :Inner, 20
+ end
+ assert_equal ["M::Inner"], inner
+
+ M.const_set :OuterAfter, 30
+ end
+ assert_equal ["M::OuterAfter", "M::OuterBefore"], outer.sort
+ assert Dependencies.constant_watch_stack.empty?
+ ensure
+ Object.class_eval { remove_const :M }
+ end
+
+ def test_new_constants_in_module_using_name
+ outer = Dependencies.new_constants_in(:M) do
+ Object.const_set :M, Module.new
+ M.const_set :OuterBefore, 10
+
+ inner = Dependencies.new_constants_in(:M) do
+ M.const_set :Inner, 20
+ end
+ assert_equal ["M::Inner"], inner
+
+ M.const_set :OuterAfter, 30
+ end
+ assert_equal ["M::OuterAfter", "M::OuterBefore"], outer.sort
+ assert Dependencies.constant_watch_stack.empty?
+ ensure
+ Object.class_eval { remove_const :M }
+ end
+
+ def test_new_constants_in_with_inherited_constants
+ m = Dependencies.new_constants_in(:Object) do
+ Object.class_eval { include ModuleWithConstant }
+ end
+ assert_equal [], m
+ end
+
+ def test_file_with_multiple_constants_and_require_dependency
+ with_loading 'autoloading_fixtures' do
+ assert ! defined?(MultipleConstantFile)
+ assert ! defined?(SiblingConstant)
+
+ require_dependency 'multiple_constant_file'
+ assert defined?(MultipleConstantFile)
+ assert defined?(SiblingConstant)
+ assert Dependencies.autoloaded?(:MultipleConstantFile)
+ assert Dependencies.autoloaded?(:SiblingConstant)
+
+ Dependencies.clear
+
+ assert ! defined?(MultipleConstantFile)
+ assert ! defined?(SiblingConstant)
+ end
+ end
+
+ def test_file_with_multiple_constants_and_auto_loading
+ with_loading 'autoloading_fixtures' do
+ assert ! defined?(MultipleConstantFile)
+ assert ! defined?(SiblingConstant)
+
+ assert_equal 10, MultipleConstantFile
+
+ assert defined?(MultipleConstantFile)
+ assert defined?(SiblingConstant)
+ assert Dependencies.autoloaded?(:MultipleConstantFile)
+ assert Dependencies.autoloaded?(:SiblingConstant)
+
+ Dependencies.clear
+
+ assert ! defined?(MultipleConstantFile)
+ assert ! defined?(SiblingConstant)
+ end
+ end
+
+ def test_nested_file_with_multiple_constants_and_require_dependency
+ with_loading 'autoloading_fixtures' do
+ assert ! defined?(ClassFolder::NestedClass)
+ assert ! defined?(ClassFolder::SiblingClass)
+
+ require_dependency 'class_folder/nested_class'
+
+ assert defined?(ClassFolder::NestedClass)
+ assert defined?(ClassFolder::SiblingClass)
+ assert Dependencies.autoloaded?("ClassFolder::NestedClass")
+ assert Dependencies.autoloaded?("ClassFolder::SiblingClass")
+
+ Dependencies.clear
+
+ assert ! defined?(ClassFolder::NestedClass)
+ assert ! defined?(ClassFolder::SiblingClass)
+ end
+ end
+
+ def test_nested_file_with_multiple_constants_and_auto_loading
+ with_loading 'autoloading_fixtures' do
+ assert ! defined?(ClassFolder::NestedClass)
+ assert ! defined?(ClassFolder::SiblingClass)
+
+ assert_kind_of Class, ClassFolder::NestedClass
+
+ assert defined?(ClassFolder::NestedClass)
+ assert defined?(ClassFolder::SiblingClass)
+ assert Dependencies.autoloaded?("ClassFolder::NestedClass")
+ assert Dependencies.autoloaded?("ClassFolder::SiblingClass")
+
+ Dependencies.clear
+
+ assert ! defined?(ClassFolder::NestedClass)
+ assert ! defined?(ClassFolder::SiblingClass)
+ end
+ end
+
+ def test_autoload_doesnt_shadow_no_method_error_with_relative_constant
+ with_loading 'autoloading_fixtures' do
+ assert !defined?(::RaisesNoMethodError), "::RaisesNoMethodError is defined but it hasn't been referenced yet!"
+ 2.times do
+ assert_raise(NoMethodError) { RaisesNoMethodError }
+ assert !defined?(::RaisesNoMethodError), "::RaisesNoMethodError is defined but it should have failed!"
+ end
+ end
+
+ ensure
+ Object.class_eval { remove_const :RaisesNoMethodError if const_defined?(:RaisesNoMethodError) }
+ end
+
+ def test_autoload_doesnt_shadow_no_method_error_with_absolute_constant
+ with_loading 'autoloading_fixtures' do
+ assert !defined?(::RaisesNoMethodError), "::RaisesNoMethodError is defined but it hasn't been referenced yet!"
+ 2.times do
+ assert_raise(NoMethodError) { ::RaisesNoMethodError }
+ assert !defined?(::RaisesNoMethodError), "::RaisesNoMethodError is defined but it should have failed!"
+ end
+ end
+
+ ensure
+ Object.class_eval { remove_const :RaisesNoMethodError if const_defined?(:RaisesNoMethodError) }
+ end
+
+ def test_autoload_doesnt_shadow_name_error
+ with_loading 'autoloading_fixtures' do
+ assert !defined?(::RaisesNameError), "::RaisesNameError is defined but it hasn't been referenced yet!"
+ 2.times do
+ begin
+ ::RaisesNameError.object_id
+ flunk 'should have raised NameError when autoloaded file referenced FooBarBaz'
+ rescue NameError => e
+ assert_equal 'uninitialized constant RaisesNameError::FooBarBaz', e.message
+ end
+ assert !defined?(::RaisesNameError), "::RaisesNameError is defined but it should have failed!"
+ end
+
+ assert !defined?(RaisesNameError)
+ 2.times do
+ assert_raise(NameError) { RaisesNameError }
+ assert !defined?(::RaisesNameError), "::RaisesNameError is defined but it should have failed!"
+ end
+ end
+
+ ensure
+ Object.class_eval { remove_const :RaisesNoMethodError if const_defined?(:RaisesNoMethodError) }
+ end
+
+ def test_remove_constant_handles_double_colon_at_start
+ Object.const_set 'DeleteMe', Module.new
+ DeleteMe.const_set 'OrMe', Module.new
+ Dependencies.remove_constant "::DeleteMe::OrMe"
+ assert ! defined?(DeleteMe::OrMe)
+ assert defined?(DeleteMe)
+ Dependencies.remove_constant "::DeleteMe"
+ assert ! defined?(DeleteMe)
+ end
+
+ def test_load_once_constants_should_not_be_unloaded
+ with_loading 'autoloading_fixtures' do
+ Dependencies.load_once_paths = Dependencies.load_paths
+ ::A.to_s
+ assert defined?(A)
+ Dependencies.clear
+ assert defined?(A)
+ end
+ ensure
+ Dependencies.load_once_paths = []
+ Object.class_eval { remove_const :A if const_defined?(:A) }
+ end
+
+ def test_load_once_paths_should_behave_when_recursively_loading
+ with_loading 'dependencies', 'autoloading_fixtures' do
+ Dependencies.load_once_paths = [Dependencies.load_paths.last]
+ assert !defined?(CrossSiteDependency)
+ assert_nothing_raised { CrossSiteDepender.nil? }
+ assert defined?(CrossSiteDependency)
+ assert !Dependencies.autoloaded?(CrossSiteDependency),
+ "CrossSiteDependency shouldn't be marked as autoloaded!"
+ Dependencies.clear
+ assert defined?(CrossSiteDependency),
+ "CrossSiteDependency shouldn't have been unloaded!"
+ end
+ ensure
+ Dependencies.load_once_paths = []
+ end
+
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/deprecation_test.rb b/vendor/rails-2.0.2/activesupport/test/deprecation_test.rb
new file mode 100644
index 000000000..9eb9e9253
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/deprecation_test.rb
@@ -0,0 +1,151 @@
+require File.dirname(__FILE__) + '/abstract_unit'
+
+class Deprecatee
+ def initialize
+ @request = ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy.new(self, :request)
+ @_request = 'there we go'
+ end
+ def request; @_request end
+ def old_request; @request end
+
+ def partially(foo = nil)
+ ActiveSupport::Deprecation.warn('calling with foo=nil is out', caller) if foo.nil?
+ end
+
+ def not() 2 end
+ def none() 1 end
+ def one(a) a end
+ def multi(a,b,c) [a,b,c] end
+ deprecate :none, :one, :multi
+
+ def a; end
+ def b; end
+ def c; end
+ def d; end
+ def e; end
+ deprecate :a, :b, :c => :e, :d => "you now need to do something extra for this one"
+end
+
+
+class DeprecationTest < Test::Unit::TestCase
+ def setup
+ # Track the last warning.
+ @old_behavior = ActiveSupport::Deprecation.behavior
+ @last_message = nil
+ ActiveSupport::Deprecation.behavior = Proc.new { |message| @last_message = message }
+
+ @dtc = Deprecatee.new
+ end
+
+ def teardown
+ ActiveSupport::Deprecation.behavior = @old_behavior
+ end
+
+ def test_inline_deprecation_warning
+ assert_deprecated(/foo=nil/) do
+ @dtc.partially
+ end
+ end
+
+ def test_undeprecated
+ assert_not_deprecated do
+ assert_equal 2, @dtc.not
+ end
+ end
+
+ def test_deprecate_class_method
+ assert_deprecated(/none is deprecated.*test_deprecate_class_method at/) do
+ assert_equal 1, @dtc.none
+ end
+
+ assert_deprecated(/one is deprecated/) do
+ assert_equal 1, @dtc.one(1)
+ end
+
+ assert_deprecated(/multi is deprecated/) do
+ assert_equal [1,2,3], @dtc.multi(1,2,3)
+ end
+ end
+
+ def test_nil_behavior_is_ignored
+ ActiveSupport::Deprecation.behavior = nil
+ assert_deprecated(/foo=nil/) { @dtc.partially }
+ end
+
+ def test_deprecated_instance_variable_proxy
+ assert_not_deprecated { @dtc.request.size }
+
+ assert_deprecated('@request.size') { assert_equal @dtc.request.size, @dtc.old_request.size }
+ assert_deprecated('@request.to_s') { assert_equal @dtc.request.to_s, @dtc.old_request.to_s }
+ end
+
+ def test_deprecated_instance_variable_proxy_shouldnt_warn_on_inspect
+ assert_not_deprecated { assert_equal @dtc.request.inspect, @dtc.old_request.inspect }
+ end
+
+ def test_assert_deprecation_without_match
+ assert_deprecated do
+ @dtc.partially
+ end
+ end
+
+ def test_assert_deprecated_matches_any_warning
+ assert_deprecated 'abc' do
+ ActiveSupport::Deprecation.warn 'abc'
+ ActiveSupport::Deprecation.warn 'def'
+ end
+ rescue Test::Unit::AssertionFailedError
+ flunk 'assert_deprecated should match any warning in block, not just the last one'
+ end
+
+ def test_assert_not_deprecated_returns_result_of_block
+ assert_equal 123, assert_not_deprecated { 123 }
+ end
+
+ def test_assert_deprecated_returns_result_of_block
+ result = assert_deprecated('abc') do
+ ActiveSupport::Deprecation.warn 'abc'
+ 123
+ end
+ assert_equal 123, result
+ end
+
+ def test_silence
+ ActiveSupport::Deprecation.silence do
+ assert_not_deprecated { @dtc.partially }
+ end
+
+ ActiveSupport::Deprecation.silenced = true
+ assert_not_deprecated { @dtc.partially }
+ ActiveSupport::Deprecation.silenced = false
+ end
+
+ def test_deprecation_without_explanation
+ assert_deprecated { @dtc.a }
+ assert_deprecated { @dtc.b }
+ end
+
+ def test_deprecation_with_alternate_method
+ assert_deprecated(/use e instead/) { @dtc.c }
+ end
+
+ def test_deprecation_with_explicit_message
+ assert_deprecated(/you now need to do something extra for this one/) { @dtc.d }
+ end
+
+ def test_assertion_failed_error_doesnt_spout_deprecation_warnings
+ error_class = Class.new(StandardError) do
+ def message
+ ActiveSupport::Deprecation.warn 'warning in error message'
+ super
+ end
+ end
+
+ raise error_class.new('hmm')
+
+ rescue => e
+ error = Test::Unit::Error.new('testing ur doodz', e)
+ assert_not_deprecated { error.message }
+ assert_nil @last_message
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/inflector_test.rb b/vendor/rails-2.0.2/activesupport/test/inflector_test.rb
new file mode 100644
index 000000000..b0155d36b
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/inflector_test.rb
@@ -0,0 +1,248 @@
+require File.dirname(__FILE__) + '/abstract_unit'
+require 'inflector_test_cases'
+
+module Ace
+ module Base
+ class Case
+ end
+ end
+end
+
+class InflectorTest < Test::Unit::TestCase
+ include InflectorTestCases
+
+ def test_pluralize_plurals
+ assert_equal "plurals", Inflector.pluralize("plurals")
+ assert_equal "Plurals", Inflector.pluralize("Plurals")
+ end
+
+ def test_pluralize_empty_string
+ assert_equal "", Inflector.pluralize("")
+ end
+
+ SingularToPlural.each do |singular, plural|
+ define_method "test_pluralize_#{singular}" do
+ assert_equal(plural, Inflector.pluralize(singular))
+ assert_equal(plural.capitalize, Inflector.pluralize(singular.capitalize))
+ end
+ end
+
+ SingularToPlural.each do |singular, plural|
+ define_method "test_singularize_#{plural}" do
+ assert_equal(singular, Inflector.singularize(plural))
+ assert_equal(singular.capitalize, Inflector.singularize(plural.capitalize))
+ end
+ end
+
+ MixtureToTitleCase.each do |before, titleized|
+ define_method "test_titleize_#{before}" do
+ assert_equal(titleized, Inflector.titleize(before))
+ end
+ end
+
+ def test_camelize
+ CamelToUnderscore.each do |camel, underscore|
+ assert_equal(camel, Inflector.camelize(underscore))
+ end
+ end
+
+ def test_underscore
+ CamelToUnderscore.each do |camel, underscore|
+ assert_equal(underscore, Inflector.underscore(camel))
+ end
+ CamelToUnderscoreWithoutReverse.each do |camel, underscore|
+ assert_equal(underscore, Inflector.underscore(camel))
+ end
+ end
+
+ def test_camelize_with_module
+ CamelWithModuleToUnderscoreWithSlash.each do |camel, underscore|
+ assert_equal(camel, Inflector.camelize(underscore))
+ end
+ end
+
+ def test_underscore_with_slashes
+ CamelWithModuleToUnderscoreWithSlash.each do |camel, underscore|
+ assert_equal(underscore, Inflector.underscore(camel))
+ end
+ end
+
+ def test_demodulize
+ assert_equal "Account", Inflector.demodulize("MyApplication::Billing::Account")
+ end
+
+ def test_foreign_key
+ ClassNameToForeignKeyWithUnderscore.each do |klass, foreign_key|
+ assert_equal(foreign_key, Inflector.foreign_key(klass))
+ end
+
+ ClassNameToForeignKeyWithoutUnderscore.each do |klass, foreign_key|
+ assert_equal(foreign_key, Inflector.foreign_key(klass, false))
+ end
+ end
+
+ def test_tableize
+ ClassNameToTableName.each do |class_name, table_name|
+ assert_equal(table_name, Inflector.tableize(class_name))
+ end
+ end
+
+ def test_classify
+ ClassNameToTableName.each do |class_name, table_name|
+ assert_equal(class_name, Inflector.classify(table_name))
+ assert_equal(class_name, Inflector.classify("table_prefix." + table_name))
+ end
+ end
+
+ def test_classify_with_symbol
+ assert_nothing_raised do
+ assert_equal 'FooBar', Inflector.classify(:foo_bars)
+ end
+ end
+
+ def test_classify_with_leading_schema_name
+ assert_equal 'FooBar', Inflector.classify('schema.foo_bar')
+ end
+
+ def test_humanize
+ UnderscoreToHuman.each do |underscore, human|
+ assert_equal(human, Inflector.humanize(underscore))
+ end
+ end
+
+ def test_constantize
+ assert_nothing_raised { assert_equal Ace::Base::Case, Inflector.constantize("Ace::Base::Case") }
+ assert_nothing_raised { assert_equal Ace::Base::Case, Inflector.constantize("::Ace::Base::Case") }
+ assert_nothing_raised { assert_equal InflectorTest, Inflector.constantize("InflectorTest") }
+ assert_nothing_raised { assert_equal InflectorTest, Inflector.constantize("::InflectorTest") }
+ assert_raises(NameError) { Inflector.constantize("UnknownClass") }
+ assert_raises(NameError) { Inflector.constantize("An invalid string") }
+ assert_raises(NameError) { Inflector.constantize("InvalidClass\n") }
+ end
+
+ if RUBY_VERSION < '1.9.0'
+ def test_constantize_does_lexical_lookup
+ assert_raises(NameError) { Inflector.constantize("Ace::Base::InflectorTest") }
+ end
+ else
+ def test_constantize_does_dynamic_lookup
+ assert_equal self.class, Inflector.constantize("Ace::Base::InflectorTest")
+ end
+ end
+
+ def test_ordinal
+ OrdinalNumbers.each do |number, ordinalized|
+ assert_equal(ordinalized, Inflector.ordinalize(number))
+ end
+ end
+
+ def test_dasherize
+ UnderscoresToDashes.each do |underscored, dasherized|
+ assert_equal(dasherized, Inflector.dasherize(underscored))
+ end
+ end
+
+ def test_underscore_as_reverse_of_dasherize
+ UnderscoresToDashes.each do |underscored, dasherized|
+ assert_equal(underscored, Inflector.underscore(Inflector.dasherize(underscored)))
+ end
+ end
+
+ def test_underscore_to_lower_camel
+ UnderscoreToLowerCamel.each do |underscored, lower_camel|
+ assert_equal(lower_camel, Inflector.camelize(underscored, false))
+ end
+ end
+
+ %w{plurals singulars uncountables}.each do |inflection_type|
+ class_eval "
+ def test_clear_#{inflection_type}
+ cached_values = Inflector.inflections.#{inflection_type}
+ Inflector.inflections.clear :#{inflection_type}
+ assert Inflector.inflections.#{inflection_type}.empty?, \"#{inflection_type} inflections should be empty after clear :#{inflection_type}\"
+ Inflector.inflections.instance_variable_set :@#{inflection_type}, cached_values
+ end
+ "
+ end
+
+ def test_clear_all
+ cached_values = Inflector.inflections.plurals, Inflector.inflections.singulars, Inflector.inflections.uncountables
+ Inflector.inflections.clear :all
+ assert Inflector.inflections.plurals.empty?
+ assert Inflector.inflections.singulars.empty?
+ assert Inflector.inflections.uncountables.empty?
+ Inflector.inflections.instance_variable_set :@plurals, cached_values[0]
+ Inflector.inflections.instance_variable_set :@singulars, cached_values[1]
+ Inflector.inflections.instance_variable_set :@uncountables, cached_values[2]
+ end
+
+ def test_clear_with_default
+ cached_values = Inflector.inflections.plurals, Inflector.inflections.singulars, Inflector.inflections.uncountables
+ Inflector.inflections.clear
+ assert Inflector.inflections.plurals.empty?
+ assert Inflector.inflections.singulars.empty?
+ assert Inflector.inflections.uncountables.empty?
+ Inflector.inflections.instance_variable_set :@plurals, cached_values[0]
+ Inflector.inflections.instance_variable_set :@singulars, cached_values[1]
+ Inflector.inflections.instance_variable_set :@uncountables, cached_values[2]
+ end
+
+ Irregularities.each do |irregularity|
+ singular, plural = *irregularity
+ Inflector.inflections do |inflect|
+ define_method("test_irregularity_between_#{singular}_and_#{plural}") do
+ inflect.irregular(singular, plural)
+ assert_equal singular, Inflector.singularize(plural)
+ assert_equal plural, Inflector.pluralize(singular)
+ end
+ end
+ end
+
+ [ :all, [] ].each do |scope|
+ Inflector.inflections do |inflect|
+ define_method("test_clear_inflections_with_#{scope.kind_of?(Array) ? "no_arguments" : scope}") do
+ # save all the inflections
+ singulars, plurals, uncountables = inflect.singulars, inflect.plurals, inflect.uncountables
+
+ # clear all the inflections
+ inflect.clear(*scope)
+
+ assert_equal [], inflect.singulars
+ assert_equal [], inflect.plurals
+ assert_equal [], inflect.uncountables
+
+ # restore all the inflections
+ singulars.reverse.each { |singular| inflect.singular(*singular) }
+ plurals.reverse.each { |plural| inflect.plural(*plural) }
+ inflect.uncountable(uncountables)
+
+ assert_equal singulars, inflect.singulars
+ assert_equal plurals, inflect.plurals
+ assert_equal uncountables, inflect.uncountables
+ end
+ end
+ end
+
+ { :singulars => :singular, :plurals => :plural, :uncountables => :uncountable }.each do |scope, method|
+ Inflector.inflections do |inflect|
+ define_method("test_clear_inflections_with_#{scope}") do
+ # save the inflections
+ values = inflect.send(scope)
+
+ # clear the inflections
+ inflect.clear(scope)
+
+ assert_equal [], inflect.send(scope)
+
+ # restore the inflections
+ if scope == :uncountables
+ inflect.send(method, values)
+ else
+ values.reverse.each { |value| inflect.send(method, *value) }
+ end
+
+ assert_equal values, inflect.send(scope)
+ end
+ end
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/inflector_test_cases.rb b/vendor/rails-2.0.2/activesupport/test/inflector_test_cases.rb
new file mode 100644
index 000000000..83fd4c8e5
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/inflector_test_cases.rb
@@ -0,0 +1,208 @@
+module InflectorTestCases
+ SingularToPlural = {
+ "search" => "searches",
+ "switch" => "switches",
+ "fix" => "fixes",
+ "box" => "boxes",
+ "process" => "processes",
+ "address" => "addresses",
+ "case" => "cases",
+ "stack" => "stacks",
+ "wish" => "wishes",
+ "fish" => "fish",
+
+ "category" => "categories",
+ "query" => "queries",
+ "ability" => "abilities",
+ "agency" => "agencies",
+ "movie" => "movies",
+
+ "archive" => "archives",
+
+ "index" => "indices",
+
+ "wife" => "wives",
+ "safe" => "saves",
+ "half" => "halves",
+
+ "move" => "moves",
+
+ "salesperson" => "salespeople",
+ "person" => "people",
+
+ "spokesman" => "spokesmen",
+ "man" => "men",
+ "woman" => "women",
+
+ "basis" => "bases",
+ "diagnosis" => "diagnoses",
+ "diagnosis_a" => "diagnosis_as",
+
+ "datum" => "data",
+ "medium" => "media",
+ "analysis" => "analyses",
+
+ "node_child" => "node_children",
+ "child" => "children",
+
+ "experience" => "experiences",
+ "day" => "days",
+
+ "comment" => "comments",
+ "foobar" => "foobars",
+ "newsletter" => "newsletters",
+
+ "old_news" => "old_news",
+ "news" => "news",
+
+ "series" => "series",
+ "species" => "species",
+
+ "quiz" => "quizzes",
+
+ "perspective" => "perspectives",
+
+ "ox" => "oxen",
+ "photo" => "photos",
+ "buffalo" => "buffaloes",
+ "tomato" => "tomatoes",
+ "dwarf" => "dwarves",
+ "elf" => "elves",
+ "information" => "information",
+ "equipment" => "equipment",
+ "bus" => "buses",
+ "status" => "statuses",
+ "status_code" => "status_codes",
+ "mouse" => "mice",
+
+ "louse" => "lice",
+ "house" => "houses",
+ "octopus" => "octopi",
+ "virus" => "viri",
+ "alias" => "aliases",
+ "portfolio" => "portfolios",
+
+ "vertex" => "vertices",
+ "matrix" => "matrices",
+ "matrix_fu" => "matrix_fus",
+
+ "axis" => "axes",
+ "testis" => "testes",
+ "crisis" => "crises",
+
+ "rice" => "rice",
+ "shoe" => "shoes",
+
+ "horse" => "horses",
+ "prize" => "prizes",
+ "edge" => "edges",
+
+ "cow" => "kine"
+ }
+
+ CamelToUnderscore = {
+ "Product" => "product",
+ "SpecialGuest" => "special_guest",
+ "ApplicationController" => "application_controller",
+ "Area51Controller" => "area51_controller"
+ }
+
+ UnderscoreToLowerCamel = {
+ "product" => "product",
+ "special_guest" => "specialGuest",
+ "application_controller" => "applicationController",
+ "area51_controller" => "area51Controller"
+ }
+
+ CamelToUnderscoreWithoutReverse = {
+ "HTMLTidy" => "html_tidy",
+ "HTMLTidyGenerator" => "html_tidy_generator",
+ "FreeBSD" => "free_bsd",
+ "HTML" => "html",
+ }
+
+ CamelWithModuleToUnderscoreWithSlash = {
+ "Admin::Product" => "admin/product",
+ "Users::Commission::Department" => "users/commission/department",
+ "UsersSection::CommissionDepartment" => "users_section/commission_department",
+ }
+
+ ClassNameToForeignKeyWithUnderscore = {
+ "Person" => "person_id",
+ "MyApplication::Billing::Account" => "account_id"
+ }
+
+ ClassNameToForeignKeyWithoutUnderscore = {
+ "Person" => "personid",
+ "MyApplication::Billing::Account" => "accountid"
+ }
+
+ ClassNameToTableName = {
+ "PrimarySpokesman" => "primary_spokesmen",
+ "NodeChild" => "node_children"
+ }
+
+ UnderscoreToHuman = {
+ "employee_salary" => "Employee salary",
+ "employee_id" => "Employee",
+ "underground" => "Underground"
+ }
+
+ MixtureToTitleCase = {
+ 'active_record' => 'Active Record',
+ 'ActiveRecord' => 'Active Record',
+ 'action web service' => 'Action Web Service',
+ 'Action Web Service' => 'Action Web Service',
+ 'Action web service' => 'Action Web Service',
+ 'actionwebservice' => 'Actionwebservice',
+ 'Actionwebservice' => 'Actionwebservice'
+ }
+
+ OrdinalNumbers = {
+ "0" => "0th",
+ "1" => "1st",
+ "2" => "2nd",
+ "3" => "3rd",
+ "4" => "4th",
+ "5" => "5th",
+ "6" => "6th",
+ "7" => "7th",
+ "8" => "8th",
+ "9" => "9th",
+ "10" => "10th",
+ "11" => "11th",
+ "12" => "12th",
+ "13" => "13th",
+ "14" => "14th",
+ "20" => "20th",
+ "21" => "21st",
+ "22" => "22nd",
+ "23" => "23rd",
+ "24" => "24th",
+ "100" => "100th",
+ "101" => "101st",
+ "102" => "102nd",
+ "103" => "103rd",
+ "104" => "104th",
+ "110" => "110th",
+ "111" => "111th",
+ "112" => "112th",
+ "113" => "113th",
+ "1000" => "1000th",
+ "1001" => "1001st"
+ }
+
+ UnderscoresToDashes = {
+ "street" => "street",
+ "street_address" => "street-address",
+ "person_street_address" => "person-street-address"
+ }
+
+ Irregularities = {
+ 'person' => 'people',
+ 'man' => 'men',
+ 'child' => 'children',
+ 'sex' => 'sexes',
+ 'move' => 'moves',
+ }
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/json/decoding_test.rb b/vendor/rails-2.0.2/activesupport/test/json/decoding_test.rb
new file mode 100644
index 000000000..93560fb5a
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/json/decoding_test.rb
@@ -0,0 +1,41 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+class TestJSONDecoding < Test::Unit::TestCase
+ TESTS = {
+ %q({"returnTo":{"\/categories":"\/"}}) => {"returnTo" => {"/categories" => "/"}},
+ %q({returnTo:{"\/categories":"\/"}}) => {"returnTo" => {"/categories" => "/"}},
+ %q({"return\\"To\\":":{"\/categories":"\/"}}) => {"return\"To\":" => {"/categories" => "/"}},
+ %q({"returnTo":{"\/categories":1}}) => {"returnTo" => {"/categories" => 1}},
+ %({"returnTo":[1,"a"]}) => {"returnTo" => [1, "a"]},
+ %({"returnTo":[1,"\\"a\\",", "b"]}) => {"returnTo" => [1, "\"a\",", "b"]},
+ %({a: "'", "b": "5,000"}) => {"a" => "'", "b" => "5,000"},
+ %({a: "a's, b's and c's", "b": "5,000"}) => {"a" => "a's, b's and c's", "b" => "5,000"},
+ %({a: "2007-01-01"}) => {'a' => Date.new(2007, 1, 1)},
+ %({a: "2007-01-01 01:12:34 Z"}) => {'a' => Time.utc(2007, 1, 1, 1, 12, 34)},
+ # no time zone
+ %({a: "2007-01-01 01:12:34"}) => {'a' => "2007-01-01 01:12:34"},
+ # needs to be *exact*
+ %({a: " 2007-01-01 01:12:34 Z "}) => {'a' => " 2007-01-01 01:12:34 Z "},
+ %([]) => [],
+ %({}) => {},
+ %(1) => 1,
+ %("") => "",
+ %("\\"") => "\"",
+ %(null) => nil,
+ %(true) => true,
+ %(false) => false,
+ %q("http:\/\/test.host\/posts\/1") => "http://test.host/posts/1"
+ }
+
+ TESTS.each do |json, expected|
+ define_method :"test_json_decoding_#{json}" do
+ assert_nothing_raised do
+ assert_equal expected, ActiveSupport::JSON.decode(json)
+ end
+ end
+ end
+
+ def test_failed_json_decoding
+ assert_raises(ActiveSupport::JSON::ParseError) { ActiveSupport::JSON.decode(%({: 1})) }
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/json/encoding_test.rb b/vendor/rails-2.0.2/activesupport/test/json/encoding_test.rb
new file mode 100644
index 000000000..4e4fe5703
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/json/encoding_test.rb
@@ -0,0 +1,111 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+class TestJSONEncoding < Test::Unit::TestCase
+ class Foo
+ def initialize(a, b)
+ @a, @b = a, b
+ end
+ end
+
+ TrueTests = [[ true, %(true) ]]
+ FalseTests = [[ false, %(false) ]]
+ NilTests = [[ nil, %(null) ]]
+ NumericTests = [[ 1, %(1) ],
+ [ 2.5, %(2.5) ]]
+
+ StringTests = [[ 'this is the <string>', %("this is the \\u003Cstring\\u003E")],
+ [ 'a "string" with quotes & an ampersand', %("a \\"string\\" with quotes \\u0026 an ampersand") ],
+ [ 'http://test.host/posts/1', %("http://test.host/posts/1")]]
+
+ ArrayTests = [[ ['a', 'b', 'c'], %([\"a\", \"b\", \"c\"]) ],
+ [ [1, 'a', :b, nil, false], %([1, \"a\", \"b\", null, false]) ]]
+
+ SymbolTests = [[ :a, %("a") ],
+ [ :this, %("this") ],
+ [ :"a b", %("a b") ]]
+
+ ObjectTests = [[ Foo.new(1, 2), %({\"a\": 1, \"b\": 2}) ]]
+
+ VariableTests = [[ ActiveSupport::JSON::Variable.new('foo'), 'foo'],
+ [ ActiveSupport::JSON::Variable.new('alert("foo")'), 'alert("foo")']]
+ RegexpTests = [[ /^a/, '/^a/' ], [/^\w{1,2}[a-z]+/ix, '/^\\w{1,2}[a-z]+/ix']]
+
+ DateTests = [[ Date.new(2005,2,1), %("2005/02/01") ]]
+ TimeTests = [[ Time.utc(2005,2,1,15,15,10), %("2005/02/01 15:15:10 +0000") ]]
+ DateTimeTests = [[ DateTime.civil(2005,2,1,15,15,10), %("2005/02/01 15:15:10 +0000") ]]
+
+ constants.grep(/Tests$/).each do |class_tests|
+ define_method("test_#{class_tests[0..-6].downcase}") do
+ self.class.const_get(class_tests).each do |pair|
+ assert_equal pair.last, pair.first.to_json
+ end
+ end
+ end
+
+ def test_hash_encoding
+ assert_equal %({\"a\": \"b\"}), { :a => :b }.to_json
+ assert_equal %({\"a\": 1}), { 'a' => 1 }.to_json
+ assert_equal %({\"a\": [1, 2]}), { 'a' => [1,2] }.to_json
+ assert_equal %({1: 2}), { 1 => 2 }.to_json
+
+ sorted_json = '{' + {:a => :b, :c => :d}.to_json[1..-2].split(', ').sort.join(', ') + '}'
+ assert_equal %({\"a\": \"b\", \"c\": \"d\"}), sorted_json
+ end
+
+ def test_utf8_string_encoded_properly_when_kcode_is_utf8
+ with_kcode 'UTF8' do
+ assert_equal '"\\u20ac2.99"', '€2.99'.to_json
+ assert_equal '"\\u270e\\u263a"', '✎☺'.to_json
+ end
+ end
+
+ def test_exception_raised_when_encoding_circular_reference
+ a = [1]
+ a << a
+ assert_raises(ActiveSupport::JSON::CircularReferenceError) { a.to_json }
+ end
+
+ def test_hash_key_identifiers_are_always_quoted
+ values = {0 => 0, 1 => 1, :_ => :_, "$" => "$", "a" => "a", :A => :A, :A0 => :A0, "A0B" => "A0B"}
+ assert_equal %w( "$" "A" "A0" "A0B" "_" "a" 0 1 ), object_keys(values.to_json)
+ end
+
+ def test_hash_should_allow_key_filtering_with_only
+ assert_equal %({"a": 1}), { 'a' => 1, :b => 2, :c => 3 }.to_json(:only => 'a')
+ end
+
+ def test_hash_should_allow_key_filtering_with_except
+ assert_equal %({"b": 2}), { 'foo' => 'bar', :b => 2, :c => 3 }.to_json(:except => ['foo', :c])
+ end
+
+ protected
+ def with_kcode(code)
+ if RUBY_VERSION < '1.9'
+ begin
+ old_kcode, $KCODE = $KCODE, 'UTF8'
+ yield
+ ensure
+ $KCODE = old_kcode
+ end
+ else
+ yield
+ end
+ end
+
+ def object_keys(json_object)
+ json_object[1..-2].scan(/([^{}:,\s]+):/).flatten.sort
+ end
+end
+
+uses_mocha 'JsonOptionsTests' do
+ class JsonOptionsTests < Test::Unit::TestCase
+ def test_enumerable_should_passthrough_options_to_elements
+ json_options = { :include => :posts }
+ ActiveSupport::JSON.expects(:encode).with(1, json_options)
+ ActiveSupport::JSON.expects(:encode).with(2, json_options)
+ ActiveSupport::JSON.expects(:encode).with('foo', json_options)
+
+ [1, 2, 'foo'].to_json(json_options)
+ end
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/multibyte_chars_test.rb b/vendor/rails-2.0.2/activesupport/test/multibyte_chars_test.rb
new file mode 100644
index 000000000..6e87ea885
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/multibyte_chars_test.rb
@@ -0,0 +1,173 @@
+require File.dirname(__FILE__) + '/abstract_unit'
+
+$KCODE = 'UTF8'
+
+class CharsTest < Test::Unit::TestCase
+
+ def setup
+ @s = {
+ :utf8 => "Abcd Блå ffi блa 埋",
+ :ascii => "asci ias c iia s",
+ :bytes => "\270\236\010\210\245"
+ }
+ end
+
+ def test_sanity
+ @s.each do |t, s|
+ assert s.respond_to?(:chars), "All string should have the chars method (#{t})"
+ assert s.respond_to?(:to_s), "All string should have the to_s method (#{t})"
+ assert_kind_of ActiveSupport::Multibyte::Chars, s.chars, "#chars should return an instance of Chars (#{t})"
+ end
+ end
+
+ def test_comparability
+ @s.each do |t, s|
+ assert_equal s, s.chars.to_s, "Chars#to_s should return enclosed string unchanged"
+ end
+ assert_nothing_raised do
+ assert_equal "a", "a", "Normal string comparisons should be unaffected"
+ assert_not_equal "a", "b", "Normal string comparisons should be unaffected"
+ assert_not_equal "a".chars, "b".chars, "Chars objects should be comparable"
+ assert_equal "a".chars, "A".downcase.chars, "Chars objects should be comparable to each other"
+ assert_equal "a".chars, "A".downcase, "Chars objects should be comparable to strings coming from elsewhere"
+ end
+
+ assert !@s[:utf8].eql?(@s[:utf8].chars), "Strict comparison is not supported"
+ assert_equal @s[:utf8], @s[:utf8].chars, "Chars should be compared by their enclosed string"
+
+ other_string = @s[:utf8].dup
+ assert_equal other_string, @s[:utf8].chars, "Chars should be compared by their enclosed string"
+ assert_equal other_string.chars, @s[:utf8].chars, "Chars should be compared by their enclosed string"
+
+ strings = ['builder'.chars, 'armor'.chars, 'zebra'.chars]
+ strings.sort!
+ assert_equal ['armor', 'builder', 'zebra'], strings, "Chars should be sortable based on their enclosed string"
+
+ # This leads to a StackLevelTooDeep exception if the comparison is not wired properly
+ assert_raise(NameError) do
+ Chars
+ end
+ end
+
+ def test_utf8?
+ assert @s[:utf8].is_utf8?, "UTF-8 strings are UTF-8"
+ assert @s[:ascii].is_utf8?, "All ASCII strings are also valid UTF-8"
+ assert !@s[:bytes].is_utf8?, "This bytestring isn't UTF-8"
+ end
+
+ # The test for the following methods are defined here because they can only be defined on the Chars class for
+ # various reasons
+
+ def test_gsub
+ assert_equal 'éxa', 'éda'.chars.gsub(/d/, 'x')
+ with_kcode('none') do
+ assert_equal 'éxa', 'éda'.chars.gsub(/d/, 'x')
+ end
+ end
+
+ def test_split
+ word = "efficient"
+ chars = ["e", "ffi", "c", "i", "e", "n", "t"]
+ assert_equal chars, word.split(//)
+ assert_equal chars, word.chars.split(//)
+ assert_kind_of ActiveSupport::Multibyte::Chars, word.chars.split(//).first, "Split should return Chars instances"
+ end
+
+ def test_regexp
+ with_kcode('none') do
+ assert_equal 12, (@s[:utf8].chars =~ /ffi/),
+ "Regex matching should be bypassed to String"
+ end
+ with_kcode('UTF8') do
+ assert_equal 9, (@s[:utf8].chars =~ /ffi/),
+ "Regex matching should be unicode aware"
+ assert_nil((''.chars =~ /\d+/),
+ "Non-matching regular expressions should return nil")
+ end
+ end
+
+ def test_pragma
+ with_kcode('UTF8') do
+ assert " ".chars.send(:utf8_pragma?), "UTF8 pragma should be on because KCODE is UTF8"
+ end
+ with_kcode('none') do
+ assert !" ".chars.send(:utf8_pragma?), "UTF8 pragma should be off"
+ end
+ end
+
+ def test_handler_setting
+ handler = ''.chars.handler
+
+ ActiveSupport::Multibyte::Chars.handler = :first
+ assert_equal :first, ''.chars.handler
+ ActiveSupport::Multibyte::Chars.handler = :second
+ assert_equal :second, ''.chars.handler
+ assert_raise(NoMethodError) do
+ ''.chars.handler.split
+ end
+
+ ActiveSupport::Multibyte::Chars.handler = handler
+ end
+
+ def test_method_chaining
+ assert_kind_of ActiveSupport::Multibyte::Chars, ''.chars.downcase
+ assert_kind_of ActiveSupport::Multibyte::Chars, ''.chars.strip, "Strip should return a Chars object"
+ assert_kind_of ActiveSupport::Multibyte::Chars, ''.chars.downcase.strip, "The Chars object should be " +
+ "forwarded down the call path for chaining"
+ assert_equal 'foo', " FOO ".chars.normalize.downcase.strip, "The Chars that results from the " +
+ " operations should be comparable to the string value of the result"
+ end
+
+ def test_passthrough_on_kcode
+ # The easiest way to check if the passthrough is in place is through #size
+ with_kcode('none') do
+ assert_equal 26, @s[:utf8].chars.size
+ end
+ with_kcode('UTF8') do
+ assert_equal 17, @s[:utf8].chars.size
+ end
+ end
+
+ def test_destructiveness
+ # Note that we're testing the destructiveness here and not the correct behaviour of the methods
+ str = 'ac'
+ str.chars.insert(1, 'b')
+ assert_equal 'abc', str, 'Insert should be destructive for a string'
+
+ str = 'ac'
+ str.chars.reverse!
+ assert_equal 'ca', str, 'reverse! should be destructive for a string'
+ end
+
+ def test_resilience
+ assert_nothing_raised do
+ assert_equal 5, @s[:bytes].chars.size, "The sequence contains five interpretable bytes"
+ end
+ reversed = [0xb8, 0x17e, 0x8, 0x2c6, 0xa5].reverse.pack('U*')
+ assert_nothing_raised do
+ assert_equal reversed, @s[:bytes].chars.reverse.to_s, "Reversing the string should only yield interpretable bytes"
+ end
+ assert_nothing_raised do
+ @s[:bytes].chars.reverse!
+ assert_equal reversed, @s[:bytes].to_s, "Reversing the string should only yield interpretable bytes"
+ end
+ end
+
+ def test_duck_typing
+ assert_equal true, 'test'.chars.respond_to?(:strip)
+ assert_equal true, 'test'.chars.respond_to?(:normalize)
+ assert_equal true, 'test'.chars.respond_to?(:normalize!)
+ assert_equal false, 'test'.chars.respond_to?(:a_method_that_doesnt_exist)
+ end
+
+ protected
+
+ def with_kcode(kcode)
+ old_kcode, $KCODE = $KCODE, kcode
+ begin
+ yield
+ ensure
+ $KCODE = old_kcode
+ end
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/multibyte_conformance.rb b/vendor/rails-2.0.2/activesupport/test/multibyte_conformance.rb
new file mode 100644
index 000000000..dede3e561
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/multibyte_conformance.rb
@@ -0,0 +1,141 @@
+require File.dirname(__FILE__) + '/abstract_unit'
+require 'open-uri'
+
+$KCODE = 'UTF8'
+UNIDATA_URL = "http://www.unicode.org/Public/#{ActiveSupport::Multibyte::UNICODE_VERSION}/ucd"
+UNIDATA_FILE = '/NormalizationTest.txt'
+CACHE_DIR = File.dirname(__FILE__) + '/cache'
+
+class Downloader
+ def self.download(from, to)
+ unless File.exist?(to)
+ $stderr.puts "Downloading #{from} to #{to}"
+ unless File.exist?(File.dirname(to))
+ system "mkdir -p #{File.dirname(to)}"
+ end
+ open(from) do |source|
+ File.open(to, 'w') do |target|
+ source.each_line do |l|
+ target.write l
+ end
+ end
+ end
+ end
+ end
+end
+
+class String
+ # Unicode Inspect returns the codepoints of the string in hex
+ def ui
+ "#{self} " + ("[%s]" % unpack("U*").map{|cp| cp.to_s(16) }.join(' '))
+ end unless ''.respond_to?(:ui)
+end
+
+Dir.mkdir(CACHE_DIR) unless File.exist?(CACHE_DIR)
+Downloader.download(UNIDATA_URL + UNIDATA_FILE, CACHE_DIR + UNIDATA_FILE)
+
+module ConformanceTest
+ def test_normalizations_C
+ each_line_of_norm_tests do |*cols|
+ col1, col2, col3, col4, col5, comment = *cols
+
+ # CONFORMANCE:
+ # 1. The following invariants must be true for all conformant implementations
+ #
+ # NFC
+ # c2 == NFC(c1) == NFC(c2) == NFC(c3)
+ assert_equal col2.ui, @handler.normalize(col1, :c).ui, "Form C - Col 2 has to be NFC(1) - #{comment}"
+ assert_equal col2.ui, @handler.normalize(col2, :c).ui, "Form C - Col 2 has to be NFC(2) - #{comment}"
+ assert_equal col2.ui, @handler.normalize(col3, :c).ui, "Form C - Col 2 has to be NFC(3) - #{comment}"
+ #
+ # c4 == NFC(c4) == NFC(c5)
+ assert_equal col4.ui, @handler.normalize(col4, :c).ui, "Form C - Col 4 has to be C(4) - #{comment}"
+ assert_equal col4.ui, @handler.normalize(col5, :c).ui, "Form C - Col 4 has to be C(5) - #{comment}"
+ end
+ end
+
+ def test_normalizations_D
+ each_line_of_norm_tests do |*cols|
+ col1, col2, col3, col4, col5, comment = *cols
+ #
+ # NFD
+ # c3 == NFD(c1) == NFD(c2) == NFD(c3)
+ assert_equal col3.ui, @handler.normalize(col1, :d).ui, "Form D - Col 3 has to be NFD(1) - #{comment}"
+ assert_equal col3.ui, @handler.normalize(col2, :d).ui, "Form D - Col 3 has to be NFD(2) - #{comment}"
+ assert_equal col3.ui, @handler.normalize(col3, :d).ui, "Form D - Col 3 has to be NFD(3) - #{comment}"
+ # c5 == NFD(c4) == NFD(c5)
+ assert_equal col5.ui, @handler.normalize(col4, :d).ui, "Form D - Col 5 has to be NFD(4) - #{comment}"
+ assert_equal col5.ui, @handler.normalize(col5, :d).ui, "Form D - Col 5 has to be NFD(5) - #{comment}"
+ end
+ end
+
+ def test_normalizations_KC
+ each_line_of_norm_tests do | *cols |
+ col1, col2, col3, col4, col5, comment = *cols
+ #
+ # NFKC
+ # c4 == NFKC(c1) == NFKC(c2) == NFKC(c3) == NFKC(c4) == NFKC(c5)
+ assert_equal col4.ui, @handler.normalize(col1, :kc).ui, "Form D - Col 4 has to be NFKC(1) - #{comment}"
+ assert_equal col4.ui, @handler.normalize(col2, :kc).ui, "Form D - Col 4 has to be NFKC(2) - #{comment}"
+ assert_equal col4.ui, @handler.normalize(col3, :kc).ui, "Form D - Col 4 has to be NFKC(3) - #{comment}"
+ assert_equal col4.ui, @handler.normalize(col4, :kc).ui, "Form D - Col 4 has to be NFKC(4) - #{comment}"
+ assert_equal col4.ui, @handler.normalize(col5, :kc).ui, "Form D - Col 4 has to be NFKC(5) - #{comment}"
+ end
+ end
+
+ def test_normalizations_KD
+ each_line_of_norm_tests do | *cols |
+ col1, col2, col3, col4, col5, comment = *cols
+ #
+ # NFKD
+ # c5 == NFKD(c1) == NFKD(c2) == NFKD(c3) == NFKD(c4) == NFKD(c5)
+ assert_equal col5.ui, @handler.normalize(col1, :kd).ui, "Form KD - Col 5 has to be NFKD(1) - #{comment}"
+ assert_equal col5.ui, @handler.normalize(col2, :kd).ui, "Form KD - Col 5 has to be NFKD(2) - #{comment}"
+ assert_equal col5.ui, @handler.normalize(col3, :kd).ui, "Form KD - Col 5 has to be NFKD(3) - #{comment}"
+ assert_equal col5.ui, @handler.normalize(col4, :kd).ui, "Form KD - Col 5 has to be NFKD(4) - #{comment}"
+ assert_equal col5.ui, @handler.normalize(col5, :kd).ui, "Form KD - Col 5 has to be NFKD(5) - #{comment}"
+ end
+ end
+
+ protected
+ def each_line_of_norm_tests(&block)
+ lines = 0
+ max_test_lines = 0 # Don't limit below 38, because that's the header of the testfile
+ File.open(File.dirname(__FILE__) + '/cache' + UNIDATA_FILE, 'r') do | f |
+ until f.eof? || (max_test_lines > 38 and lines > max_test_lines)
+ lines += 1
+ line = f.gets.chomp!
+ next if (line.empty? || line =~ /^\#/)
+
+ cols, comment = line.split("#")
+ cols = cols.split(";").map{|e| e.strip}.reject{|e| e.empty? }
+ next unless cols.length == 5
+
+ # codepoints are in hex in the test suite, pack wants them as integers
+ cols.map!{|c| c.split.map{|codepoint| codepoint.to_i(16)}.pack("U*") }
+ cols << comment
+
+ yield(*cols)
+ end
+ end
+ end
+end
+
+begin
+ require_library_or_gem('utf8proc_native')
+ require 'active_record/multibyte/handlers/utf8_handler_proc'
+ class ConformanceTestProc < Test::Unit::TestCase
+ include ConformanceTest
+ def setup
+ @handler = ::ActiveSupport::Multibyte::Handlers::UTF8HandlerProc
+ end
+ end
+rescue LoadError
+end
+
+class ConformanceTestPure < Test::Unit::TestCase
+ include ConformanceTest
+ def setup
+ @handler = ::ActiveSupport::Multibyte::Handlers::UTF8Handler
+ end
+end \ No newline at end of file
diff --git a/vendor/rails-2.0.2/activesupport/test/multibyte_handler_test.rb b/vendor/rails-2.0.2/activesupport/test/multibyte_handler_test.rb
new file mode 100644
index 000000000..3384a1a0d
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/multibyte_handler_test.rb
@@ -0,0 +1,367 @@
+require File.dirname(__FILE__) + '/abstract_unit'
+
+$KCODE = 'UTF8'
+
+class String
+ # Unicode Inspect returns the codepoints of the string in hex
+ def ui
+ "#{self} " + ("[%s]" % unpack("U*").map{|cp| cp.to_s(16) }.join(' '))
+ end unless ''.respond_to?(:ui)
+end
+
+module UTF8HandlingTest
+
+ def common_setup
+ # This is an ASCII string with some russian strings and a ligature. It's nicely calibrated, because
+ # slicing it at some specific bytes will kill your characters if you use standard Ruby routines.
+ # It has both capital and standard letters, so that we can test case conversions easily.
+ # It has 26 characters and 28 when the ligature gets split during normalization.
+ @string = "Abcd Блå ffi бла бла бла бла"
+ @string_kd = "Abcd Блå ffi бла бла бла бла"
+ @string_kc = "Abcd Блå ffi бла бла бла бла"
+ @string_c = "Abcd Блå ffi бла бла бла бла"
+ @string_d = "Abcd Блå ffi бла бла бла бла"
+ @bytestring = "\270\236\010\210\245" # Not UTF-8
+
+ # Characters from the character classes as described in UAX #29
+ @character_from_class = {
+ :l => 0x1100, :v => 0x1160, :t => 0x11A8, :lv => 0xAC00, :lvt => 0xAC01, :cr => 0x000D, :lf => 0x000A,
+ :extend => 0x094D, :n => 0x64
+ }
+ end
+
+ def test_utf8_recognition
+ assert ActiveSupport::Multibyte::Handlers::UTF8Handler.consumes?(@string),
+ "Should recognize as a valid UTF-8 string"
+ assert !ActiveSupport::Multibyte::Handlers::UTF8Handler.consumes?(@bytestring), "This is bytestring, not UTF-8"
+ end
+
+ def test_simple_normalization
+ # Normalization of DEVANAGARI LETTER QA breaks when composition exclusion isn't used correctly
+ assert_equal [0x915, 0x93c].pack('U*').ui, [0x915, 0x93c].pack('U*').chars.normalize(:c).to_s.ui
+
+ null_byte_str = "Test\0test"
+
+ assert_equal '', @handler.normalize(''), "Empty string should not break things"
+ assert_equal null_byte_str.ui, @handler.normalize(null_byte_str, :kc).ui, "Null byte should remain"
+ assert_equal null_byte_str.ui, @handler.normalize(null_byte_str, :c).ui, "Null byte should remain"
+ assert_equal null_byte_str.ui, @handler.normalize(null_byte_str, :d).ui, "Null byte should remain"
+ assert_equal null_byte_str.ui, @handler.normalize(null_byte_str, :kd).ui, "Null byte should remain"
+ assert_equal null_byte_str.ui, @handler.decompose(null_byte_str).ui, "Null byte should remain"
+ assert_equal null_byte_str.ui, @handler.compose(null_byte_str).ui, "Null byte should remain"
+
+ comp_str = [
+ 44, # LATIN CAPITAL LETTER D
+ 307, # COMBINING DOT ABOVE
+ 328, # COMBINING OGONEK
+ 323 # COMBINING DOT BELOW
+ ].pack("U*")
+ norm_str_KC = [44,105,106,328,323].pack("U*")
+ norm_str_C = [44,307,328,323].pack("U*")
+ norm_str_D = [44,307,110,780,78,769].pack("U*")
+ norm_str_KD = [44,105,106,110,780,78,769].pack("U*")
+
+ assert_equal norm_str_KC.ui, @handler.normalize(comp_str, :kc).ui, "Should normalize KC"
+ assert_equal norm_str_C.ui, @handler.normalize(comp_str, :c).ui, "Should normalize C"
+ assert_equal norm_str_D.ui, @handler.normalize(comp_str, :d).ui, "Should normalize D"
+ assert_equal norm_str_KD.ui, @handler.normalize(comp_str, :kd).ui, "Should normalize KD"
+
+ assert_raise(ActiveSupport::Multibyte::Handlers::EncodingError) { @handler.normalize(@bytestring) }
+ end
+
+ # Test for the Public Review Issue #29, bad explanation of composition might lead to a
+ # bad implementation: http://www.unicode.org/review/pr-29.html
+ def test_normalization_C_pri_29
+ [
+ [0x0B47, 0x0300, 0x0B3E],
+ [0x1100, 0x0300, 0x1161]
+ ].map { |c| c.pack('U*') }.each do |c|
+ assert_equal c.ui, @handler.normalize(c, :c).ui, "Composition is implemented incorrectly"
+ end
+ end
+
+ def test_casefolding
+ simple_str = "abCdef"
+ simple_str_upcase = "ABCDEF"
+ simple_str_downcase = "abcdef"
+
+ assert_equal '', @handler.downcase(@handler.upcase('')), "Empty string should not break things"
+ assert_equal simple_str_upcase, @handler.upcase(simple_str), "should upcase properly"
+ assert_equal simple_str_downcase, @handler.downcase(simple_str), "should downcase properly"
+ assert_equal simple_str_downcase, @handler.downcase(@handler.upcase(simple_str_downcase)), "upcase and downcase should be mirrors"
+
+ rus_str = "аБвгд\0f"
+ rus_str_upcase = "АБВГД\0F"
+ rus_str_downcase = "абвгд\0f"
+ assert_equal rus_str_upcase, @handler.upcase(rus_str), "should upcase properly honoring null-byte"
+ assert_equal rus_str_downcase, @handler.downcase(rus_str), "should downcase properly honoring null-byte"
+
+ jap_str = "の埋め込み化対応はほぼ完成"
+ assert_equal jap_str, @handler.upcase(jap_str), "Japanse has no upcase, should remain unchanged"
+ assert_equal jap_str, @handler.downcase(jap_str), "Japanse has no downcase, should remain unchanged"
+
+ assert_raise(ActiveSupport::Multibyte::Handlers::EncodingError) { @handler.upcase(@bytestring) }
+ end
+
+ def test_capitalize
+ { 'аБвг аБвг' => 'Абвг абвг',
+ 'аБвг АБВГ' => 'Абвг абвг',
+ 'АБВГ АБВГ' => 'Абвг абвг',
+ '' => '' }.each do |f,t|
+ assert_equal t, @handler.capitalize(f), "Capitalize should work as expected"
+ end
+ assert_raise(ActiveSupport::Multibyte::Handlers::EncodingError) { @handler.capitalize(@bytestring) }
+ end
+
+ def test_translate_offset
+ str = "Блaå" # [2, 2, 1, 2] bytes
+ assert_equal 0, @handler.translate_offset('', 0), "Offset for an empty string makes no sense, return 0"
+ assert_equal 0, @handler.translate_offset(str, 0), "First character, first byte"
+ assert_equal 0, @handler.translate_offset(str, 1), "First character, second byte"
+ assert_equal 1, @handler.translate_offset(str, 2), "Second character, third byte"
+ assert_equal 1, @handler.translate_offset(str, 3), "Second character, fourth byte"
+ assert_equal 2, @handler.translate_offset(str, 4), "Third character, fifth byte"
+ assert_equal 3, @handler.translate_offset(str, 5), "Fourth character, sixth byte"
+ assert_equal 3, @handler.translate_offset(str, 6), "Fourth character, seventh byte"
+ assert_raise(ActiveSupport::Multibyte::Handlers::EncodingError) { @handler.translate_offset(@bytestring, 3) }
+ end
+
+ def test_insert
+ assert_equal '', @handler.insert('', 0, ''), "Empty string should not break things"
+ assert_equal "Abcd Блå ffiБУМ бла бла бла бла", @handler.insert(@string, 10, "БУМ"),
+ "Text should be inserted at right codepoints"
+ assert_equal "Abcd Блå ffiБУМ бла бла бла бла", @string, "Insert should be destructive"
+ assert_raise(ActiveSupport::Multibyte::Handlers::EncodingError) do
+ @handler.insert(@bytestring, 2, "\210")
+ end
+ end
+
+ def test_reverse
+ str = "wБлåa \n"
+ rev = "\n aåлБw"
+ assert_equal '', @handler.reverse(''), "Empty string shouldn't change"
+ assert_equal rev.ui, @handler.reverse(str).ui, "Should reverse properly"
+ assert_raise(ActiveSupport::Multibyte::Handlers::EncodingError) { @handler.reverse(@bytestring) }
+ end
+
+ def test_size
+ assert_equal 0, @handler.size(''), "Empty string has size 0"
+ assert_equal 26, @handler.size(@string), "String length should be 26"
+ assert_equal 26, @handler.length(@string), "String length method should be properly aliased"
+ assert_raise(ActiveSupport::Multibyte::Handlers::EncodingError) { @handler.size(@bytestring) }
+ end
+
+ def test_slice
+ assert_equal 0x41, @handler.slice(@string, 0), "Singular characters should return codepoints"
+ assert_equal 0xE5, @handler.slice(@string, 7), "Singular characters should return codepoints"
+ assert_equal nil, @handler.slice('', -1..1), "Broken range should return nil"
+ assert_equal '', @handler.slice('', 0..10), "Empty string should not break things"
+ assert_equal "d Блå ffi", @handler.slice(@string, 3..9), "Unicode characters have to be returned"
+ assert_equal "d Блå ffi", @handler.slice(@string, 3, 7), "Unicode characters have to be returned"
+ assert_equal "A", @handler.slice(@string, 0, 1), "Slicing from an offset should return characters"
+ assert_equal " Блå ffi ", @handler.slice(@string, 4..10), "Unicode characters have to be returned"
+ assert_equal "ffi бла", @handler.slice(@string, /ffi бла/u), "Slicing on Regexps should be supported"
+ assert_equal "ffi бла", @handler.slice(@string, /ffi \w\wа/u), "Slicing on Regexps should be supported"
+ assert_equal nil, @handler.slice(@string, /unknown/u), "Slicing on Regexps with no match should return nil"
+ assert_equal "ffi бла", @handler.slice(@string, /(ffi бла)/u,1), "Slicing on Regexps with a match group should be supported"
+ assert_equal nil, @handler.slice(@string, /(ffi)/u,2), "Slicing with a Regexp and asking for an invalid match group should return nil"
+ assert_equal "", @handler.slice(@string, 7..6), "Range is empty, should return an empty string"
+ assert_raise(ActiveSupport::Multibyte::Handlers::EncodingError) { @handler.slice(@bytestring, 2..3) }
+ assert_raise(TypeError, "With 2 args, should raise TypeError for non-Numeric or Regexp first argument") { @handler.slice(@string, 2..3, 1) }
+ assert_raise(TypeError, "With 2 args, should raise TypeError for non-Numeric or Regexp second argument") { @handler.slice(@string, 1, 2..3) }
+ assert_raise(ArgumentError, "Should raise ArgumentError when there are more than 2 args") { @handler.slice(@string, 1, 1, 1) }
+ end
+
+ def test_grapheme_cluster_length
+ assert_equal 0, @handler.g_length(''), "String should count 0 grapheme clusters"
+ assert_equal 2, @handler.g_length([0x0924, 0x094D, 0x0930].pack('U*')), "String should count 2 grapheme clusters"
+ assert_equal 1, @handler.g_length(string_from_classes(%w(cr lf))), "Don't cut between CR and LF"
+ assert_equal 1, @handler.g_length(string_from_classes(%w(l l))), "Don't cut between L"
+ assert_equal 1, @handler.g_length(string_from_classes(%w(l v))), "Don't cut between L and V"
+ assert_equal 1, @handler.g_length(string_from_classes(%w(l lv))), "Don't cut between L and LV"
+ assert_equal 1, @handler.g_length(string_from_classes(%w(l lvt))), "Don't cut between L and LVT"
+ assert_equal 1, @handler.g_length(string_from_classes(%w(lv v))), "Don't cut between LV and V"
+ assert_equal 1, @handler.g_length(string_from_classes(%w(lv t))), "Don't cut between LV and T"
+ assert_equal 1, @handler.g_length(string_from_classes(%w(v v))), "Don't cut between V and V"
+ assert_equal 1, @handler.g_length(string_from_classes(%w(v t))), "Don't cut between V and T"
+ assert_equal 1, @handler.g_length(string_from_classes(%w(lvt t))), "Don't cut between LVT and T"
+ assert_equal 1, @handler.g_length(string_from_classes(%w(t t))), "Don't cut between T and T"
+ assert_equal 1, @handler.g_length(string_from_classes(%w(n extend))), "Don't cut before Extend"
+ assert_equal 2, @handler.g_length(string_from_classes(%w(n n))), "Cut between normal characters"
+ assert_equal 3, @handler.g_length(string_from_classes(%w(n cr lf n))), "Don't cut between CR and LF"
+ assert_equal 2, @handler.g_length(string_from_classes(%w(n l v t))), "Don't cut between L, V and T"
+ assert_raise(ActiveSupport::Multibyte::Handlers::EncodingError) { @handler.g_length(@bytestring) }
+ end
+
+ def test_index
+ s = "Καλημέρα κόσμε!"
+ assert_equal 0, @handler.index('', ''), "The empty string is always found at the beginning of the string"
+ assert_equal 0, @handler.index('haystack', ''), "The empty string is always found at the beginning of the string"
+ assert_equal 0, @handler.index(s, 'Κ'), "Greek K is at 0"
+ assert_equal 1, @handler.index(s, 'α'), "Greek Alpha is at 1"
+
+ assert_equal nil, @handler.index(@bytestring, 'a')
+ assert_raise(ActiveSupport::Multibyte::Handlers::EncodingError) { @handler.index(@bytestring, "\010") }
+ end
+
+ def test_indexed_insert
+ s = "Καλη!"
+ @handler[s, 2] = "a"
+ assert_equal "Καaη!", s
+ @handler[s, 2] = "ηη"
+ assert_equal "Καηηη!", s
+ assert_raises(IndexError) { @handler[s, 10] = 'a' }
+ assert_equal "Καηηη!", s
+ @handler[s, 2] = 32
+ assert_equal "Κα ηη!", s
+ @handler[s, 3, 2] = "λλλ"
+ assert_equal "Κα λλλ!", s
+ @handler[s, 1, 0] = "λ"
+ assert_equal "Κλα λλλ!", s
+ assert_raises(IndexError) { @handler[s, 10, 4] = 'a' }
+ assert_equal "Κλα λλλ!", s
+ @handler[s, 4..6] = "ηη"
+ assert_equal "Κλα ηη!", s
+ assert_raises(RangeError) { @handler[s, 10..12] = 'a' }
+ assert_equal "Κλα ηη!", s
+ @handler[s, /ηη/] = "λλλ"
+ assert_equal "Κλα λλλ!", s
+ assert_raises(IndexError) { @handler[s, /ii/] = 'a' }
+ assert_equal "Κλα λλλ!", s
+ @handler[s, /(λλ)(.)/, 2] = "α"
+ assert_equal "Κλα λλα!", s
+ assert_raises(IndexError) { @handler[s, /()/, 10] = 'a' }
+ assert_equal "Κλα λλα!", s
+ @handler[s, "α"] = "η"
+ assert_equal "Κλη λλα!", s
+ @handler[s, "λλ"] = "ααα"
+ assert_equal "Κλη αααα!", s
+ end
+
+ def test_rjust
+ s = "Καη"
+ assert_raises(ArgumentError) { @handler.rjust(s, 10, '') }
+ assert_raises(ArgumentError) { @handler.rjust(s) }
+ assert_equal "Καη", @handler.rjust(s, -3)
+ assert_equal "Καη", @handler.rjust(s, 0)
+ assert_equal "Καη", @handler.rjust(s, 3)
+ assert_equal " Καη", @handler.rjust(s, 5)
+ assert_equal " Καη", @handler.rjust(s, 7)
+ assert_equal "----Καη", @handler.rjust(s, 7, '-')
+ assert_equal "ααααΚαη", @handler.rjust(s, 7, 'α')
+ assert_equal "abaΚαη", @handler.rjust(s, 6, 'ab')
+ assert_equal "αηαΚαη", @handler.rjust(s, 6, 'αη')
+ end
+
+ def test_ljust
+ s = "Καη"
+ assert_raises(ArgumentError) { @handler.ljust(s, 10, '') }
+ assert_raises(ArgumentError) { @handler.ljust(s) }
+ assert_equal "Καη", @handler.ljust(s, -3)
+ assert_equal "Καη", @handler.ljust(s, 0)
+ assert_equal "Καη", @handler.ljust(s, 3)
+ assert_equal "Καη ", @handler.ljust(s, 5)
+ assert_equal "Καη ", @handler.ljust(s, 7)
+ assert_equal "Καη----", @handler.ljust(s, 7, '-')
+ assert_equal "Καηαααα", @handler.ljust(s, 7, 'α')
+ assert_equal "Καηaba", @handler.ljust(s, 6, 'ab')
+ assert_equal "Καηαηα", @handler.ljust(s, 6, 'αη')
+ end
+
+ def test_center
+ s = "Καη"
+ assert_raises(ArgumentError) { @handler.center(s, 10, '') }
+ assert_raises(ArgumentError) { @handler.center(s) }
+ assert_equal "Καη", @handler.center(s, -3)
+ assert_equal "Καη", @handler.center(s, 0)
+ assert_equal "Καη", @handler.center(s, 3)
+ assert_equal "Καη ", @handler.center(s, 4)
+ assert_equal " Καη ", @handler.center(s, 5)
+ assert_equal " Καη ", @handler.center(s, 6)
+ assert_equal "--Καη--", @handler.center(s, 7, '-')
+ assert_equal "--Καη---", @handler.center(s, 8, '-')
+ assert_equal "ααΚαηαα", @handler.center(s, 7, 'α')
+ assert_equal "ααΚαηααα", @handler.center(s, 8, 'α')
+ assert_equal "aΚαηab", @handler.center(s, 6, 'ab')
+ assert_equal "abΚαηab", @handler.center(s, 7, 'ab')
+ assert_equal "ababΚαηabab", @handler.center(s, 11, 'ab')
+ assert_equal "αΚαηαη", @handler.center(s, 6, 'αη')
+ assert_equal "αηΚαηαη", @handler.center(s, 7, 'αη')
+ end
+
+ def test_strip
+ # A unicode aware version of strip should strip all 26 types of whitespace. This includes the NO BREAK SPACE
+ # aka BOM (byte order mark). The byte order mark has no place in UTF-8 because it's used to detect LE and BE.
+ b = "\n" + [
+ 32, # SPACE
+ 8195, # EM SPACE
+ 8199, # FIGURE SPACE,
+ 8201, # THIN SPACE
+ 8202, # HAIR SPACE
+ 65279, # NO BREAK SPACE (ZW)
+ ].pack('U*')
+ m = "word блин\n\n\n word"
+ e = [
+ 65279, # NO BREAK SPACE (ZW)
+ 8201, # THIN SPACE
+ 8199, # FIGURE SPACE,
+ 32, # SPACE
+ ].pack('U*')
+ string = b+m+e
+
+ assert_equal '', @handler.strip(''), "Empty string should stay empty"
+ assert_equal m+e, @handler.lstrip(string), "Whitespace should be gone on the left"
+ assert_equal b+m, @handler.rstrip(string), "Whitespace should be gone on the right"
+ assert_equal m, @handler.strip(string), "Whitespace should be stripped on both sides"
+
+ bs = "\n #{@bytestring} \n\n"
+ assert_equal @bytestring, @handler.strip(bs), "Invalid unicode strings should still strip"
+ end
+
+ def test_tidy_bytes
+ result = [0xb8, 0x17e, 0x8, 0x2c6, 0xa5].pack('U*')
+ assert_equal result, @handler.tidy_bytes(@bytestring)
+ assert_equal "a#{result}a", @handler.tidy_bytes('a' + @bytestring + 'a'),
+ 'tidy_bytes should leave surrounding characters intact'
+ assert_equal "é#{result}é", @handler.tidy_bytes('é' + @bytestring + 'é'),
+ 'tidy_bytes should leave surrounding characters intact'
+ assert_nothing_raised { @handler.tidy_bytes(@bytestring).unpack('U*') }
+
+ assert_equal "\xC3\xA7", @handler.tidy_bytes("\xE7") # iso_8859_1: small c cedilla
+ assert_equal "\xC2\xA9", @handler.tidy_bytes("\xA9") # iso_8859_1: copyright symbol
+ assert_equal "\xE2\x80\x9C", @handler.tidy_bytes("\x93") # win_1252: left smart quote
+ assert_equal "\xE2\x82\xAC", @handler.tidy_bytes("\x80") # win_1252: euro
+ assert_equal "\x00", @handler.tidy_bytes("\x00") # null char
+ assert_equal [0xfffd].pack('U'), @handler.tidy_bytes("\xef\xbf\xbd") # invalid char
+ end
+
+ protected
+
+ def string_from_classes(classes)
+ classes.collect do |k|
+ @character_from_class[k.intern]
+ end.pack('U*')
+ end
+end
+
+
+begin
+ require_library_or_gem('utf8proc_native')
+ require 'active_record/multibyte/handlers/utf8_handler_proc'
+ class UTF8HandlingTestProc < Test::Unit::TestCase
+ include UTF8HandlingTest
+ def setup
+ common_setup
+ @handler = ::ActiveSupport::Multibyte::Handlers::UTF8HandlerProc
+ end
+ end
+rescue LoadError
+end
+
+class UTF8HandlingTestPure < Test::Unit::TestCase
+ include UTF8HandlingTest
+ def setup
+ common_setup
+ @handler = ::ActiveSupport::Multibyte::Handlers::UTF8Handler
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/option_merger_test.rb b/vendor/rails-2.0.2/activesupport/test/option_merger_test.rb
new file mode 100644
index 000000000..0cddfe8c2
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/option_merger_test.rb
@@ -0,0 +1,50 @@
+require File.dirname(__FILE__) + '/abstract_unit'
+
+class OptionMergerTest < Test::Unit::TestCase
+ def setup
+ @options = {:hello => 'world'}
+ end
+
+ def test_method_with_options_merges_options_when_options_are_present
+ local_options = {:cool => true}
+
+ with_options(@options) do |o|
+ assert_equal local_options, method_with_options(local_options)
+ assert_equal @options.merge(local_options),
+ o.method_with_options(local_options)
+ end
+ end
+
+ def test_method_with_options_appends_options_when_options_are_missing
+ with_options(@options) do |o|
+ assert_equal Hash.new, method_with_options
+ assert_equal @options, o.method_with_options
+ end
+ end
+
+ def test_method_with_options_allows_to_overwrite_options
+ local_options = {:hello => 'moon'}
+ assert_equal @options.keys, local_options.keys
+
+ with_options(@options) do |o|
+ assert_equal local_options, method_with_options(local_options)
+ assert_equal @options.merge(local_options),
+ o.method_with_options(local_options)
+ assert_equal local_options, o.method_with_options(local_options)
+ end
+ with_options(local_options) do |o|
+ assert_equal local_options.merge(@options),
+ o.method_with_options(@options)
+ end
+ end
+
+ # Needed when counting objects with the ObjectSpace
+ def test_option_merger_class_method
+ assert_equal ActiveSupport::OptionMerger, ActiveSupport::OptionMerger.new('', '').class
+ end
+
+ private
+ def method_with_options(options = {})
+ options
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/ordered_options_test.rb b/vendor/rails-2.0.2/activesupport/test/ordered_options_test.rb
new file mode 100644
index 000000000..bf7339ac5
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/ordered_options_test.rb
@@ -0,0 +1,84 @@
+require File.dirname(__FILE__) + '/abstract_unit'
+
+class OrderedHashTest < Test::Unit::TestCase
+ def setup
+ @keys = %w( blue green red pink orange )
+ @values = %w( 000099 009900 aa0000 cc0066 cc6633 )
+ @ordered_hash = ActiveSupport::OrderedHash.new
+
+ @keys.each_with_index do |key, index|
+ @ordered_hash[key] = @values[index]
+ end
+ end
+
+ def test_order
+ assert_equal @keys, @ordered_hash.keys
+ assert_equal @values, @ordered_hash.values
+ end
+
+ def test_access
+ assert @keys.zip(@values).all? { |k, v| @ordered_hash[k] == v }
+ end
+
+ def test_assignment
+ key, value = 'purple', '5422a8'
+
+ @ordered_hash[key] = value
+ assert_equal @keys.length + 1, @ordered_hash.length
+ assert_equal key, @ordered_hash.keys.last
+ assert_equal value, @ordered_hash.values.last
+ assert_equal value, @ordered_hash[key]
+ end
+end
+
+class OrderedOptionsTest < Test::Unit::TestCase
+ def test_usage
+ a = OrderedOptions.new
+
+ assert_nil a[:not_set]
+
+ a[:allow_concurreny] = true
+ assert_equal 1, a.size
+ assert a[:allow_concurreny]
+
+ a[:allow_concurreny] = false
+ assert_equal 1, a.size
+ assert !a[:allow_concurreny]
+
+ a["else_where"] = 56
+ assert_equal 2, a.size
+ assert_equal 56, a[:else_where]
+ end
+
+ def test_looping
+ a = OrderedOptions.new
+
+ a[:allow_concurreny] = true
+ a["else_where"] = 56
+
+ test = [[:allow_concurreny, true], [:else_where, 56]]
+
+ a.each_with_index do |(key, value), index|
+ assert_equal test[index].first, key
+ assert_equal test[index].last, value
+ end
+ end
+
+ def test_method_access
+ a = OrderedOptions.new
+
+ assert_nil a.not_set
+
+ a.allow_concurreny = true
+ assert_equal 1, a.size
+ assert a.allow_concurreny
+
+ a.allow_concurreny = false
+ assert_equal 1, a.size
+ assert !a.allow_concurreny
+
+ a.else_where = 56
+ assert_equal 2, a.size
+ assert_equal 56, a.else_where
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/test_test.rb b/vendor/rails-2.0.2/activesupport/test/test_test.rb
new file mode 100644
index 000000000..eecbd31f9
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/test_test.rb
@@ -0,0 +1,73 @@
+require File.dirname(__FILE__) + '/abstract_unit'
+require 'active_support/test_case'
+class AssertDifferenceTest < Test::Unit::TestCase
+ def setup
+ @object = Class.new do
+ attr_accessor :num
+ def increment
+ self.num += 1
+ end
+
+ def decrement
+ self.num -= 1
+ end
+ end.new
+ @object.num = 0
+ end
+
+ if lambda { }.respond_to?(:binding)
+ def test_assert_no_difference
+ assert_no_difference '@object.num' do
+ # ...
+ end
+ end
+
+ def test_assert_difference
+ assert_difference '@object.num', +1 do
+ @object.increment
+ end
+ end
+
+ def test_assert_difference_with_implicit_difference
+ assert_difference '@object.num' do
+ @object.increment
+ end
+ end
+
+ def test_arbitrary_expression
+ assert_difference '@object.num + 1', +2 do
+ @object.increment
+ @object.increment
+ end
+ end
+
+ def test_negative_differences
+ assert_difference '@object.num', -1 do
+ @object.decrement
+ end
+ end
+
+ def test_expression_is_evaluated_in_the_appropriate_scope
+ local_scope = 'foo'
+ silence_warnings do
+ assert_difference('local_scope; @object.num') { @object.increment }
+ end
+ end
+
+ def test_array_of_expressions
+ assert_difference [ '@object.num', '@object.num + 1' ], +1 do
+ @object.increment
+ end
+ end
+ else
+ def default_test; end
+ end
+end
+
+# These should always pass
+class NotTestingThingsTest < Test::Unit::TestCase
+ include ActiveSupport::Testing::Default
+end
+
+class AlsoDoingNothingTest < ActiveSupport::TestCase
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/time_zone_test.rb b/vendor/rails-2.0.2/activesupport/test/time_zone_test.rb
new file mode 100644
index 000000000..c2a3e1c53
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/time_zone_test.rb
@@ -0,0 +1,98 @@
+require File.dirname(__FILE__) + '/abstract_unit'
+
+class TimeZoneTest < Test::Unit::TestCase
+ class MockTime
+ def self.now
+ Time.utc( 2004, 7, 25, 14, 49, 00 )
+ end
+
+ def self.local(*args)
+ Time.utc(*args)
+ end
+ end
+
+ TimeZone::Time = MockTime
+
+ def test_formatted_offset_positive
+ zone = TimeZone.create( "Test", 4200 )
+ assert_equal "+01:10", zone.formatted_offset
+ end
+
+ def test_formatted_offset_negative
+ zone = TimeZone.create( "Test", -4200 )
+ assert_equal "-01:10", zone.formatted_offset
+ end
+
+ def test_now
+ zone = TimeZone.create( "Test", 4200 )
+ assert_equal Time.local(2004,7,25,15,59,00).to_a[0,6], zone.now.to_a[0,6]
+ end
+
+ def test_today
+ zone = TimeZone.create( "Test", 43200 )
+ assert_equal Date.new(2004,7,26), zone.today
+ end
+
+ def test_adjust_negative
+ zone = TimeZone.create( "Test", -4200 ) # 4200s == 70 mins
+ assert_equal Time.utc(2004,7,24,23,55,0), zone.adjust(Time.utc(2004,7,25,1,5,0))
+ end
+
+ def test_adjust_positive
+ zone = TimeZone.create( "Test", 4200 )
+ assert_equal Time.utc(2004,7,26,1,5,0), zone.adjust(Time.utc(2004,7,25,23,55,0))
+ end
+
+ def test_unadjust
+ zone = TimeZone.create( "Test", 4200 )
+ expect = Time.utc(2004,7,24,23,55,0).to_a[0,6]
+ actual = zone.unadjust(Time.utc(2004,7,25,1,5,0)).to_a[0,6]
+ assert_equal expect, actual
+ end
+
+ def test_zone_compare
+ zone1 = TimeZone.create( "Test1", 4200 )
+ zone2 = TimeZone.create( "Test1", 5600 )
+ assert zone1 < zone2
+ assert zone2 > zone1
+
+ zone1 = TimeZone.create( "Able", 10000 )
+ zone2 = TimeZone.create( "Zone", 10000 )
+ assert zone1 < zone2
+ assert zone2 > zone1
+
+ zone1 = TimeZone.create( "Able", 10000 )
+ assert zone1 == zone1
+ end
+
+ def test_to_s
+ zone = TimeZone.create( "Test", 4200 )
+ assert_equal "(UTC+01:10) Test", zone.to_s
+ end
+
+ def test_all_sorted
+ all = TimeZone.all
+ 1.upto( all.length-1 ) do |i|
+ assert all[i-1] < all[i]
+ end
+ end
+
+ def test_index
+ assert_nil TimeZone["bogus"]
+ assert_not_nil TimeZone["Central Time (US & Canada)"]
+ assert_not_nil TimeZone[8]
+ assert_raises(ArgumentError) { TimeZone[false] }
+ end
+
+ def test_new
+ a = TimeZone.new("Berlin")
+ b = TimeZone.new("Berlin")
+ assert_same a, b
+ assert_nil TimeZone.new("bogus")
+ end
+
+ def test_us_zones
+ assert TimeZone.us_zones.include?(TimeZone["Hawaii"])
+ assert !TimeZone.us_zones.include?(TimeZone["Kuala Lumpur"])
+ end
+end
diff --git a/vendor/rails-2.0.2/activesupport/test/whiny_nil_test.rb b/vendor/rails-2.0.2/activesupport/test/whiny_nil_test.rb
new file mode 100644
index 000000000..4483134be
--- /dev/null
+++ b/vendor/rails-2.0.2/activesupport/test/whiny_nil_test.rb
@@ -0,0 +1,38 @@
+# Stub to enable testing without Active Record
+module ActiveRecord
+ class Base
+ def save!
+ end
+ end
+end
+
+require File.dirname(__FILE__) + '/abstract_unit'
+require 'active_support/whiny_nil'
+
+class WhinyNilTest < Test::Unit::TestCase
+ def test_unchanged
+ nil.method_thats_not_in_whiners
+ rescue NoMethodError => nme
+ assert_match(/nil.method_thats_not_in_whiners/, nme.message)
+ end
+
+ def test_active_record
+ nil.save!
+ rescue NoMethodError => nme
+ assert(!(nme.message =~ /nil:NilClass/))
+ assert_match(/nil\.save!/, nme.message)
+ end
+
+ def test_array
+ nil.each
+ rescue NoMethodError => nme
+ assert(!(nme.message =~ /nil:NilClass/))
+ assert_match(/nil\.each/, nme.message)
+ end
+
+ def test_id
+ nil.id
+ rescue RuntimeError => nme
+ assert(!(nme.message =~ /nil:NilClass/))
+ end
+end