# File lib/fluent/test/input_test.rb, line 27 def initialize(klass, &block) FileBuffer.clear_buffer_paths super(klass, &block) @emit_streams = [] @expects = nil # for checking only the number of emitted records during run @expected_emits_length = nil @run_timeout = 5 end
# File lib/fluent/test/input_test.rb, line 50 def emits all = [] @emit_streams.each {|tag,events| events.each {|time,record| all << [tag, time, record] } } all end
# File lib/fluent/test/input_test.rb, line 60 def events all = [] @emit_streams.each {|tag,events| all.concat events } all end
# File lib/fluent/test/input_test.rb, line 37 def expect_emit(tag, time, record) (@expects ||= []) << [tag, time, record] self end
# File lib/fluent/test/input_test.rb, line 42 def expected_emits @expects ||= [] end
# File lib/fluent/test/input_test.rb, line 68 def records all = [] @emit_streams.each {|tag,events| events.each {|time,record| all << record } } all end
# File lib/fluent/test/input_test.rb, line 78 def run(&block) m = method(:emit_stream) Engine.define_singleton_method(:emit_stream) {|tag,es| m.call(tag, es) } super { block.call if block if @expected_emits_length || @expects max_length = @expected_emits_length || @expects.length started_at = Time.now i, j = 0, 0 while i < max_length && Time.now <= started_at + @run_timeout if j >= @emit_streams.length sleep 0.01 next end tag, events = @emit_streams[j] events.each do |time, record| assert_equal(@expects[i], [tag, time, record]) if @expects i += 1 end j += 1 end assert_equal(@expects.length, i) if @expects end } self end
Generated with the Darkfish Rdoc Generator 2.