# File lib/mspec/matchers/output_to_fd.rb, line 25 25: def matches?(block) 26: old_to = @to.dup 27: out = File.open(tmp("mspec_output_to_#{$$}_#{Time.now.to_i}"), 'w+') 28: 29: # Replacing with a file handle so that Readline etc. work 30: @to.reopen out 31: 32: block.call 33: 34: ensure 35: begin 36: @to.reopen old_to 37: 38: out.rewind 39: @actual = out.read 40: 41: case @expected 42: when Regexp 43: return !(@actual =~ @expected).nil? 44: else 45: return @actual == @expected 46: end 47: 48: # Clean up 49: ensure 50: out.close unless out.closed? 51: FileUtils.rm out.path 52: end 53: 54: return true 55: end