From af1dbe7fc2920db768ab8744a16db6c00948dc34 Mon Sep 17 00:00:00 2001 From: Joao Duarte Date: Tue, 7 Jul 2015 14:06:56 +0100 Subject: [PATCH] refactor existing directory spec test Fixes #59 --- spec/inputs/file_spec.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/spec/inputs/file_spec.rb b/spec/inputs/file_spec.rb index 17d32a3..d5335ee 100644 --- a/spec/inputs/file_spec.rb +++ b/spec/inputs/file_spec.rb @@ -167,13 +167,17 @@ insist { events[1]["host"] } == "#{Socket.gethostname.force_encoding(Encoding::UTF_8)}" end - context "sincedb_path is an existing directory" do + context "when sincedb_path is an existing directory" do + let(:tmpfile_path) { Stud::Temporary.pathname } + let(:sincedb_path) { Stud::Temporary.directory } + subject { LogStash::Inputs::File.new("path" => tmpfile_path, "sincedb_path" => sincedb_path) } + + after :each do + FileUtils.rm_rf(sincedb_path) + end + it "should raise exception" do - tmpfile_path = Stud::Temporary.pathname - Stud::Temporary.directory do |sincedb_path| - plugin = LogStash::Inputs::File.new("path" => tmpfile_path, "sincedb_path" => sincedb_path) - expect { plugin.register }.to raise_error(ArgumentError) - end + expect { subject.register }.to raise_error(ArgumentError) end end end