aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/module/attribute_accessor_per_thread_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/test/core_ext/module/attribute_accessor_per_thread_test.rb')
-rw-r--r--activesupport/test/core_ext/module/attribute_accessor_per_thread_test.rb21
1 files changed, 7 insertions, 14 deletions
diff --git a/activesupport/test/core_ext/module/attribute_accessor_per_thread_test.rb b/activesupport/test/core_ext/module/attribute_accessor_per_thread_test.rb
index c73ca0be0c..a2b3239884 100644
--- a/activesupport/test/core_ext/module/attribute_accessor_per_thread_test.rb
+++ b/activesupport/test/core_ext/module/attribute_accessor_per_thread_test.rb
@@ -14,7 +14,7 @@ class ModuleAttributeAccessorPerThreadTest < ActiveSupport::TestCase
class SubMyClass < MyClass
end
- def setup
+ setup do
@class = MyClass
@subclass = SubMyClass
@object = @class.new
@@ -23,18 +23,11 @@ class ModuleAttributeAccessorPerThreadTest < ActiveSupport::TestCase
def test_can_initialize_with_default_value
Thread.new do
@class.thread_mattr_accessor :baz, default: "default_value"
- assert_equal "default_value", @class.baz
- end.join
- end
-
- def test_can_initialize_with_a_block_as_default_value
- Thread.new do
- @class.thread_mattr_accessor :baz do
- "default_value"
- end
assert_equal "default_value", @class.baz
end.join
+
+ assert_nil @class.baz
end
def test_should_use_mattr_default
@@ -82,23 +75,23 @@ class ModuleAttributeAccessorPerThreadTest < ActiveSupport::TestCase
threads = []
threads << Thread.new do
@class.foo = "things"
- sleep 1
+ Thread.pass
assert_equal "things", @class.foo
end
threads << Thread.new do
@class.foo = "other things"
- sleep 1
+ Thread.pass
assert_equal "other things", @class.foo
end
threads << Thread.new do
@class.foo = "really other things"
- sleep 1
+ Thread.pass
assert_equal "really other things", @class.foo
end
- threads.each { |t| t.join }
+ threads.each(&:join)
end
def test_should_raise_name_error_if_attribute_name_is_invalid