Module: NoShitInMyGreenDots::Integrations::RSpec

Defined in:
lib/no_shit_in_my_green_dots/rspec.rb

Defined Under Namespace

Classes: StdoutLeak

Class Method Summary collapse

Class Method Details

.install!Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/no_shit_in_my_green_dots/rspec.rb', line 14

def self.install!
  return if @installed

  ::RSpec.configure do |config|
    config.around do |example|
      matcher = ::RSpec::Matchers::BuiltIn::Output.new(nil).to_stdout_from_any_process
      matcher.matches?(-> { example.run })
      captured_output = matcher.instance_variable_get(:@actual).to_s

      next if captured_output.nil? || captured_output.empty?
      next if example.exception

      raise StdoutLeak.new(captured_output)
    end
  end

  @installed = true
end