From 4fc050527cf1091bca6d4415c9c170f5a8ee08a9 Mon Sep 17 00:00:00 2001 From: Pere Urbon-Bayes Date: Thu, 8 Oct 2015 17:41:08 +0200 Subject: [PATCH] add an input helper to run without the need of a config and only from the plugin object Fixes #40 --- lib/logstash/devutils/rspec/logstash_helpers.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/logstash/devutils/rspec/logstash_helpers.rb b/lib/logstash/devutils/rspec/logstash_helpers.rb index 68609e5..78748cd 100644 --- a/lib/logstash/devutils/rspec/logstash_helpers.rb +++ b/lib/logstash/devutils/rspec/logstash_helpers.rb @@ -86,6 +86,19 @@ def output_func(event) result end # def input + def plugin_input(plugin, &block) + queue = Queue.new + + input_thread = Thread.new do + plugin.run(queue) + end + result = block.call(queue) + + plugin.do_stop + input_thread.join + result + end + def agent(&block) it("agent(#{caller[0].gsub(/ .*/, "")}) runs") do