diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-03-01 17:20:10 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-03-01 17:20:35 -0800 |
commit | 7b6bfe84f332a3c99656f73cf0251bce0a16ba88 (patch) | |
tree | fe0fa3c7ef7d0638b9ef9f3db1b259ade1c656de /actionpack/test/dispatch | |
parent | 50ed1a25a4e496a7a67861b1a04d667bd3445bb6 (diff) | |
download | rails-7b6bfe84f332a3c99656f73cf0251bce0a16ba88.tar.gz rails-7b6bfe84f332a3c99656f73cf0251bce0a16ba88.tar.bz2 rails-7b6bfe84f332a3c99656f73cf0251bce0a16ba88.zip |
refactor Reference to a ClassCache object, fix lazy lookup in Middleware so that anonymous classes are supported
Diffstat (limited to 'actionpack/test/dispatch')
-rw-r--r-- | actionpack/test/dispatch/middleware_stack/middleware_test.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/middleware_stack/middleware_test.rb b/actionpack/test/dispatch/middleware_stack/middleware_test.rb new file mode 100644 index 0000000000..aedd5feb38 --- /dev/null +++ b/actionpack/test/dispatch/middleware_stack/middleware_test.rb @@ -0,0 +1,50 @@ +require 'abstract_unit' +require 'action_dispatch/middleware/stack' + +module ActionDispatch + class MiddlewareStack + class MiddlewareTest < ActiveSupport::TestCase + class Omg; end + + { + 'concrete' => Omg, + 'anonymous' => Class.new + }.each do |name, klass| + + define_method("test_#{name}_klass") do + mw = Middleware.new klass + assert_equal klass, mw.klass + end + + define_method("test_#{name}_==") do + mw1 = Middleware.new klass + mw2 = Middleware.new klass + assert_equal mw1, mw2 + end + + end + + def test_string_class + mw = Middleware.new Omg.name + assert_equal Omg, mw.klass + end + + def test_double_equal_works_with_classes + k = Class.new + mw = Middleware.new k + assert_operator mw, :==, k + assert_operator mw, :!=, Class.new + end + + def test_double_equal_works_with_strings + mw = Middleware.new Omg + assert_operator mw, :==, Omg.name + end + + def test_double_equal_normalizes_strings + mw = Middleware.new Omg + assert_operator mw, :==, "::#{Omg.name}" + end + end + end +end |