aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2009-09-30 22:27:02 +0100
committerPratik Naik <pratiknaik@gmail.com>2009-09-30 22:27:02 +0100
commitdd2779e1b83b4d867d47dd286ec0c919f5df12a9 (patch)
tree6e52ea0a329c24429f4d1d41b065e082f0ed6baa /activesupport/test
parent329b14aa8fdd291a00d17ba12c2e0ab4c3a157cc (diff)
parent420004e030e96f2ace6e27fd622c90ee9e986677 (diff)
downloadrails-dd2779e1b83b4d867d47dd286ec0c919f5df12a9.tar.gz
rails-dd2779e1b83b4d867d47dd286ec0c919f5df12a9.tar.bz2
rails-dd2779e1b83b4d867d47dd286ec0c919f5df12a9.zip
Merge commit 'mainstream/master'
Diffstat (limited to 'activesupport/test')
-rw-r--r--activesupport/test/abstract_unit.rb2
-rw-r--r--activesupport/test/memoizable_test.rb11
-rw-r--r--activesupport/test/message_verifier_test.rb15
-rw-r--r--activesupport/test/new_callback_inheritance_test.rb2
-rw-r--r--activesupport/test/ts_isolated.rb15
5 files changed, 39 insertions, 6 deletions
diff --git a/activesupport/test/abstract_unit.rb b/activesupport/test/abstract_unit.rb
index ee6084dfcd..af9656615c 100644
--- a/activesupport/test/abstract_unit.rb
+++ b/activesupport/test/abstract_unit.rb
@@ -19,7 +19,7 @@ require 'active_support/test_case'
require 'active_support/ruby/shim'
def uses_memcached(test_name)
- require 'active_support/vendor/memcache'
+ require 'memcache'
begin
MemCache.new('localhost').stats
yield
diff --git a/activesupport/test/memoizable_test.rb b/activesupport/test/memoizable_test.rb
index 3bad683093..195e3eaa42 100644
--- a/activesupport/test/memoizable_test.rb
+++ b/activesupport/test/memoizable_test.rb
@@ -4,12 +4,13 @@ class MemoizableTest < ActiveSupport::TestCase
class Person
extend ActiveSupport::Memoizable
- attr_reader :name_calls, :age_calls, :is_developer_calls
+ attr_reader :name_calls, :age_calls, :is_developer_calls, :name_query_calls
def initialize
@name_calls = 0
@age_calls = 0
@is_developer_calls = 0
+ @name_query_calls = 0
end
def name
@@ -18,6 +19,7 @@ class MemoizableTest < ActiveSupport::TestCase
end
def name?
+ @name_query_calls += 1
true
end
memoize :name?
@@ -116,6 +118,13 @@ class MemoizableTest < ActiveSupport::TestCase
end
end
+ def test_memoization_flush_with_punctuation
+ assert_equal true, @person.name?
+ @person.flush_cache(:name?)
+ 3.times { assert_equal true, @person.name? }
+ assert_equal 2, @person.name_query_calls
+ end
+
def test_memoization_with_nil_value
assert_equal nil, @person.age
assert_equal 1, @person.age_calls
diff --git a/activesupport/test/message_verifier_test.rb b/activesupport/test/message_verifier_test.rb
index 57c4ce841e..4f8837ba4e 100644
--- a/activesupport/test/message_verifier_test.rb
+++ b/activesupport/test/message_verifier_test.rb
@@ -1,25 +1,34 @@
require 'abstract_unit'
+begin
+ require 'openssl'
+ OpenSSL::Digest::SHA1
+rescue LoadError, NameError
+ $stderr.puts "Skipping MessageVerifier test: broken OpenSSL install"
+else
+
class MessageVerifierTest < Test::Unit::TestCase
def setup
@verifier = ActiveSupport::MessageVerifier.new("Hey, I'm a secret!")
@data = {:some=>"data", :now=>Time.now}
end
-
+
def test_simple_round_tripping
message = @verifier.generate(@data)
assert_equal @data, @verifier.verify(message)
end
-
+
def test_tampered_data_raises
data, hash = @verifier.generate(@data).split("--")
assert_not_verified("#{data.reverse}--#{hash}")
assert_not_verified("#{data}--#{hash.reverse}")
end
-
+
def assert_not_verified(message)
assert_raise(ActiveSupport::MessageVerifier::InvalidSignature) do
@verifier.verify(message)
end
end
end
+
+end
diff --git a/activesupport/test/new_callback_inheritance_test.rb b/activesupport/test/new_callback_inheritance_test.rb
index da0c19eaea..fe316ae3da 100644
--- a/activesupport/test/new_callback_inheritance_test.rb
+++ b/activesupport/test/new_callback_inheritance_test.rb
@@ -112,4 +112,4 @@ class InheritedCallbacksTest2 < Test::Unit::TestCase
def test_crazy_mix_off
assert_equal %w(before1 before2 update after2 after1), @update2.log
end
-end \ No newline at end of file
+end
diff --git a/activesupport/test/ts_isolated.rb b/activesupport/test/ts_isolated.rb
new file mode 100644
index 0000000000..9378a13766
--- /dev/null
+++ b/activesupport/test/ts_isolated.rb
@@ -0,0 +1,15 @@
+require 'test/unit'
+require 'rbconfig'
+require 'active_support/core_ext/kernel/reporting'
+
+class TestIsolated < Test::Unit::TestCase
+ ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME'))
+
+ Dir["#{File.dirname(__FILE__)}/**/*_test.rb"].each do |file|
+ define_method("test #{file}") do
+ command = "#{ruby} -Ilib:test #{file}"
+ silence_stderr { `#{command}` }
+ assert_equal 0, $?.to_i, command
+ end
+ end
+end