Replace the class declaration with let statements

Instead of using a concrete class use let statement instead, this make
sure they are reset between run and make the variable available at the
context level.

Fixes #7017
This commit is contained in:
Pier-Hugues Pellerin 2017-05-03 21:16:04 -04:00
parent 9f2ce5d164
commit a758412499

View file

@ -53,13 +53,12 @@ describe LogStash::Plugins::Registry do
end
context "when loading plugin manually configured" do
it "should return the plugin" do
class SimplePlugin
end
let(:simple_plugin) { Class.new }
it "should return the plugin" do
expect { registry.lookup("filter", "simple_plugin") }.to raise_error(LoadError)
registry.add(:filter, "simple_plugin", SimplePlugin)
expect(registry.lookup("filter", "simple_plugin")).to eq(SimplePlugin)
registry.add(:filter, "simple_plugin", simple_plugin)
expect(registry.lookup("filter", "simple_plugin")).to eq(simple_plugin)
end
it "doesn't add multiple time the same plugin" do
@ -74,9 +73,9 @@ describe LogStash::Plugins::Registry do
end
it "allow you find plugin by type" do
registry.add(:filter, "simple_plugin", SimplePlugin)
registry.add(:filter, "simple_plugin", simple_plugin)
expect(registry.plugins_with_type(:filter)).to include(SimplePlugin)
expect(registry.plugins_with_type(:filter)).to include(simple_plugin)
expect(registry.plugins_with_type(:modules)).to match([])
end
end