Sha256: e08b3b73d173ac1b5523d05080637a15b2ced84cc278a2484bab17f2e5330e5b

Contents?: true

Size: 1.49 KB

Versions: 241

Compression:

Stored size: 1.49 KB

Contents

require 'stringio'

module RSpec
  module Support
    class StdErrSplitter
      def initialize(original)
        @orig_stderr    = original
        @output_tracker = ::StringIO.new
      end

      respond_to_name = (::RUBY_VERSION.to_f < 1.9) ? :respond_to? : :respond_to_missing?
      define_method respond_to_name do |*args|
        @orig_stderr.respond_to?(*args) || super(*args)
      end

      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

      def ==(other)
        @orig_stderr == other
      end

      def reopen(*args)
        reset!
        @orig_stderr.reopen(*args)
      end

      # To work around JRuby error:
      # can't convert RSpec::Support::StdErrSplitter into String
      def to_io
        @orig_stderr.to_io
      end

      # To work around JRuby error:
      # TypeError: $stderr must have write method, RSpec::StdErrSplitter given
      def write(line)
        return if line =~ %r{^\S+/gems/\S+:\d+: warning:} # http://rubular.com/r/kqeUIZOfPG

        @orig_stderr.write(line)
        @output_tracker.write(line)
      end

      def has_output?
        !output.empty?
      end

      def reset!
        @output_tracker = ::StringIO.new
      end

      def verify_no_warnings!
        raise "Warnings were generated: #{output}" if has_output?
        reset!
      end

      def output
        @output_tracker.string
      end
    end
  end
end

Version data entries

241 entries across 217 versions & 61 rubygems

Version Path
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/stderr_splitter.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/stderr_splitter.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/stderr_splitter.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/stderr_splitter.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/stderr_splitter.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/stderr_splitter.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/stderr_splitter.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/stderr_splitter.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/stderr_splitter.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/stderr_splitter.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/stderr_splitter.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/stderr_splitter.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/stderr_splitter.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/stderr_splitter.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/stderr_splitter.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/stderr_splitter.rb
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/stderr_splitter.rb
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/stderr_splitter.rb
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/stderr_splitter.rb
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/rspec-support-3.8.2/lib/rspec/support/spec/stderr_splitter.rb