Fix dependencies revealed by testing in isolation

This commit is contained in:
Jeremy Kemper 2009-04-22 17:41:28 -07:00
parent 5c4ba6e3fc
commit f28bd9557c
61 changed files with 127 additions and 32 deletions

View File

@ -21,6 +21,12 @@ Rake::TestTask.new { |t|
t.verbose = true
t.warning = true
}
task :isolated_test do
Dir['test/**/*_test.rb'].all? do |file|
ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME'))
system(ruby, '-Ilib:test', file)
end or raise "Failures"
end
# Create compressed packages
dist_dirs = [ "lib", "test"]

View File

@ -2,6 +2,7 @@ require 'benchmark'
require 'active_support/core_ext/benchmark'
require 'active_support/core_ext/exception'
require 'active_support/core_ext/class/attribute_accessors'
require 'active_support/core_ext' # FIXME: pulling in all to_param extensions
module ActiveSupport
# See ActiveSupport::Cache::Store for documentation.

View File

@ -1,3 +1,5 @@
require 'active_support/core_ext/object/duplicable'
module ActiveSupport
module Cache
module Strategy

View File

@ -1,3 +1,5 @@
require 'active_support/core_ext/array/extract_options'
module ActiveSupport
# Callbacks are hooks into the lifecycle of an object that allow you to trigger logic
# before or after an alteration of the object state.

View File

@ -1,3 +1,7 @@
require 'active_support/core_ext/hash/keys'
require 'active_support/core_ext/hash/reverse_merge'
require 'active_support/inflector'
class Array
# Converts the array to a comma-separated sentence where the last element is joined by the connector word. Options:
# * <tt>:words_connector</tt> - The sign or word used to join the elements in arrays with two or more elements (default: ", ")
@ -155,7 +159,7 @@ class Array
raise "Not all elements respond to to_xml" unless all? { |e| e.respond_to? :to_xml }
require 'builder' unless defined?(Builder)
options[:root] ||= all? { |e| e.is_a?(first.class) && first.class.to_s != "Hash" } ? first.class.to_s.underscore.pluralize : "records"
options[:root] ||= all? { |e| e.is_a?(first.class) && first.class.to_s != "Hash" } ? ActiveSupport::Inflector.pluralize(ActiveSupport::Inflector.underscore(first.class.name)) : "records"
options[:children] ||= options[:root].singularize
options[:indent] ||= 2
options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])

View File

@ -1,3 +1,5 @@
require 'active_support/core_ext/object/duplicable'
# Retain for backward compatibility. Methods are now included in Class.
module ClassInheritableAttributes # :nodoc:
end
@ -216,4 +218,4 @@ class Class
extlib_inheritable_reader(*syms)
extlib_inheritable_writer(*syms)
end
end
end

View File

@ -1,3 +1,6 @@
require 'active_support/core_ext/object/extending'
require 'active_support/core_ext/module/introspection'
class Class #:nodoc:
# Unassociates the class with its subclasses and removes the subclasses

View File

@ -1,3 +1,5 @@
require 'active_support/duration'
class Date
class << self
# Returns a new Date representing the date 1 day ago (i.e. yesterday's date).

View File

@ -1,4 +1,6 @@
require 'active_support/inflector'
require 'active_support/core_ext/time/conversions'
require 'active_support/core_ext/date_time/conversions'
class Date
DATE_FORMATS = {

View File

@ -1,5 +1,4 @@
require 'date'
require 'active_support/core_ext/time'
require 'active_support/core_ext/date_time/acts_like'
require 'active_support/core_ext/date_time/calculations'
require 'active_support/core_ext/date_time/conversions'

View File

@ -1,6 +1,8 @@
require 'date'
require 'active_support/core_ext/object/conversions'
require 'active_support/core_ext/array/conversions'
require 'active_support/core_ext/hash/reverse_merge'
require 'active_support/core/time'
class Hash
# This module exists to decorate files deserialized using Hash.from_xml with

View File

@ -1,6 +1,7 @@
# Adds the 'around_level' method to Logger.
require 'active_support/core_ext/class/attribute_accessors'
class Logger
# Adds the 'around_level' method to Logger.
class Logger #:nodoc:
def self.define_around_helper(level)
module_eval <<-end_eval
def around_#{level}(before_message, after_message, &block) # def around_debug(before_message, after_message, &block)

View File

@ -22,11 +22,11 @@ class Module
alias_method :attr_internal, :attr_internal_accessor
private
mattr_accessor :attr_internal_naming_format
self.attr_internal_naming_format = '@_%s'
class << self; attr_accessor :attr_internal_naming_format end
self.attr_internal_naming_format = '@_%s'
private
def attr_internal_ivar_name(attr)
attr_internal_naming_format % attr
Module.attr_internal_naming_format % attr
end
end

View File

@ -1,3 +1,5 @@
require 'active_support/inflector'
class Module
# Returns the name of the module containing this one.
#
@ -26,7 +28,7 @@ class Module
# p Module.new.parent # => Object
#
def parent
parent_name ? parent_name.constantize : Object
parent_name ? ActiveSupport::Inflector.constantize(parent_name) : Object
end
# Returns all the parents of this module according to its name, ordered from
@ -47,7 +49,7 @@ class Module
if parent_name
parts = parent_name.split('::')
until parts.empty?
parents << (parts * '::').constantize
parents << ActiveSupport::Inflector.constantize(parts * '::')
parts.pop
end
end

View File

@ -1,13 +1,15 @@
require 'active_support/inflector'
module ActiveSupport
class ModelName < String
attr_reader :singular, :plural, :cache_key, :partial_path
def initialize(name)
super
@singular = underscore.tr('/', '_').freeze
@plural = @singular.pluralize.freeze
@singular = ActiveSupport::Inflector.underscore(self).tr('/', '_').freeze
@plural = ActiveSupport::Inflector.pluralize(@singular).freeze
@cache_key = tableize.freeze
@partial_path = "#{@cache_key}/#{demodulize.underscore}".freeze
@partial_path = "#{@cache_key}/#{ActiveSupport::Inflector.underscore(ActiveSupport::Inflector.demodulize(self))}".freeze
end
end
end

View File

@ -1,3 +1,5 @@
require 'active_support/core_ext/module/aliasing'
class Module
# Synchronize access around a method, delegating synchronization to a
# particular mutex. A mutex (either a Mutex, or any object that responds to

View File

@ -1,3 +1,5 @@
require 'active_support/duration'
class Numeric
# Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.years.
#

View File

@ -1,3 +1,4 @@
require 'active_support/core_ext/object/acts_like'
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/object/duplicable'
require 'active_support/core_ext/object/try'

View File

@ -1,3 +1,5 @@
require 'active_support/core_ext/module/aliasing'
class Range
begin
(1..2).step

View File

@ -1,4 +1,5 @@
require 'date'
require 'active_support/core_ext/time/calculations'
class String
# 'a'.ord == 'a'[0] for Ruby 1.9 forward compatibility.

View File

@ -1,4 +1,5 @@
# encoding: utf-8
require 'active_support/multibyte'
class String
unless '1.9'.respond_to?(:force_encoding)

View File

@ -1,11 +1,13 @@
require 'set'
require 'thread'
require 'active_support/inflector'
require 'active_support/core_ext/name_error'
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/module/aliasing'
require 'active_support/core_ext/module/attribute_accessors'
require 'active_support/core_ext/module/introspection'
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/load_error'
require 'active_support/core_ext/name_error'
require 'active_support/core_ext/string/starts_ends_with'
require 'active_support/inflector'
module ActiveSupport #:nodoc:
module Dependencies #:nodoc:

View File

@ -1,4 +1,5 @@
require 'active_support/core_ext/module/deprecation'
require 'active_support/core_ext/module/aliasing'
module ActiveSupport
class << Deprecation

View File

@ -1,3 +1,5 @@
require 'active_support/inflector'
module ActiveSupport
module Deprecation
class DeprecationProxy #:nodoc:
@ -61,7 +63,7 @@ module ActiveSupport
private
def target
@new_const.to_s.constantize
ActiveSupport::Inflector.constantize(@new_const.to_s)
end
def warn(callstack, called, args)

View File

@ -1,4 +1,5 @@
require 'active_support/basic_object'
require 'active_support/core_ext/array/conversions'
module ActiveSupport
# Provides accurate date and time measurements using Date#advance and

View File

@ -1,6 +1,7 @@
# encoding: utf-8
require 'iconv'
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/string/access'
require 'active_support/core_ext/string/multibyte'
module ActiveSupport

View File

@ -1,3 +1,5 @@
require 'active_support/core_ext/time/conversions'
class Time
# Returns a JSON string representing the time. If ActiveSupport.use_standard_json_time_format is set to true, the
# ISO 8601 format is used.

View File

@ -1,3 +1,5 @@
require 'active_support/core_ext/object/metaclass'
module ActiveSupport
module SafelyMemoizable
def safely_memoize(*symbols)

View File

@ -4,6 +4,8 @@ require 'active_support/multibyte/chars'
require 'active_support/multibyte/exceptions'
require 'active_support/multibyte/unicode_database'
require 'active_support/core_ext/module/attribute_accessors'
module ActiveSupport #:nodoc:
module Multibyte
# A list of all available normalization forms. See http://www.unicode.org/reports/tr15/tr15-29.html for more

View File

@ -1,3 +1,5 @@
require 'active_support/core_ext/array/wrap'
module ActiveSupport
module Testing
module Assertions

View File

@ -131,7 +131,7 @@ module ActiveSupport
# Time.utc(2005,2,1,15,15,10).in_time_zone.to_json
# # => "2005/02/01 15:15:10 +0000"
def to_json(options = nil)
if ActiveSupport.use_standard_json_time_format
if !ActiveSupport.respond_to?(:use_standard_json_time_format) || ActiveSupport.use_standard_json_time_format
xmlschema.inspect
else
%("#{time.strftime("%Y/%m/%d %H:%M:%S")} #{formatted_offset(false)}")

View File

@ -1,3 +1,5 @@
require 'active_support/core_ext/module/delegation'
module ActiveSupport
# = XmlMini
#

View File

@ -1,3 +1,5 @@
require 'active_support/core_ext/object/blank'
# = XmlMini ReXML implementation
module ActiveSupport
module XmlMini_REXML #:nodoc:

View File

@ -4,11 +4,13 @@ require 'fileutils'
require 'active_support/buffered_logger'
class BufferedLoggerTest < Test::Unit::TestCase
Logger = ActiveSupport::BufferedLogger
def setup
@message = "A debug message"
@integer_message = 12345
@output = StringIO.new
@logger = ActiveSupport::BufferedLogger.new(@output)
@logger = Logger.new(@output)
end
def test_should_log_debugging_message_when_debugging
@ -76,9 +78,9 @@ class BufferedLoggerTest < Test::Unit::TestCase
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
assert_equal Logger::MAX_BUFFER_SIZE, @logger.auto_flushing
(ActiveSupport::BufferedLogger::MAX_BUFFER_SIZE - 1).times do
(Logger::MAX_BUFFER_SIZE - 1).times do
@logger.info 'wait for it..'
assert @output.string.empty?, @output.string
end
@ -89,8 +91,8 @@ class BufferedLoggerTest < Test::Unit::TestCase
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
Logger::Severity.constants.each do |level|
@logger.level = Logger::Severity.const_get(level) - 1
assert @logger.send("#{level.downcase}?"), "didn't know if it was #{level.downcase}? or below"
end
end
@ -111,7 +113,7 @@ class BufferedLoggerTest < Test::Unit::TestCase
tmp_directory = File.join(File.dirname(__FILE__), "tmp")
log_file = File.join(tmp_directory, "development.log")
assert !File.exist?(tmp_directory)
@logger = ActiveSupport::BufferedLogger.new(log_file)
@logger = Logger.new(log_file)
assert File.exist?(tmp_directory)
ensure
FileUtils.rm_rf(tmp_directory)

View File

@ -1,6 +1,9 @@
require 'abstract_unit'
require 'active_support/core_ext/array'
require 'active_support/core_ext/big_decimal'
require 'active_support/core_ext/object/conversions'
require 'active_support/core_ext' # FIXME: pulling in all to_xml extensions
class ArrayExtAccessTests < Test::Unit::TestCase
def test_from

View File

@ -1,4 +1,5 @@
require 'abstract_unit'
require 'active_support/core_ext/object/blank'
class EmptyTrue
def empty?() true; end

View File

@ -1,4 +1,5 @@
require 'abstract_unit'
require 'active_support/core_ext/class/attribute_accessors'
class ClassAttributeAccessorTest < Test::Unit::TestCase
def setup

View File

@ -1,4 +1,5 @@
require 'abstract_unit'
require 'active_support/core_ext/class/inheritable_attributes'
class ClassInheritableAttributesTest < Test::Unit::TestCase
def setup

View File

@ -1,4 +1,5 @@
require 'abstract_unit'
require 'active_support/core_ext/date_time'
class DateTimeExtCalculationsTest < Test::Unit::TestCase
def test_to_s

View File

@ -1,4 +1,6 @@
require 'abstract_unit'
require 'bigdecimal'
require 'active_support/core_ext/object/duplicable'
class DuplicableTest < Test::Unit::TestCase
NO = [nil, false, true, :symbol, 1, 2.3, BigDecimal.new('4.56'), Class.new]

View File

@ -1,4 +1,5 @@
require 'abstract_unit'
require 'active_support/core/time'
class DurationTest < ActiveSupport::TestCase
def test_inspect

View File

@ -1,4 +1,5 @@
require 'abstract_unit'
require 'active_support/core_ext/exception'
class ExceptionExtTests < Test::Unit::TestCase

View File

@ -1,5 +1,7 @@
require 'abstract_unit'
require 'active_support/core_ext/hash'
require 'bigdecimal'
require 'active_support/core_ext/string/access'
class HashExtTest < Test::Unit::TestCase
def setup

View File

@ -1,4 +1,5 @@
require 'abstract_unit'
require 'active_support/core_ext/module/attr_accessor_with_default'
class AttrAccessorWithDefaultTest < Test::Unit::TestCase
def setup

View File

@ -1,4 +1,5 @@
require 'abstract_unit'
require 'active_support/core_ext/module/attr_internal'
class AttrInternalTest < Test::Unit::TestCase
def setup
@ -37,8 +38,8 @@ class AttrInternalTest < Test::Unit::TestCase
end
def test_naming_format
assert_equal '@_%s', @target.attr_internal_naming_format
assert_nothing_raised { @target.attr_internal_naming_format = '@abc%sdef' }
assert_equal '@_%s', Module.attr_internal_naming_format
assert_nothing_raised { Module.attr_internal_naming_format = '@abc%sdef' }
@target.attr_internal :foo
assert !@instance.instance_variable_defined?('@_foo')
@ -47,6 +48,6 @@ class AttrInternalTest < Test::Unit::TestCase
assert !@instance.instance_variable_defined?('@_foo')
assert @instance.instance_variable_defined?('@abcfoodef')
ensure
@target.attr_internal_naming_format = '@_%s'
Module.attr_internal_naming_format = '@_%s'
end
end

View File

@ -1,4 +1,5 @@
require 'abstract_unit'
require 'active_support/core_ext/module/attribute_accessors'
class ModuleAttributeAccessorTest < Test::Unit::TestCase
def setup

View File

@ -1,4 +1,5 @@
require 'abstract_unit'
require 'active_support/core_ext/module/model_naming'
class ModelNamingTest < Test::Unit::TestCase
def setup

View File

@ -1,4 +1,5 @@
require 'abstract_unit'
require 'active_support/core_ext/name_error'
class NameErrorTest < Test::Unit::TestCase
def test_name_error_should_set_missing_name

View File

@ -1,6 +1,7 @@
require 'abstract_unit'
require 'active_support/core_ext/numeric/bytes'
require 'active_support/core_ext/numeric'
require 'active_support/core_ext/integer'
require 'active_support/core/time'
class NumericExtTimeAndDateTimeTest < Test::Unit::TestCase
def setup

View File

@ -1,5 +1,7 @@
require 'abstract_unit'
require 'active_support/core_ext/object'
require 'active_support/core_ext/class/removal'
require 'active_support/core/time'
class ClassA; end
class ClassB < ClassA; end

View File

@ -1,4 +1,5 @@
require 'abstract_unit'
require 'active_support/core_ext/proc'
class ProcTests < Test::Unit::TestCase
def test_bind_returns_method_with_changed_self

View File

@ -1,5 +1,6 @@
require 'abstract_unit'
require 'active_support/core_ext/range'
require 'active_support/core_ext/date/conversions'
class RangeTest < Test::Unit::TestCase
def test_to_s_from_dates

View File

@ -4,6 +4,7 @@ require 'abstract_unit'
require 'inflector_test_cases'
require 'active_support/core_ext/string'
require 'active_support/core_ext/time'
class StringInflectionsTest < Test::Unit::TestCase
include InflectorTestCases

View File

@ -1,4 +1,5 @@
require 'abstract_unit'
require 'active_support/core/time'
class TimeExtCalculationsTest < Test::Unit::TestCase
def test_seconds_since_midnight

View File

@ -1,5 +1,6 @@
require 'abstract_unit'
require 'active_support/time_with_zone'
require 'active_support/json'
class TimeWithZoneTest < Test::Unit::TestCase

View File

@ -1,6 +1,8 @@
require 'abstract_unit'
require 'pp'
require 'active_support/dependencies'
require 'active_support/core_ext/module/loading'
require 'active_support/core_ext/kernel/reporting'
module ModuleWithMissing
mattr_accessor :missing_count

View File

@ -1,4 +1,6 @@
require 'abstract_unit'
require 'active_support/core/time'
require 'active_support/core_ext/array/conversions'
class I18nTest < Test::Unit::TestCase
def setup

View File

@ -1,4 +1,6 @@
require 'abstract_unit'
require 'active_support/inflector'
require 'inflector_test_cases'
module Ace

View File

@ -1,4 +1,5 @@
require 'abstract_unit'
require 'active_support/core_ext/kernel/reporting'
class AssertDifferenceTest < ActiveSupport::TestCase
def setup

View File

@ -1,4 +1,5 @@
require 'abstract_unit'
require 'active_support/core/time'
class TimeZoneTest < Test::Unit::TestCase
def test_utc_to_local

View File

@ -1,5 +1,6 @@
require 'abstract_unit'
require 'active_support/xml_mini'
require 'active_support/core_ext/hash/conversions'
begin
gem 'nokogiri', '>= 1.1.1'