Extract shared_context

This commit is contained in:
Koichi TANAKA 2014-12-03 14:30:19 +09:00
parent fbb8b658bb
commit c44ecb5ac7
6 changed files with 18 additions and 24 deletions

View File

@ -1,16 +1,11 @@
require "spec_helper" require "spec_helper"
describe "out_elasticsearch" do describe "out_elasticsearch", stub: :daemon do
let(:exists_user) { build(:user) } let(:exists_user) { build(:user) }
let(:daemon) { build(:fluentd, variant: "td-agent") } let(:match) { "test.out_forward.#{Time.now.to_i}.*" }
let(:match) { "test.out_elasticsearch.#{Time.now.to_i}.*" }
let(:location) { daemon_setting_out_elasticsearch_path } let(:location) { daemon_setting_out_elasticsearch_path }
before do before do
Fluentd.stub(:instance).and_return(daemon)
Fluentd::Agent::TdAgent.any_instance.stub(:detached_command).and_return(true)
daemon.agent.config_write ""
login_with exists_user login_with exists_user
end end

View File

@ -1,15 +1,10 @@
require "spec_helper" require "spec_helper"
describe "out_forward" do describe "out_forward", stub: :daemon do
let(:exists_user) { build(:user) } let(:exists_user) { build(:user) }
let(:daemon) { build(:fluentd, variant: "td-agent") }
let(:match) { "test.out_forward.#{Time.now.to_i}.*" } let(:match) { "test.out_forward.#{Time.now.to_i}.*" }
before do before do
Fluentd.stub(:instance).and_return(daemon)
Fluentd::Agent::TdAgent.any_instance.stub(:detached_command).and_return(true)
daemon.agent.config_write ""
login_with exists_user login_with exists_user
end end

View File

@ -1,15 +1,10 @@
require "spec_helper" require "spec_helper"
describe "out_td" do describe "out_td", stub: :daemon do
let(:exists_user) { build(:user) } let(:exists_user) { build(:user) }
let(:daemon) { build(:fluentd, variant: "td-agent") }
let(:api_key) { "dummydummy" } let(:api_key) { "dummydummy" }
before do before do
Fluentd.stub(:instance).and_return(daemon)
Fluentd::Agent::TdAgent.any_instance.stub(:detached_command).and_return(true)
daemon.agent.config_write ""
login_with exists_user login_with exists_user
end end

View File

@ -1,13 +1,9 @@
require "spec_helper" require "spec_helper"
describe "source_and_output", js: true do describe "source_and_output", js: true, stub: :daemon do
let(:exists_user) { build(:user) } let(:exists_user) { build(:user) }
let(:daemon) { build(:fluentd, variant: "td-agent") }
before do before do
Fluentd.stub(:instance).and_return(daemon)
Fluentd::Agent::TdAgent.any_instance.stub(:detached_command).and_return(true)
login_with exists_user login_with exists_user
end end

View File

@ -35,6 +35,7 @@ RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods config.include FactoryGirl::Syntax::Methods
config.include LoginMacro config.include LoginMacro
config.include JavascriptMacro config.include JavascriptMacro
config.include StubDaemon
# If true, the base class of anonymous controllers will be inferred # If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of # automatically. This will be the default behavior in future versions of

View File

@ -0,0 +1,12 @@
module StubDaemon
shared_context 'stub daemon', stub: :daemon do
let!(:exists_user) { build(:user) }
let!(:daemon) { build(:fluentd, variant: "td-agent") }
before do
Fluentd.stub(:instance).and_return(daemon)
Fluentd::Agent::TdAgent.any_instance.stub(:detached_command).and_return(true)
daemon.agent.config_write ""
end
end
end