Class: RSpec::Support::StdErrSplitter
- Inherits:
-
Object
- Object
- RSpec::Support::StdErrSplitter
show all
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-support-3.12.0/lib/rspec/support/spec/stderr_splitter.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of StdErrSplitter.
6
7
8
9
10
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-support-3.12.0/lib/rspec/support/spec/stderr_splitter.rb', line 6
def initialize(original)
@orig_stderr = original
@output_tracker = ::StringIO.new
@last_line = nil
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
17
18
19
20
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-support-3.12.0/lib/rspec/support/spec/stderr_splitter.rb', line 17
def method_missing(name, *args, &block)
@output_tracker.__send__(name, *args, &block) if @output_tracker.respond_to?(name)
@orig_stderr.__send__(name, *args, &block)
end
|
Instance Method Details
#==(other) ⇒ Object
22
23
24
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-support-3.12.0/lib/rspec/support/spec/stderr_splitter.rb', line 22
def ==(other)
@orig_stderr == other
end
|
#has_output? ⇒ Boolean
57
58
59
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-support-3.12.0/lib/rspec/support/spec/stderr_splitter.rb', line 57
def has_output?
!output.empty?
end
|
70
71
72
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-support-3.12.0/lib/rspec/support/spec/stderr_splitter.rb', line 70
def output
@output_tracker.string
end
|
#reopen(*args) ⇒ Object
26
27
28
29
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-support-3.12.0/lib/rspec/support/spec/stderr_splitter.rb', line 26
def reopen(*args)
reset!
@orig_stderr.reopen(*args)
end
|
61
62
63
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-support-3.12.0/lib/rspec/support/spec/stderr_splitter.rb', line 61
def reset!
@output_tracker = ::StringIO.new
end
|
To work around JRuby error: can’t convert RSpec::Support::StdErrSplitter into String
33
34
35
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-support-3.12.0/lib/rspec/support/spec/stderr_splitter.rb', line 33
def to_io
@orig_stderr.to_io
end
|
#verify_no_warnings! ⇒ Object
65
66
67
68
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-support-3.12.0/lib/rspec/support/spec/stderr_splitter.rb', line 65
def verify_no_warnings!
raise "Warnings were generated: #{output}" if has_output?
reset!
end
|
#write(line) ⇒ Object
To work around JRuby error: TypeError: $stderr must have write method, RSpec::StdErrSplitter given
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-support-3.12.0/lib/rspec/support/spec/stderr_splitter.rb', line 39
def write(line)
return if line =~ %r{^\S+/gems/\S+:\d+: warning:}
return if @last_line =~ %r{^\S+/gems/\S+:\d+: warning:} &&
line =~ %r{warning: The called method .* is defined here}
return if line =~ %r{lib/ruby/2\.7\.0/fileutils\.rb:622: warning:}
@orig_stderr.write(line)
@output_tracker.write(line)
ensure
@last_line = line
end
|