fluentd-ui/spec/models/fluentd/agent/local_common_spec.rb
2014-12-03 17:07:08 +09:00

30 lines
797 B
Ruby

require 'spec_helper'
require 'fileutils'
describe 'Fluentd::Agent::LocalCommon' do
subject { target_class.new.tap{|t| t.pid_file = pid_file_path} }
let!(:target_class) { Struct.new(:pid_file){ include Fluentd::Agent::LocalCommon } }
let!(:pid_file_path) { Rails.root.join('tmp', 'fluentd-test', 'local_common_test.pid').to_s }
describe '#pid' do
context 'no pid file exists' do
its(:pid) { should be_nil }
end
context 'empty pid file given' do
before { FileUtils.touch pid_file_path }
after { FileUtils.rm pid_file_path }
its(:pid) { should be_nil }
end
context 'valid pid file given' do
before { File.write pid_file_path, '9999' }
after { FileUtils.rm pid_file_path }
its(:pid) { should eq(9999) }
end
end
end