From 111347f0cc7b23efba06d29fc374111f9d160f06 Mon Sep 17 00:00:00 2001 From: Rashmi Yadav Date: Thu, 4 Aug 2011 12:33:56 +0530 Subject: The trailing '/' isn't being picked up by Github anyway, and the link works as is. --- activesupport/README.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport') diff --git a/activesupport/README.rdoc b/activesupport/README.rdoc index a38ad76f43..cc3981e74d 100644 --- a/activesupport/README.rdoc +++ b/activesupport/README.rdoc @@ -14,7 +14,7 @@ The latest version of Active Support can be installed with Rubygems: Source code can be downloaded as part of the Rails project on GitHub -* https://github.com/rails/rails/tree/master/activesupport/ +* https://github.com/rails/rails/tree/master/activesupport == License -- cgit v1.2.3 From 7934ffe5e9a88236f9fb924d9d4c1f20ff0892c7 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 26 Jul 2011 10:58:16 -0700 Subject: fixing whitespace errors --- activesupport/test/xml_mini_test.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'activesupport') diff --git a/activesupport/test/xml_mini_test.rb b/activesupport/test/xml_mini_test.rb index e2b90ae16e..4450c1a0ae 100644 --- a/activesupport/test/xml_mini_test.rb +++ b/activesupport/test/xml_mini_test.rb @@ -50,49 +50,49 @@ module XmlMiniTest def test_rename_key_does_not_dasherize_multiple_trailing_underscores assert_equal "id__", ActiveSupport::XmlMini.rename_key("id__") - end + end end class ToTagTest < ActiveSupport::TestCase def assert_xml(xml) assert_equal xml, @options[:builder].target! end - + setup do @xml = ActiveSupport::XmlMini @options = {:skip_instruct => true, :builder => Builder::XmlMarkup.new} end - + test "#to_tag accepts a callable object and passes options with the builder" do @xml.to_tag(:some_tag, lambda {|o| o[:builder].br }, @options) assert_xml "
" end - + test "#to_tag accepts a callable object and passes options and tag name" do @xml.to_tag(:tag, lambda {|o, t| o[:builder].b(t) }, @options) assert_xml "tag" end - + test "#to_tag accepts an object responding to #to_xml and passes the options, where :root is key" do obj = Object.new obj.instance_eval do def to_xml(options) options[:builder].yo(options[:root].to_s) end end - + @xml.to_tag(:tag, obj, @options) assert_xml "tag" end - + test "#to_tag accepts arbitrary objects responding to #to_str" do @xml.to_tag(:b, "Howdy", @options) assert_xml "Howdy" end - + test "#to_tag should dasherize the space when passed a string with spaces as a key" do @xml.to_tag("New York", 33, @options) assert_xml "33" end - + test "#to_tag should dasherize the space when passed a symbol with spaces as a key" do @xml.to_tag(:"New York", 33, @options) assert_xml "33" -- cgit v1.2.3 From 797d2254d7d1a541305526431e7362df5d5dd970 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 26 Jul 2011 11:02:41 -0700 Subject: fixing tests on ruby trunk --- activesupport/test/xml_mini_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport') diff --git a/activesupport/test/xml_mini_test.rb b/activesupport/test/xml_mini_test.rb index 4450c1a0ae..dde17ea403 100644 --- a/activesupport/test/xml_mini_test.rb +++ b/activesupport/test/xml_mini_test.rb @@ -58,7 +58,7 @@ module XmlMiniTest assert_equal xml, @options[:builder].target! end - setup do + def setup @xml = ActiveSupport::XmlMini @options = {:skip_instruct => true, :builder => Builder::XmlMarkup.new} end -- cgit v1.2.3 From d13b5d4b2aac3bec055933f1769a7becff374742 Mon Sep 17 00:00:00 2001 From: Vishnu Atrai Date: Tue, 26 Jul 2011 23:53:54 +0530 Subject: remove unused variables warnings removed --- activesupport/test/safe_buffer_test.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'activesupport') diff --git a/activesupport/test/safe_buffer_test.rb b/activesupport/test/safe_buffer_test.rb index 46bc0d7a34..7662e9b765 100644 --- a/activesupport/test/safe_buffer_test.rb +++ b/activesupport/test/safe_buffer_test.rb @@ -80,14 +80,12 @@ class SafeBufferTest < ActiveSupport::TestCase end test "Should escape dirty buffers on add" do - dirty = @buffer clean = "hello".html_safe @buffer.gsub!('', '<>') assert_equal "hello<>", clean + @buffer end test "Should concat as a normal string when dirty" do - dirty = @buffer clean = "hello".html_safe @buffer.gsub!('', '<>') assert_equal "<>hello", @buffer + clean -- cgit v1.2.3 From f1403f930358dcd8c66d8bc276da11874546ed2f Mon Sep 17 00:00:00 2001 From: Jonathan del Strother Date: Tue, 26 Jul 2011 16:10:55 +0100 Subject: Constantize a regexp in Dependencies#load_missing_constant --- activesupport/lib/active_support/dependencies.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index d1543c4c58..a60697cb12 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -466,6 +466,7 @@ module ActiveSupport #:nodoc: # Load the constant named +const_name+ which is missing from +from_mod+. If # it is not possible to load the constant into from_mod, try its parent module # using const_missing. + THIS_FILE = %r{#{Regexp.escape(__FILE__)}} def load_missing_constant(from_mod, const_name) log_call from_mod, const_name @@ -478,7 +479,7 @@ module ActiveSupport #:nodoc: qualified_name = qualified_name_for from_mod, const_name path_suffix = qualified_name.underscore - trace = caller.reject {|l| l =~ %r{#{Regexp.escape(__FILE__)}}} + trace = caller.reject {|l| l =~ THIS_FILE} name_error = NameError.new("uninitialized constant #{qualified_name}") name_error.set_backtrace(trace) -- cgit v1.2.3 From ab422b04a2fd8144a26d82f2ec1efeeb684b29db Mon Sep 17 00:00:00 2001 From: Jonathan del Strother Date: Wed, 27 Jul 2011 00:06:19 +0100 Subject: Replace unnecessary regexp in Dependencies#load_missing_constant --- activesupport/lib/active_support/dependencies.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index a60697cb12..8cd4d15e4c 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -466,7 +466,6 @@ module ActiveSupport #:nodoc: # Load the constant named +const_name+ which is missing from +from_mod+. If # it is not possible to load the constant into from_mod, try its parent module # using const_missing. - THIS_FILE = %r{#{Regexp.escape(__FILE__)}} def load_missing_constant(from_mod, const_name) log_call from_mod, const_name @@ -479,7 +478,7 @@ module ActiveSupport #:nodoc: qualified_name = qualified_name_for from_mod, const_name path_suffix = qualified_name.underscore - trace = caller.reject {|l| l =~ THIS_FILE} + trace = caller.reject {|l| l.starts_with? __FILE__ } name_error = NameError.new("uninitialized constant #{qualified_name}") name_error.set_backtrace(trace) -- cgit v1.2.3 From 9d5340e7094444a35c48035d9f111617806d519c Mon Sep 17 00:00:00 2001 From: Brian Cardarella Date: Fri, 29 Jul 2011 13:06:45 -0400 Subject: Reset @dirty to false when slicing an instance of SafeBuffer --- activesupport/lib/active_support/core_ext/string/output_safety.rb | 6 ++++++ activesupport/test/safe_buffer_test.rb | 6 ++++++ 2 files changed, 12 insertions(+) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb index 3bf4edbdef..6d6c4912bb 100644 --- a/activesupport/lib/active_support/core_ext/string/output_safety.rb +++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb @@ -86,6 +86,12 @@ module ActiveSupport #:nodoc: end end + def[](*args) + new_safe_buffer = super + new_safe_buffer.instance_eval { @dirty = false } + new_safe_buffer + end + def safe_concat(value) raise SafeConcatError if dirty? original_concat(value) diff --git a/activesupport/test/safe_buffer_test.rb b/activesupport/test/safe_buffer_test.rb index 7662e9b765..8f77999d25 100644 --- a/activesupport/test/safe_buffer_test.rb +++ b/activesupport/test/safe_buffer_test.rb @@ -106,4 +106,10 @@ class SafeBufferTest < ActiveSupport::TestCase test "should not fail if the returned object is not a string" do assert_kind_of NilClass, @buffer.slice("chipchop") end + + test "Should initialize @dirty to false for new instance when sliced" do + dirty = @buffer[0,0].send(:dirty?) + assert_not_nil dirty + assert !dirty + end end -- cgit v1.2.3 From f85b9662699d7b77fd9ad4e1303565fdaaed0379 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 29 Jul 2011 14:38:57 -0700 Subject: delay backtrace scrubbing until we actually raise an exception. fixes #1936 --- activesupport/lib/active_support/dependencies.rb | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index 8cd4d15e4c..3f6c93e860 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -478,10 +478,6 @@ module ActiveSupport #:nodoc: qualified_name = qualified_name_for from_mod, const_name path_suffix = qualified_name.underscore - trace = caller.reject {|l| l.starts_with? __FILE__ } - name_error = NameError.new("uninitialized constant #{qualified_name}") - name_error.set_backtrace(trace) - file_path = search_for_file(path_suffix) if file_path && ! loaded.include?(File.expand_path(file_path)) # We found a matching file to load @@ -500,11 +496,12 @@ module ActiveSupport #:nodoc: return parent.const_missing(const_name) rescue NameError => e raise unless e.missing_name? qualified_name_for(parent, const_name) - raise name_error end - else - raise name_error end + + raise NameError, + "uninitialized constant #{qualified_name}", + caller.reject {|l| l.starts_with? __FILE__ } end # Remove the constants that have been autoloaded, and those that have been -- cgit v1.2.3 From 48fce08bb3606b989a20f5e60f9243e627099339 Mon Sep 17 00:00:00 2001 From: Brian Durand Date: Fri, 29 Jul 2011 17:27:45 -0500 Subject: Change ActiveSupport::Cache behavior to always return duplicate objects instead of frozen objects. --- activesupport/lib/active_support/cache.rb | 23 ++++++++--------------- activesupport/test/caching_test.rb | 17 ++++++++++------- 2 files changed, 18 insertions(+), 22 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index ac88c82709..2d2264e58a 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -557,15 +557,14 @@ module ActiveSupport @expires_in = options[:expires_in] @expires_in = @expires_in.to_f if @expires_in @created_at = Time.now.to_f - if defined?(value) + if value.nil? + @value = nil + else + @value = Marshal.dump(value) if should_compress?(value, options) - @value = Zlib::Deflate.deflate(Marshal.dump(value)) + @value = Zlib::Deflate.deflate(@value) @compressed = true - else - @value = value end - else - @value = nil end end @@ -576,12 +575,8 @@ module ActiveSupport # Get the value stored in the cache. def value - if defined?(@value) - val = compressed? ? Marshal.load(Zlib::Inflate.inflate(@value)) : @value - unless val.frozen? - val.freeze rescue nil - end - val + if @value + Marshal.load(compressed? ? Zlib::Inflate.inflate(@value) : @value) end end @@ -614,10 +609,8 @@ module ActiveSupport def size if @value.nil? 0 - elsif @value.respond_to?(:bytesize) - @value.bytesize else - Marshal.dump(@value).bytesize + @value.bytesize end end diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb index 402c6695aa..dff3d6ef0d 100644 --- a/activesupport/test/caching_test.rb +++ b/activesupport/test/caching_test.rb @@ -204,7 +204,7 @@ module CacheStoreBehavior @cache.write('foo', 'bar', :compress => true) raw_value = @cache.send(:read_entry, 'foo', {}).raw_value assert_equal 'bar', @cache.read('foo') - assert_equal 'bar', raw_value + assert_equal 'bar', Marshal.load(raw_value) end def test_read_and_write_compressed_large_data @@ -270,10 +270,12 @@ module CacheStoreBehavior assert !@cache.exist?('foo') end - def test_store_objects_should_be_immutable + def test_read_should_return_a_different_object_id_each_time_it_is_called @cache.write('foo', 'bar') - assert_raise(ActiveSupport::FrozenObjectError) { @cache.read('foo').gsub!(/.*/, 'baz') } - assert_equal 'bar', @cache.read('foo') + assert_not_equal @cache.read('foo').object_id, @cache.read('foo').object_id + value = @cache.read('foo') + value << 'bingo' + assert_not_equal value, @cache.read('foo') end def test_original_store_objects_should_not_be_immutable @@ -551,7 +553,8 @@ end class MemoryStoreTest < ActiveSupport::TestCase def setup - @cache = ActiveSupport::Cache.lookup_store(:memory_store, :expires_in => 60, :size => 100) + @record_size = Marshal.dump("aaaaaaaaaa").bytesize + @cache = ActiveSupport::Cache.lookup_store(:memory_store, :expires_in => 60, :size => @record_size * 10) end include CacheStoreBehavior @@ -566,7 +569,7 @@ class MemoryStoreTest < ActiveSupport::TestCase @cache.write(5, "eeeeeeeeee") && sleep(0.001) @cache.read(2) && sleep(0.001) @cache.read(4) - @cache.prune(30) + @cache.prune(@record_size * 3) assert_equal true, @cache.exist?(5) assert_equal true, @cache.exist?(4) assert_equal false, @cache.exist?(3) @@ -719,7 +722,7 @@ class CacheEntryTest < ActiveSupport::TestCase def test_non_compress_values entry = ActiveSupport::Cache::Entry.new("value") assert_equal "value", entry.value - assert_equal "value", entry.raw_value + assert_equal "value", Marshal.load(entry.raw_value) assert_equal false, entry.compressed? end end -- cgit v1.2.3 From e1b546464ecf20466fb38a93eea9769945774eee Mon Sep 17 00:00:00 2001 From: Brad Ediger Date: Sun, 31 Jul 2011 07:38:38 -0500 Subject: remove_possible_method: test if method exists This speeds up remove_possible_method substantially since it doesn't have to rescue a NameError in the common case. Closes #2346. --- .../lib/active_support/core_ext/module/remove_method.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/core_ext/module/remove_method.rb b/activesupport/lib/active_support/core_ext/module/remove_method.rb index 07d7c9b018..b76bc16ee1 100644 --- a/activesupport/lib/active_support/core_ext/module/remove_method.rb +++ b/activesupport/lib/active_support/core_ext/module/remove_method.rb @@ -1,11 +1,16 @@ class Module def remove_possible_method(method) - remove_method(method) + if method_defined?(method) || private_method_defined?(method) + remove_method(method) + end rescue NameError + # If the requested method is defined on a superclass or included module, + # method_defined? returns true but remove_method throws a NameError. + # Ignore this. end def redefine_method(method, &block) remove_possible_method(method) define_method(method, &block) end -end \ No newline at end of file +end -- cgit v1.2.3 From 30ef55de66decbbcf6475917c741c42fb738718b Mon Sep 17 00:00:00 2001 From: Arun Agrawal Date: Sun, 31 Jul 2011 23:36:21 +0530 Subject: Removing extra requires from the test. Already loaded in abstract_unit. --- activesupport/test/core_ext/string_ext_test.rb | 1 - activesupport/test/dependencies_test.rb | 1 - activesupport/test/json/decoding_test.rb | 1 - activesupport/test/multibyte_utils_test.rb | 1 - activesupport/test/test_test.rb | 1 - 5 files changed, 5 deletions(-) (limited to 'activesupport') diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb index 18a86e08f5..a4bba056df 100644 --- a/activesupport/test/core_ext/string_ext_test.rb +++ b/activesupport/test/core_ext/string_ext_test.rb @@ -6,7 +6,6 @@ require 'inflector_test_cases' require 'active_support/inflector' require 'active_support/core_ext/string' require 'active_support/time' -require 'active_support/core_ext/kernel/reporting' require 'active_support/core_ext/string/strip' class StringInflectionsTest < Test::Unit::TestCase diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index b4edf0f51d..b0e96731cc 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -1,7 +1,6 @@ require 'abstract_unit' require 'pp' require 'active_support/dependencies' -require 'active_support/core_ext/kernel/reporting' module ModuleWithMissing mattr_accessor :missing_count diff --git a/activesupport/test/json/decoding_test.rb b/activesupport/test/json/decoding_test.rb index 201729a6c2..d1454902e5 100644 --- a/activesupport/test/json/decoding_test.rb +++ b/activesupport/test/json/decoding_test.rb @@ -2,7 +2,6 @@ require 'abstract_unit' require 'active_support/json' require 'active_support/time' -require 'active_support/core_ext/kernel/reporting' class TestJSONDecoding < ActiveSupport::TestCase TESTS = { diff --git a/activesupport/test/multibyte_utils_test.rb b/activesupport/test/multibyte_utils_test.rb index 1dff944922..0a2f20d282 100644 --- a/activesupport/test/multibyte_utils_test.rb +++ b/activesupport/test/multibyte_utils_test.rb @@ -2,7 +2,6 @@ require 'abstract_unit' require 'multibyte_test_helpers' -require 'active_support/core_ext/kernel/reporting' class MultibyteUtilsTest < ActiveSupport::TestCase include MultibyteTestHelpers diff --git a/activesupport/test/test_test.rb b/activesupport/test/test_test.rb index 5bd995aa32..f880052786 100644 --- a/activesupport/test/test_test.rb +++ b/activesupport/test/test_test.rb @@ -1,5 +1,4 @@ require 'abstract_unit' -require 'active_support/core_ext/kernel/reporting' class AssertDifferenceTest < ActiveSupport::TestCase def setup -- cgit v1.2.3 From cc78a8f04cb8a4ced280e73de6337cec25070a8e Mon Sep 17 00:00:00 2001 From: Dmitriy Kiriyenko Date: Mon, 1 Aug 2011 18:00:41 +0300 Subject: Remove unnecessary require (happened after fcbde454f6) --- activesupport/lib/active_support/core_ext/module/delegation.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/core_ext/module/delegation.rb b/activesupport/lib/active_support/core_ext/module/delegation.rb index 41f9a76b13..149b849b12 100644 --- a/activesupport/lib/active_support/core_ext/module/delegation.rb +++ b/activesupport/lib/active_support/core_ext/module/delegation.rb @@ -1,5 +1,3 @@ -require "active_support/core_ext/module/remove_method" - class Module # Provides a delegate class method to easily expose contained objects' methods # as your own. Pass one or more methods (specified as symbols or strings) -- cgit v1.2.3 From 05d4b9d2fdb0aceb9082303301ecaf77605288a0 Mon Sep 17 00:00:00 2001 From: Brian Durand Date: Mon, 1 Aug 2011 12:05:29 -0500 Subject: Pass options in ActiveSupport::Cache::CacheStore#read_multi through to the delete_entry call. --- activesupport/lib/active_support/cache.rb | 2 +- activesupport/test/caching_test.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index 2d2264e58a..95d936b32f 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -347,7 +347,7 @@ module ActiveSupport entry = read_entry(key, options) if entry if entry.expired? - delete_entry(key) + delete_entry(key, options) else results[name] = entry.value end diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb index dff3d6ef0d..6bb13ec9b8 100644 --- a/activesupport/test/caching_test.rb +++ b/activesupport/test/caching_test.rb @@ -199,6 +199,14 @@ module CacheStoreBehavior @cache.write('fud', 'biz') assert_equal({"foo" => "bar", "fu" => "baz"}, @cache.read_multi('foo', 'fu')) end + + def test_read_multi_with_expires + @cache.write('foo', 'bar', :expires_in => 0.001) + @cache.write('fu', 'baz') + @cache.write('fud', 'biz') + sleep(0.002) + assert_equal({"fu" => "baz"}, @cache.read_multi('foo', 'fu')) + end def test_read_and_write_compressed_small_data @cache.write('foo', 'bar', :compress => true) -- cgit v1.2.3 From eaee18dd9abe6a72e83743009931f7765a005f24 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 3 Aug 2011 16:55:00 -0700 Subject: make assert_difference error message not suck --- activesupport/lib/active_support/testing/assertions.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/testing/assertions.rb b/activesupport/lib/active_support/testing/assertions.rb index 3864b1f5a6..ba34e9853c 100644 --- a/activesupport/lib/active_support/testing/assertions.rb +++ b/activesupport/lib/active_support/testing/assertions.rb @@ -46,16 +46,17 @@ module ActiveSupport # end def assert_difference(expression, difference = 1, message = nil, &block) exps = Array.wrap(expression).map { |e| - e.respond_to?(:call) ? e : lambda { eval(e, block.binding) } + callee = e.respond_to?(:call) ? e : lambda { eval(e, block.binding) } + [e, callee] } - before = exps.map { |e| e.call } + before = exps.map { |_, block| block.call } yield - exps.each_with_index do |e, i| - error = "#{e.inspect} didn't change by #{difference}" + exps.each_with_index do |(code, block), i| + error = "#{code.inspect} didn't change by #{difference}" error = "#{message}.\n#{error}" if message - assert_equal(before[i] + difference, e.call, error) + assert_equal(before[i] + difference, block.call, error) end end -- cgit v1.2.3 From a7a3169cc33aa06b6d3b70889c577d067a6c41ae Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 4 Aug 2011 14:07:23 -0700 Subject: fixing assert_difference issues on ruby 1.8 --- activesupport/lib/active_support/testing/assertions.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/testing/assertions.rb b/activesupport/lib/active_support/testing/assertions.rb index ba34e9853c..f3629ada5b 100644 --- a/activesupport/lib/active_support/testing/assertions.rb +++ b/activesupport/lib/active_support/testing/assertions.rb @@ -45,18 +45,19 @@ module ActiveSupport # post :delete, :id => ... # end def assert_difference(expression, difference = 1, message = nil, &block) - exps = Array.wrap(expression).map { |e| - callee = e.respond_to?(:call) ? e : lambda { eval(e, block.binding) } - [e, callee] + expressions = Array.wrap expression + + exps = expressions.map { |e| + e.respond_to?(:call) ? e : lambda { eval(e, block.binding) } } - before = exps.map { |_, block| block.call } + before = exps.map { |e| e.call } yield - exps.each_with_index do |(code, block), i| + expressions.zip(exps).each_with_index do |(code, e), i| error = "#{code.inspect} didn't change by #{difference}" error = "#{message}.\n#{error}" if message - assert_equal(before[i] + difference, block.call, error) + assert_equal(before[i] + difference, e.call, error) end end -- cgit v1.2.3 From b905f8c96326c86caafc20bec7e3722cf4813d2c Mon Sep 17 00:00:00 2001 From: Sukeerthi Adiga Date: Fri, 5 Aug 2011 14:04:43 +0530 Subject: Rubygems => RubyGems --- activesupport/README.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport') diff --git a/activesupport/README.rdoc b/activesupport/README.rdoc index cc3981e74d..1ab8e00608 100644 --- a/activesupport/README.rdoc +++ b/activesupport/README.rdoc @@ -8,7 +8,7 @@ outside of Rails. == Download and installation -The latest version of Active Support can be installed with Rubygems: +The latest version of Active Support can be installed with RubyGems: % [sudo] gem install activesupport -- cgit v1.2.3