diff options
author | Ian Ker-Seymer <i.kerseymer@gmail.com> | 2015-01-28 00:33:57 -0700 |
---|---|---|
committer | Ian Ker-Seymer <i.kerseymer@gmail.com> | 2015-01-28 00:40:25 -0700 |
commit | b3c23f117695b3089c03b7c0d78781c176b2c418 (patch) | |
tree | 8e22ceeb85b8099b84a4f3efe3fda92875bb0766 /activesupport/test | |
parent | 36082a62048248c27cdd513c943ee94b716bd7f8 (diff) | |
download | rails-b3c23f117695b3089c03b7c0d78781c176b2c418.tar.gz rails-b3c23f117695b3089c03b7c0d78781c176b2c418.tar.bz2 rails-b3c23f117695b3089c03b7c0d78781c176b2c418.zip |
Return value of yielded block in File.atomic_write
Staying true to Ruby convention, we now return the value of the yielded
block from `File.atomic_write {...}`. This mimics the behavior of MRI's
`File.open {...}`.
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/file_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/file_test.rb b/activesupport/test/core_ext/file_test.rb index 2c04e9687c..cde0132b97 100644 --- a/activesupport/test/core_ext/file_test.rb +++ b/activesupport/test/core_ext/file_test.rb @@ -57,6 +57,16 @@ class AtomicWriteTest < ActiveSupport::TestCase File.unlink(file_name) rescue nil end + def test_atomic_write_returns_result_from_yielded_block + block_return_value = File.atomic_write(file_name, Dir.pwd) do |file| + "Hello world!" + end + + assert_equal "Hello world!", block_return_value + ensure + File.unlink(file_name) rescue nil + end + private def file_name "atomic.file" |