diff options
Diffstat (limited to 'spec/ruby/core/file/fixtures/common.rb')
-rw-r--r-- | spec/ruby/core/file/fixtures/common.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/ruby/core/file/fixtures/common.rb b/spec/ruby/core/file/fixtures/common.rb new file mode 100644 index 0000000000..50721388ad --- /dev/null +++ b/spec/ruby/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 |