Extract commonality into the base class, make life easy for our plugin writers.

This commit is contained in:
Chris Lowder
2012-01-24 14:36:38 +00:00
parent ed4a32518f
commit bc1c5e4c74
10 changed files with 45 additions and 41 deletions
+6 -2
View File
@@ -30,7 +30,9 @@ describe "Foreman::CLI", :fakefs do
it "respects --env" do
write_procfile
write_env("envfile")
mock.instance_of(Foreman::Export::Upstart).export("/upstart", { "env" => "envfile" })
mock_export = mock(Foreman::Export::Upstart)
mock(Foreman::Export::Upstart).new(is_a(Foreman::Engine), { "env" => "envfile" }) { mock_export }
mock_export.export("/upstart")
foreman %{ export upstart /upstart --env envfile }
end
end
@@ -60,7 +62,9 @@ describe "Foreman::CLI", :fakefs do
it "runs successfully" do
dont_allow(subject).error
mock.instance_of(Foreman::Export::Upstart).export("/tmp/foo", {})
mock_export = mock(Foreman::Export::Upstart)
mock(Foreman::Export::Upstart).new(is_a(Foreman::Engine), {}) { mock_export }
mock_export.export("/tmp/foo")
subject.export("upstart", "/tmp/foo")
end
end
+1 -1
View File
@@ -6,7 +6,7 @@ require "tmpdir"
describe Foreman::Export::Bluepill, :fakefs do
let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile") }
let(:engine) { Foreman::Engine.new(procfile) }
let(:bluepill) { Foreman::Export::Bluepill.new(engine) }
let(:bluepill) { Foreman::Export::Bluepill.new(engine, :concurrency => "alpha=2") }
before(:each) { load_export_templates_into_fakefs("bluepill") }
before(:each) { stub(bluepill).say }
+3 -2
View File
@@ -6,7 +6,7 @@ require "tmpdir"
describe Foreman::Export::Runit, :fakefs do
let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile", 'bar=baz') }
let(:engine) { Foreman::Engine.new(procfile) }
let(:runit) { Foreman::Export::Runit.new(engine) }
let(:runit) { Foreman::Export::Runit.new(engine, :concurrency => 'alpha=2') }
before(:each) { load_export_templates_into_fakefs("runit") }
before(:each) { stub(runit).say }
@@ -14,7 +14,8 @@ describe Foreman::Export::Runit, :fakefs do
it "exports to the filesystem" do
FileUtils.mkdir_p('/tmp/init')
runit.export('/tmp/init', :concurrency => "alpha=2,bravo=1")
runit.export('/tmp/init')
File.read("/tmp/init/app-alpha-1/run").should == example_export_file('runit/app-alpha-1-run')
File.read("/tmp/init/app-alpha-1/log/run").should ==
+3 -2
View File
@@ -6,7 +6,7 @@ require "tmpdir"
describe Foreman::Export::Upstart, :fakefs do
let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile") }
let(:engine) { Foreman::Engine.new(procfile) }
let(:upstart) { Foreman::Export::Upstart.new(engine) }
let(:upstart) { Foreman::Export::Upstart.new(engine, :concurrency => "alpha=2") }
before(:each) { load_export_templates_into_fakefs("upstart") }
before(:each) { stub(upstart).say }
@@ -33,6 +33,7 @@ describe Foreman::Export::Upstart, :fakefs do
context "with alternate templates" do
let(:template_root) { "/tmp/alternate" }
let(:upstart) { Foreman::Export::Upstart.new(engine, :template => template_root) }
before do
FileUtils.mkdir_p template_root
@@ -40,7 +41,7 @@ describe Foreman::Export::Upstart, :fakefs do
end
it "can export with alternate template files" do
upstart.export("/tmp/init", :template => template_root)
upstart.export("/tmp/init")
File.read("/tmp/init/app.conf").should == "alternate_template\n"
end