Changeset 4595
- Timestamp:
- 07/08/06 18:14:49 (2 years ago)
- Files:
-
- trunk/actionpack/lib/action_controller/benchmarking.rb (modified) (1 diff)
- trunk/actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb (modified) (1 diff)
- trunk/actionpack/lib/action_controller/cgi_process.rb (modified) (2 diffs)
- trunk/actionpack/lib/action_controller/components.rb (modified) (1 diff)
- trunk/actionpack/lib/action_controller/flash.rb (modified) (1 diff)
- trunk/actionpack/lib/action_controller/test_process.rb (modified) (2 diffs)
- trunk/actionpack/lib/action_view/helpers/form_helper.rb (modified) (2 diffs)
- trunk/actionpack/lib/action_view/helpers/text_helper.rb (modified) (2 diffs)
- trunk/actionpack/test/controller/helper_test.rb (modified) (1 diff)
- trunk/actionpack/test/template/active_record_helper_test.rb (modified) (5 diffs)
- trunk/actionpack/test/template/prototype_helper_test.rb (modified) (1 diff)
- trunk/activesupport/test/abstract_unit.rb (added)
- trunk/activesupport/test/caching_tools_test.rb (modified) (7 diffs)
- trunk/activesupport/test/class_inheritable_attributes_test.rb (modified) (1 diff)
- trunk/activesupport/test/clean_logger_test.rb (modified) (1 diff)
- trunk/activesupport/test/core_ext/array_ext_test.rb (modified) (9 diffs)
- trunk/activesupport/test/core_ext/blank_test.rb (modified) (1 diff)
- trunk/activesupport/test/core_ext/cgi_ext_test.rb (modified) (1 diff)
- trunk/activesupport/test/core_ext/class_test.rb (modified) (1 diff)
- trunk/activesupport/test/core_ext/date_ext_test.rb (modified) (2 diffs)
- trunk/activesupport/test/core_ext/enumerable_test.rb (modified) (2 diffs)
- trunk/activesupport/test/core_ext/exception_test.rb (modified) (7 diffs)
- trunk/activesupport/test/core_ext/hash_ext_test.rb (modified) (1 diff)
- trunk/activesupport/test/core_ext/integer_ext_test.rb (modified) (3 diffs)
- trunk/activesupport/test/core_ext/kernel_test.rb (modified) (1 diff)
- trunk/activesupport/test/core_ext/load_error_tests.rb (modified) (1 diff)
- trunk/activesupport/test/core_ext/module_test.rb (modified) (5 diffs)
- trunk/activesupport/test/core_ext/numeric_ext_test.rb (modified) (1 diff)
- trunk/activesupport/test/core_ext/object_and_class_ext_test.rb (modified) (11 diffs)
- trunk/activesupport/test/core_ext/pathname_test.rb (modified) (2 diffs)
- trunk/activesupport/test/core_ext/proc_test.rb (modified) (1 diff)
- trunk/activesupport/test/core_ext/range_ext_test.rb (modified) (1 diff)
- trunk/activesupport/test/core_ext/string_ext_test.rb (modified) (6 diffs)
- trunk/activesupport/test/core_ext/symbol_test.rb (modified) (1 diff)
- trunk/activesupport/test/core_ext/time_ext_test.rb (modified) (11 diffs)
- trunk/activesupport/test/dependencies_test.rb (modified) (9 diffs)
- trunk/activesupport/test/inflector_test.rb (modified) (13 diffs)
- trunk/activesupport/test/json.rb (modified) (4 diffs)
- trunk/activesupport/test/option_merger_test.rb (modified) (3 diffs)
- trunk/activesupport/test/ordered_options_test.rb (modified) (6 diffs)
- trunk/activesupport/test/reloadable_test.rb (modified) (5 diffs)
- trunk/activesupport/test/time_zone_test.rb (modified) (1 diff)
- trunk/activesupport/test/whiny_nil_test.rb (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/lib/action_controller/benchmarking.rb
r4312 r4595 66 66 runtime = [Benchmark::measure{ perform_action_without_benchmark }.real, 0.0001].max 67 67 log_message = "Completed in #{sprintf("%.5f", runtime)} (#{(1 / runtime).floor} reqs/sec)" 68 log_message << rendering_runtime(runtime) if @rendering_runtime68 log_message << rendering_runtime(runtime) if defined?(@rendering_runtime) 69 69 log_message << active_record_runtime(runtime) if Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected? 70 70 log_message << " | #{headers["Status"]}" trunk/actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb
r4524 r4595 76 76 # Fix for Safari Ajax postings that always append \000 77 77 content.chop! if content[-1] == 0 78 content.gsub! /&_=$/, ''78 content.gsub!(/&_=$/, '') 79 79 env_table['RAW_POST_DATA'] = content.freeze 80 80 end trunk/actionpack/lib/action_controller/cgi_process.rb
r4306 r4595 102 102 103 103 def session 104 unless @session104 unless defined?(@session) 105 105 if @session_options == false 106 106 @session = Hash.new … … 120 120 121 121 def reset_session 122 @session.delete if CGI::Session === @session122 @session.delete if defined?(@session) && @session.is_a?(CGI::Session) 123 123 @session = new_session 124 124 end trunk/actionpack/lib/action_controller/components.rb
r4474 r4595 112 112 113 113 def flash_with_components(refresh = false) #:nodoc: 114 if @flash.nil?|| refresh115 @flash = 116 if @parent_controller114 if !defined?(@flash) || refresh 115 @flash = 116 if defined?(@parent_controller) 117 117 @parent_controller.flash 118 118 else trunk/actionpack/lib/action_controller/flash.rb
r4540 r4595 156 156 # Note that if sessions are disabled only flash.now will work. 157 157 def flash(refresh = false) #:doc: 158 if @flash.nil?|| refresh159 @flash = 158 if !defined?(@flash) || refresh 159 @flash = 160 160 if @session.is_a?(Hash) 161 161 # @session is a Hash, if sessions are disabled trunk/actionpack/lib/action_controller/test_process.rb
r4433 r4595 338 338 base.class_eval <<-EOV, __FILE__, __LINE__ 339 339 def #{method}(action, parameters = nil, session = nil, flash = nil) 340 @request.env['REQUEST_METHOD'] = "#{method.upcase}" if @request340 @request.env['REQUEST_METHOD'] = "#{method.upcase}" if defined?(@request) 341 341 process(action, parameters, session, flash) 342 342 end … … 349 349 # Sanity check for required instance variables so we can give an 350 350 # understandable error message. 351 %w(controller request response).each do |iv_name| 352 raise "@#{iv_name} is nil: make sure you set it in your test's setup method." if instance_variable_get("@#{iv_name}").nil? 351 %w(@controller @request @response).each do |iv_name| 352 if !instance_variables.include?(iv_name) || instance_variable_get(iv_name).nil? 353 raise "#{iv_name} is nil: make sure you set it in your test's setup method." 354 end 353 355 end 354 356 trunk/actionpack/lib/action_view/helpers/form_helper.rb
r4334 r4595 268 268 options["checked"] = "checked" if checked 269 269 pretty_tag_value = tag_value.to_s.gsub(/\s/, "_").gsub(/\W/, "").downcase 270 options["id"] = @auto_index?270 options["id"] = defined?(@auto_index) ? 271 271 "#{@object_name}_#{@auto_index}_#{@method_name}_#{pretty_tag_value}" : 272 272 "#{@object_name}_#{@method_name}_#{pretty_tag_value}" … … 378 378 options["id"] ||= tag_id_with_index(options["index"]) 379 379 options.delete("index") 380 elsif @auto_index380 elsif defined?(@auto_index) 381 381 options["name"] ||= tag_name_with_index(@auto_index) 382 382 options["id"] ||= tag_id_with_index(@auto_index) trunk/actionpack/lib/action_view/helpers/text_helper.rb
r4446 r4595 278 278 def reset_cycle(name = "default") 279 279 cycle = get_cycle(name) 280 return if cycle.nil? 281 cycle.reset 280 cycle.reset unless cycle.nil? 282 281 end 283 282 … … 306 305 # uses an instance variable of ActionView::Base. 307 306 def get_cycle(name) 308 @_cycles = Hash.new if @_cycles.nil?307 @_cycles = Hash.new unless defined?(@_cycles) 309 308 return @_cycles[name] 310 309 end 311 310 312 311 def set_cycle(name, cycle_object) 313 @_cycles = Hash.new if @_cycles.nil?312 @_cycles = Hash.new unless defined?(@_cycles) 314 313 @_cycles[name] = cycle_object 315 314 end trunk/actionpack/test/controller/helper_test.rb
r2938 r4595 78 78 def test_declare_missing_file_from_helper 79 79 require 'broken_helper' 80 rescue LoadError => e81 assert_nil /\bbroken_helper\b/.match(e.to_s)[1]80 rescue LoadError => e 81 assert_nil(/\bbroken_helper\b/.match(e.to_s)[1]) 82 82 end 83 83 trunk/actionpack/test/template/active_record_helper_test.rb
r4592 r4595 50 50 end 51 51 52 def Post.content_columns() [ Column.new(:string, "title", "Title"), Column.new(:text, "body", "Body") ] end 52 silence_warnings do 53 def Post.content_columns() [ Column.new(:string, "title", "Title"), Column.new(:text, "body", "Body") ] end 54 end 53 55 54 56 @post.title = "Hello World" … … 77 79 end 78 80 79 def User.content_columns() [ Column.new(:string, "email", "Email") ] end 81 silence_warnings do 82 def User.content_columns() [ Column.new(:string, "email", "Email") ] end 83 end 80 84 81 85 @user.email = "" … … 120 124 ) 121 125 122 class << @post 123 def new_record?() false end 124 def to_param() id end 125 def id() 1 end 126 silence_warnings do 127 class << @post 128 def new_record?() false end 129 def to_param() id end 130 def id() 1 end 131 end 126 132 end 133 127 134 assert_dom_equal( 128 135 %(<form action="update/1" method="post"><input id="post_id" name="post[id]" type="hidden" value="1" /><p><label for="post_title">Title</label><br /><input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /></p>\n<p><label for="post_body">Body</label><br /><div class="fieldWithErrors"><textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea></div></p><input name="commit" type="submit" value="Update" /></form>), … … 132 139 133 140 def test_form_with_date 134 def Post.content_columns() [ Column.new(:date, "written_on", "Written on") ] end 141 silence_warnings do 142 def Post.content_columns() [ Column.new(:date, "written_on", "Written on") ] end 143 end 135 144 136 145 assert_dom_equal( … … 139 148 ) 140 149 end 141 150 142 151 def test_form_with_datetime 143 def Post.content_columns() [ Column.new(:datetime, "written_on", "Written on") ] end 152 silence_warnings do 153 def Post.content_columns() [ Column.new(:datetime, "written_on", "Written on") ] end 154 end 144 155 @post.written_on = Time.gm(2004, 6, 15, 16, 30) 145 156 trunk/actionpack/test/template/prototype_helper_test.rb
r4374 r4595 14 14 15 15 def setup 16 @template = nil 16 17 @controller = Class.new do 17 18 def url_for(options, *parameters_for_method_reference) trunk/activesupport/test/caching_tools_test.rb
r4059 r4595 1 require 'test/unit' 2 require File.dirname(__FILE__)+'/../lib/active_support/caching_tools' 1 require File.dirname(__FILE__) + '/abstract_unit' 3 2 4 3 class HashCachingTests < Test::Unit::TestCase 5 6 4 def cached(&proc) 7 return @cached if @cached8 5 return @cached if defined?(@cached) 6 9 7 @cached_class = Class.new(&proc) 10 8 @cached_class.class_eval do … … 14 12 @cached = @cached_class.new 15 13 end 16 14 17 15 def test_cache_access_should_call_method 18 16 cached do … … 21 19 assert_raises(RuntimeError) { cached.slow_method_cache[1] } 22 20 end 23 21 24 22 def test_cache_access_should_actually_cache 25 23 cached do … … 38 36 assert_equal 12, cached.slow_method_cache[11] 39 37 end 40 38 41 39 def test_cache_should_be_clearable 42 40 cached do … … 49 47 assert_equal 2, cached.slow_method_cache[:b] 50 48 assert_equal 3, cached.slow_method_cache[:c] 51 49 52 50 assert_equal 1, cached.slow_method_cache[:a] 53 51 assert_equal 2, cached.slow_method_cache[:b] 54 52 assert_equal 3, cached.slow_method_cache[:c] 55 53 56 54 cached.slow_method_cache.clear 57 55 58 56 assert_equal 4, cached.slow_method_cache[:a] 59 57 assert_equal 5, cached.slow_method_cache[:b] 60 58 assert_equal 6, cached.slow_method_cache[:c] 61 59 end 62 60 63 61 def test_deep_caches_should_work_too 64 62 cached do … … 71 69 assert_equal 7, cached.slow_method_cache[1][2][4] 72 70 assert_equal 7, cached.slow_method_cache[4][2][1] 73 71 74 72 assert_equal({ 75 73 1 => {1 => {1 => 3}, 2 => {4 => 7}}, … … 78 76 ) 79 77 end 80 81 78 end trunk/activesupport/test/class_inheritable_attributes_test.rb
r3493 r4595 1 require 'test/unit' 2 require File.dirname(__FILE__) + '/../lib/active_support/core_ext/class/inheritable_attributes' 1 require File.dirname(__FILE__) + '/abstract_unit' 3 2 4 3 class ClassInheritableAttributesTest < Test::Unit::TestCase trunk/activesupport/test/clean_logger_test.rb
r3131 r4595 1 require 'test/unit'1 require File.dirname(__FILE__) + '/abstract_unit' 2 2 require 'stringio' 3 require File.dirname(__FILE__) + '/../lib/active_support/clean_logger'4 require File.dirname(__FILE__) + '/../lib/active_support/core_ext/kernel.rb' unless defined? silence_warnings5 3 6 4 class CleanLoggerTest < Test::Unit::TestCase trunk/activesupport/test/core_ext/array_ext_test.rb
r4413 r4595 1 require 'test/unit' 2 require File.dirname(__FILE__) + '/../../lib/active_support' 1 require File.dirname(__FILE__) + '/../abstract_unit' 3 2 4 3 class ArrayExtToParamTests < Test::Unit::TestCase … … 8 7 assert_equal 'hello/10', %w(hello 10).to_param 9 8 end 10 9 11 10 def test_number_array 12 11 assert_equal '10/20', [10, 20].to_param … … 20 19 assert_equal "one and two", ['one', 'two'].to_sentence 21 20 assert_equal "one, two, and three", ['one', 'two', 'three'].to_sentence 22 21 23 22 end 24 23 25 24 def test_to_sentence_with_connector 26 25 assert_equal "one, two, and also three", ['one', 'two', 'three'].to_sentence(:connector => 'and also') 27 26 end 28 27 29 28 def test_to_sentence_with_skip_last_comma 30 29 assert_equal "one, two, and three", ['one', 'two', 'three'].to_sentence(:skip_last_comma => false) … … 34 33 assert_equal "one and two", ['one', 'two'].to_sentence 35 34 end 36 35 37 36 def test_one_element 38 37 assert_equal "one", ['one'].to_sentence … … 47 46 Class.new { def id() 3 end }.new 48 47 ] 49 48 50 49 assert_equal "null", [].to_s(:db) 51 50 assert_equal "1,2,3", collection.to_s(:db) … … 88 87 assert_equal [[]], [].split(0) 89 88 end 90 89 91 90 def test_split_with_argument 92 91 assert_equal [[1, 2], [4, 5]], [1, 2, 3, 4, 5].split(3) 93 92 assert_equal [[1, 2, 3, 4, 5]], [1, 2, 3, 4, 5].split(0) 94 93 end 95 94 96 95 def test_split_with_block 97 96 assert_equal [[1, 2], [4, 5], [7, 8], [10]], (1..10).to_a.split { |i| i % 3 == 0 } 98 97 end 99 98 100 99 def test_split_with_edge_values 101 100 assert_equal [[], [2, 3, 4, 5]], [1, 2, 3, 4, 5].split(1) … … 125 124 assert_equal "<people><person>", xml.first(16) 126 125 end 127 126 128 127 def test_to_xml_with_options 129 xml = [ 128 xml = [ 130 129 { :name => "David", :street_address => "Paulina" }, { :name => "Jason", :street_address => "Evergreen" } 131 130 ].to_xml(:skip_instruct => true, :skip_types => true, :indent => 0) … … 139 138 140 139 def test_to_xml_with_dasherize_false 141 xml = [ 140 xml = [ 142 141 { :name => "David", :street_address => "Paulina" }, { :name => "Jason", :street_address => "Evergreen" } 143 142 ].to_xml(:skip_instruct => true, :skip_types => true, :indent => 0, :dasherize => false) … … 149 148 150 149 def test_to_xml_with_dasherize_true 151 xml = [ 150 xml = [ 152 151 { :name => "David", :street_address => "Paulina" }, { :name => "Jason", :street_address => "Evergreen" } 153 152 ].to_xml(:skip_instruct => true, :skip_types => true, :indent => 0, :dasherize => true) trunk/activesupport/test/core_ext/blank_test.rb
r3493 r4595 1 require 'test/unit' 2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/object' 3 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/blank' 1 require File.dirname(__FILE__) + '/../abstract_unit' 4 2 5 3 class BlankTest < Test::Unit::TestCase trunk/activesupport/test/core_ext/cgi_ext_test.rb
r1496 r4595 1 require 'test/unit' 2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/cgi' 1 require File.dirname(__FILE__) + '/../abstract_unit' 3 2 4 3 class EscapeSkippingSlashesTest < Test::Unit::TestCase trunk/activesupport/test/core_ext/class_test.rb
r3493 r4595 1 require 'test/unit' 2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/class' 1 require File.dirname(__FILE__) + '/../abstract_unit' 3 2 4 3 class A trunk/activesupport/test/core_ext/date_ext_test.rb
r738 r4595 1 require 'test/unit' 2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/date' 1 require File.dirname(__FILE__) + '/../abstract_unit' 3 2 4 3 class DateExtCalculationsTest < Test::Unit::TestCase … … 7 6 assert_equal "February 21, 2005", Date.new(2005, 2, 21).to_s(:long) 8 7 end 9 8 10 9 def test_to_time 11 10 assert_equal Time.local(2005, 2, 21), Date.new(2005, 2, 21).to_time 12 11 end 13 12 14 13 def test_to_date 15 14 assert_equal Date.new(2005, 2, 21), Date.new(2005, 2, 21).to_date trunk/activesupport/test/core_ext/enumerable_test.rb
r4495 r4595 1 require 'test/unit' 2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/symbol' 3 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/enumerable' 1 require File.dirname(__FILE__) + '/../abstract_unit' 4 2 5 3 Payment = Struct.new(:price) … … 13 11 klass = Class.new 14 12 klass.send(:attr_accessor, :name) 15 objects = (1..50).inject([]) do |people,| 13 objects = (1..50).inject([]) do |people,| 16 14 p = klass.new 17 15 p.name = names.sort_by { rand }.first trunk/activesupport/test/core_ext/exception_test.rb
r4158 r4595 1 require 'test/unit' 2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/exception' 1 require File.dirname(__FILE__) + '/../abstract_unit' 3 2 4 3 class ExceptionExtTests < Test::Unit::TestCase 5 4 6 5 def get_exception(cls = RuntimeError, msg = nil, trace = nil) 7 6 begin raise cls, msg, (trace || caller) … … 10 9 end 11 10 end 12 11 13 12 def setup 14 13 Exception::TraceSubstitutions.clear 15 14 end 16 15 17 16 def test_clean_backtrace 18 17 Exception::TraceSubstitutions << [/\s*hidden.*/, ''] … … 21 20 assert_equal ['bhal.rb', 'rawh hid den stuff is not here', 'almost all'], e.clean_backtrace 22 21 end 23 22 24 23 def test_app_backtrace 25 24 Exception::TraceSubstitutions << [/\s*hidden.*/, ''] … … 28 27 assert_equal ['bhal.rb', 'almost all'], e.application_backtrace 29 28 end 30 29 31 30 def test_app_backtrace_with_before 32 31 Exception::TraceSubstitutions << [/\s*hidden.*/, ''] … … 42 41 assert_equal ['vendor/file.rb some stuff', ' vendor/file.rb some stuff'], e.framework_backtrace 43 42 end 44 43 45 44 def test_backtrace_should_clean_paths 46 45 Exception::TraceSubstitutions << [/\s*hidden.*/, ''] … … 49 48 assert_equal ['bhal.rb', 'rawh hid den stuff is not here', 'almost all'], e.clean_backtrace 50 49 end 51 50 52 51 def test_clean_message_should_clean_paths 53 52 Exception::TraceSubstitutions << [/\s*hidden.*/, ''] … … 56 55 assert_equal "I dislike a/b/c", e.clean_message 57 56 end 58 57 59 58 def test_app_trace_should_be_empty_when_no_app_frames 60 59 Exception::TraceSubstitutions << [/\s*hidden.*/, ''] trunk/activesupport/test/core_ext/hash_ext_test.rb
r4555 r4595 1 require 'test/unit' 2 require File.dirname(__FILE__) + '/../../lib/active_support' 1 require File.dirname(__FILE__) + '/../abstract_unit' 3 2 4 3 class HashExtTest < Test::Unit::TestCase trunk/activesupport/test/core_ext/integer_ext_test.rb
r1863 r4595 1 require 'test/unit' 2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/integer' 1 require File.dirname(__FILE__) + '/../abstract_unit' 3 2 4 3 class IntegerExtTest < Test::Unit::TestCase … … 6 5 assert [ -2, 0, 2, 4 ].all? { |i| i.even? } 7 6 assert ![ -1, 1, 3 ].all? { |i| i.even? } 8 7 9 8 assert 22953686867719691230002707821868552601124472329079.odd? 10 9 assert !22953686867719691230002707821868552601124472329079.even? … … 18 17 assert 1000000000000000000000000000000000000000000000000000000001.odd? 19 18 end 20 19 21 20 def test_multiple_of 22 21 [ -7, 0, 7, 14 ].each { |i| assert i.multiple_of?(7) } trunk/activesupport/test/core_ext/kernel_test.rb
r4386 r4595 1 require 'test/unit' 2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/kernel' unless defined? silence_warnings 1 require File.dirname(__FILE__) + '/../abstract_unit' 3 2 4 3 class KernelTest < Test::Unit::TestCase trunk/activesupport/test/core_ext/load_error_tests.rb
r985 r4595 1 require 'test/unit' 2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/load_error' 1 require File.dirname(__FILE__) + '/../abstract_unit' 3 2 4 3 class TestMissingSourceFile < Test::Unit::TestCase trunk/activesupport/test/core_ext/module_test.rb
r4429 r4595 1 require 'test/unit' 2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/class' 3 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/module' 1 require File.dirname(__FILE__) + '/../abstract_unit' 4 2 5 3 module One … … 68 66 assert_equal "Chicago", david.city 69 67 end 70 68 71 69 def test_delegation_down_hierarchy 72 70 david = Someone.new("David", Somewhere.new("Paulina", "Chicago")) 73 71 assert_equal "CHICAGO", david.upcase 74 72 end 75 73 76 74 def test_delegation_to_instance_variable 77 75 david = Name.new("David", "Hansson") 78 76 assert_equal "DAVID HANSSON", david.upcase 79 77 end 80 78 81 79 def test_missing_delegation_target 82 80 assert_raises(ArgumentError) { eval($nowhere) } 83 81 assert_raises(ArgumentError) { eval($noplace) } 84 82 end 85 83 86 84 def test_parent 87 85 assert_equal Yz::Zy, Yz::Zy::Cd.parent … … 89 87 assert_equal Object, Yz.parent 90 88 end 91 89 92 90 def test_parents 93 91 assert_equal [Yz::Zy, Yz, Object], Yz::Zy::Cd.parents 94 92 assert_equal [Yz, Object], Yz::Zy.parents 95 93 end 96 94 97 95 def test_as_load_path 98 96 assert_equal 'yz/zy', Yz::Zy.as_load_path … … 157 155 FooClassWithBarMethod.alias_method_chain :quux!, :baz 158 156 assert @instance.respond_to?(:quux_with_baz!) 159 157 160 158 assert_equal 'quux_with_baz!', @instance.quux! 161 159 assert_equal 'quux', @instance.quux_without_baz! … … 167 165 assert !@instance.respond_to?(:quux_with_baz!) 168 166 assert !@instance.respond_to?(:quux_with_baz?) 169 167 170 168 FooClassWithBarMethod.send(:include, BarMethodAliaser) 171 169 FooClassWithBarMethod.alias_method_chain :quux!, :baz 172 170 FooClassWithBarMethod.alias_method_chain :quux?, :baz 173 171 174 172 assert @instance.respond_to?(:quux_with_baz!) 175 173 assert @instance.respond_to?(:quux_with_baz?) trunk/activesupport/test/core_ext/numeric_ext_test.rb
r2746 r4595 1 require 'test/unit' 2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/numeric' 1 require File.dirname(__FILE__) + '/../abstract_unit' 3 2 4 3 class NumericExtTimeTest < Test::Unit::TestCase trunk/activesupport/test/core_ext/object_and_class_ext_test.rb
r4049 r4595 1 require 'test/unit' 2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/object' 3 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/class' 1 require File.dirname(__FILE__) + '/../abstract_unit' 4 2 5 3 class ClassA; end … … 42 40 assert !defined?(ClassD) 43 41 end 44 42 45 43 def test_subclasses_of 46 44 assert_equal [ClassJ], Object.subclasses_of(ClassI) … … 48 46 assert_equal [], Object.subclasses_of(ClassI) 49 47 end 50 48 51 49 def test_subclasses_of_should_find_nested_classes 52 50 assert Object.subclasses_of(ClassK).include?(Nested::ClassL) 53 51 end 54 52 55 53 def test_subclasses_of_should_not_return_removed_classes 56 54 # First create the removed class … … 59 57 Nested.const_set :ClassL, new_class 60 58 assert_equal "Nested::ClassL", new_class.name # Sanity check 61 59 62 60 subclasses = Object.subclasses_of(ClassK) 63 61 assert subclasses.include?(new_class) … … 76 74 suppress(LoadError, ArgumentError) { raise ArgumentError } 77 75 end 78 76 79 77 def test_extended_by 80 78 foo = Foo.new … … 83 81 assert ([Bar, Baz] - foo.extended_by).empty?, "Expected Bar, Baz in #{foo.extended_by.inspect}" 84 82 end 85 83 86 84 def test_extend_with_included_modules_from 87 85 foo, object = Foo.new, Object.new 88 86 assert !object.respond_to?(:bar) 89 87 assert !object.respond_to?(:baz) 90 88 91 89 object.extend_with_included_modules_from(foo) 92 90 assert object.respond_to?(:bar) 93 91 assert !object.respond_to?(:baz) 94 92 95 93 foo.extend(Baz) 96 94 object.extend_with_included_modules_from(foo) … … 114 112 assert_equal %w(@bar @baz), @dest.instance_variables.sort 115 113 %w(@bar @baz).each do |name| 116 assert_equal @source.instance_variable_get(name).object_id, 114 assert_equal @source.instance_variable_get(name).object_id, 117 115 @dest.instance_variable_get(name).object_id 118 116 end 119 117 end 120 118 121 119 def test_copy_instance_variables_from_with_explicit_excludes 122 120 @dest.copy_instance_variables_from(@source, ['@baz']) … … 124 122 assert_equal 'bar', @dest.instance_variable_get('@bar') 125 123 end 126 124 127 125 def test_copy_instance_variables_automatically_excludes_protected_instance_variables 128 126 @source.instance_variable_set(:@quux, 'quux') … … 132 130 end 133 131 end 134 132 135 133 @dest.copy_instance_variables_from(@source) 136 134 assert !@dest.instance_variables.include?('@bar') … … 138 136 assert_equal 'baz', @dest.instance_variable_get('@baz') 139 137 end 140 138 141 139 def test_instance_values 142 140 object = Object.new … … 145 143 assert_equal({'a' => 1, 'b' => 2}, object.instance_values) 146 144 end 147 145 148 146 def test_instance_exec_passes_arguments_to_block 149 147 block = Proc.new { |value| [self, value] } 150 148 assert_equal %w(hello goodbye), 'hello'.instance_exec('goodbye', &block) 151 149 end 152 150 153 151 end trunk/activesupport/test/core_ext/pathname_test.rb
r4159 r4595 1 require 'test/unit' 2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/pathname' 1 require File.dirname(__FILE__) + '/../abstract_unit' 3 2 4 3 class TestPathname < Test::Unit::TestCase 5 6 4 def test_clean_within 7 5 assert_equal "Hi", Pathname.clean_within("Hi") … … 9 7 assert_equal "Hello\nWorld", Pathname.clean_within("Hello/a/b/../..\na/b/../../World/c/..") 10 8 end 11 12 9 end trunk/activesupport/test/core_ext/proc_test.rb
r3469 r4595 1 require 'test/unit' 2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/proc' 1 require File.dirname(__FILE__) + '/../abstract_unit' 3 2 4 3 class ProcTests < Test::Unit::TestCase trunk/activesupport/test/core_ext/range_ext_test.rb
r2506 r4595 1 require 'test/unit' 2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/date' 3 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/time' 4 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/range' 1 require File.dirname(__FILE__) + '/../abstract_unit' 5 2 6 3 class RangeTest < Test::Unit::TestCase trunk/activesupport/test/core_ext/string_ext_test.rb
r3548 r4595 1 require 'test/unit'2 1 require 'date' 3 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/string' 4 require File.dirname(__FILE__) + '/../inflector_test' unless defined? InflectorTest 2 require File.dirname(__FILE__) + '/../abstract_unit' 5 3 6 4 class StringInflectionsTest < Test::Unit::TestCase … … 29 27 assert_equal(underscore, camel.underscore) 30 28 end 31 29 32 30 assert_equal "html_tidy", "HTMLTidy".underscore 33 31 assert_equal "html_tidy_generator", "HTMLTidyGenerator".underscore … … 59 57 end 60 58 end 61 59 62 60 def test_string_to_time 63 61 assert_equal Time.utc(2005, 2, 27, 23, 50), "2005-02-27 23:50".to_time … … 65 63 assert_equal Date.new(2005, 2, 27), "2005-02-27".to_date 66 64 end 67 65 68 66 def test_access