aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/file_test.rb
diff options
context:
space:
mode:
authorIan Ker-Seymer <i.kerseymer@gmail.com>2015-01-28 00:33:57 -0700
committerIan Ker-Seymer <i.kerseymer@gmail.com>2015-01-28 00:40:25 -0700
commitb3c23f117695b3089c03b7c0d78781c176b2c418 (patch)
tree8e22ceeb85b8099b84a4f3efe3fda92875bb0766 /activesupport/test/core_ext/file_test.rb
parent36082a62048248c27cdd513c943ee94b716bd7f8 (diff)
downloadrails-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/core_ext/file_test.rb')
-rw-r--r--activesupport/test/core_ext/file_test.rb10
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"