summaryrefslogtreecommitdiff
path: root/spec/rubyspec/core/file/fixtures/common.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/rubyspec/core/file/fixtures/common.rb')
-rw-r--r--spec/rubyspec/core/file/fixtures/common.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/rubyspec/core/file/fixtures/common.rb b/spec/rubyspec/core/file/fixtures/common.rb
new file mode 100644
index 0000000000..50721388ad
--- /dev/null
+++ b/spec/rubyspec/core/file/fixtures/common.rb
@@ -0,0 +1,22 @@
+module FileSpecs
+ class SubString < String; end
+
+ def self.make_closer(obj, exc=nil)
+ ScratchPad << :file_opened
+
+ class << obj
+ attr_accessor :close_exception
+
+ alias_method :original_close, :close
+
+ def close
+ original_close
+ ScratchPad << :file_closed
+
+ raise @close_exception if @close_exception
+ end
+ end
+
+ obj.close_exception = exc
+ end
+end