Class: RSpec::Risky::Minitest::Plugin::OutputCapture::Stream
- Inherits:
-
Object
- Object
- RSpec::Risky::Minitest::Plugin::OutputCapture::Stream
show all
- Defined in:
- lib/rspec/risky/minitest/output_capture.rb
Instance Method Summary
collapse
Constructor Details
#initialize(stream_name, io, report) ⇒ Stream
Returns a new instance of Stream.
28
29
30
31
32
|
# File 'lib/rspec/risky/minitest/output_capture.rb', line 28
def initialize(stream_name, io, report)
@stream_name = stream_name
@io = io
@report = report
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
58
59
60
61
62
|
# File 'lib/rspec/risky/minitest/output_capture.rb', line 58
def method_missing(method_name, *args, &block)
return super unless @io.respond_to?(method_name)
@io.public_send(method_name, *args, &block)
end
|
Instance Method Details
#<<(data) ⇒ Object
41
42
43
44
|
# File 'lib/rspec/risky/minitest/output_capture.rb', line 41
def <<(data)
write(data)
self
end
|
#print(*objects) ⇒ Object
52
53
54
55
56
|
# File 'lib/rspec/risky/minitest/output_capture.rb', line 52
def print(*objects)
data = objects.empty? ? $_.to_s : objects.map(&:to_s).join($,)
@report.record(@stream_name, data, caller_locations(1)) unless OutputCapture.suppressed?
@io.print(*objects)
end
|
#puts(*objects) ⇒ Object
46
47
48
49
50
|
# File 'lib/rspec/risky/minitest/output_capture.rb', line 46
def puts(*objects)
data = objects.empty? ? "\n" : objects.map { |object| "#{object}\n" }.join
@report.record(@stream_name, data, caller_locations(1)) unless OutputCapture.suppressed?
@io.puts(*objects)
end
|
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
64
65
66
|
# File 'lib/rspec/risky/minitest/output_capture.rb', line 64
def respond_to_missing?(method_name, include_private = false)
@io.respond_to?(method_name, include_private) || super
end
|
#write(data) ⇒ Object
34
35
36
37
38
39
|
# File 'lib/rspec/risky/minitest/output_capture.rb', line 34
def write(data)
return @io.write(data) if OutputCapture.suppressed?
@report.record(@stream_name, data.to_s, caller_locations(1))
@io.write(data)
end
|