foreman 0.47.0 → 0.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. data/bin/taskman +8 -0
  2. data/data/example/Procfile +4 -3
  3. data/data/example/spawnee +14 -0
  4. data/data/example/spawner +7 -0
  5. data/data/export/bluepill/master.pill.erb +10 -10
  6. data/data/export/launchd/launchd.plist.erb +3 -3
  7. data/data/export/runit/log/run.erb +7 -0
  8. data/data/export/runit/run.erb +2 -2
  9. data/data/export/supervisord/app.conf.erb +12 -12
  10. data/data/export/upstart/master.conf.erb +2 -2
  11. data/data/export/upstart/process.conf.erb +3 -3
  12. data/lib/foreman/cli.rb +57 -22
  13. data/lib/foreman/engine/cli.rb +105 -0
  14. data/lib/foreman/engine.rb +233 -148
  15. data/lib/foreman/env.rb +27 -0
  16. data/lib/foreman/export/base.rb +107 -27
  17. data/lib/foreman/export/bluepill.rb +3 -17
  18. data/lib/foreman/export/inittab.rb +8 -11
  19. data/lib/foreman/export/launchd.rb +4 -16
  20. data/lib/foreman/export/runit.rb +14 -39
  21. data/lib/foreman/export/supervisord.rb +3 -13
  22. data/lib/foreman/export/upstart.rb +9 -27
  23. data/lib/foreman/export.rb +1 -2
  24. data/lib/foreman/process.rb +73 -67
  25. data/lib/foreman/procfile.rb +59 -25
  26. data/lib/foreman/version.rb +1 -1
  27. data/lib/foreman.rb +4 -0
  28. data/man/foreman.1 +5 -1
  29. data/spec/foreman/cli_spec.rb +46 -150
  30. data/spec/foreman/engine_spec.rb +46 -80
  31. data/spec/foreman/export/base_spec.rb +4 -7
  32. data/spec/foreman/export/bluepill_spec.rb +7 -6
  33. data/spec/foreman/export/inittab_spec.rb +7 -7
  34. data/spec/foreman/export/launchd_spec.rb +4 -7
  35. data/spec/foreman/export/runit_spec.rb +12 -17
  36. data/spec/foreman/export/supervisord_spec.rb +7 -56
  37. data/spec/foreman/export/upstart_spec.rb +18 -23
  38. data/spec/foreman/process_spec.rb +27 -124
  39. data/spec/foreman/procfile_spec.rb +26 -16
  40. data/spec/resources/Procfile +4 -0
  41. data/spec/resources/bin/echo +2 -0
  42. data/spec/resources/bin/env +2 -0
  43. data/spec/resources/bin/test +2 -0
  44. data/spec/resources/export/bluepill/app-concurrency.pill +4 -4
  45. data/spec/resources/export/bluepill/app.pill +4 -4
  46. data/spec/resources/export/supervisord/app-alpha-1.conf +24 -0
  47. data/spec/resources/export/supervisord/app-alpha-2.conf +4 -4
  48. data/spec/spec_helper.rb +57 -6
  49. metadata +28 -19
  50. data/data/export/runit/log_run.erb +0 -7
  51. data/lib/foreman/color.rb +0 -40
  52. data/lib/foreman/procfile_entry.rb +0 -26
  53. data/lib/foreman/utils.rb +0 -18
  54. data/spec/foreman/color_spec.rb +0 -31
  55. data/spec/foreman/procfile_entry_spec.rb +0 -13
  56. data/spec/resources/export/supervisord/app-env-with-comma.conf +0 -24
  57. data/spec/resources/export/supervisord/app-env.conf +0 -21
  58. data/spec/resources/export/supervisord/app.conf +0 -24
  59. /data/spec/resources/export/runit/{app-alpha-1-log-run → app-alpha-1/log/run} +0 -0
  60. /data/spec/resources/export/runit/{app-alpha-1-run → app-alpha-1/run} +0 -0
  61. /data/spec/resources/export/runit/{app-alpha-2-log-run → app-alpha-2/log/run} +0 -0
  62. /data/spec/resources/export/runit/{app-alpha-2-run → app-alpha-2/run} +0 -0
  63. /data/spec/resources/export/runit/{app-bravo-1-log-run → app-bravo-1/log/run} +0 -0
  64. /data/spec/resources/export/runit/{app-bravo-1-run → app-bravo-1/run} +0 -0
@@ -3,188 +3,84 @@ require "foreman/cli"
3
3
 
4
4
  describe "Foreman::CLI", :fakefs do
5
5
  subject { Foreman::CLI.new }
6
- let(:engine) { subject.send(:engine) }
7
- let(:entries) { engine.procfile.entries.inject({}) { |h,e| h.update(e.name => e) } }
8
6
 
9
- describe "start" do
10
- describe "with a non-existent Procfile" do
11
- it "prints an error" do
12
- mock_error(subject, "Procfile does not exist.") do
13
- dont_allow.instance_of(Foreman::Engine).start
14
- subject.start
15
- end
16
- end
17
- end
18
-
19
- describe "with a Procfile" do
20
- before(:each) { write_procfile }
7
+ describe ".foreman" do
8
+ before { File.open(".foreman", "w") { |f| f.puts "formation: alpha=2" } }
21
9
 
22
- it "runs successfully" do
23
- dont_allow(subject).error
24
- mock.instance_of(Foreman::Engine).start
25
- subject.start
26
- end
27
-
28
- it "can run a single process" do
29
- dont_allow(subject).error
30
- stub(engine).watch_for_output
31
- stub(engine).watch_for_termination
32
- mock(entries["alpha"]).spawn(1, is_a(IO), engine.directory, {}, 5000) { [] }
33
- mock(entries["bravo"]).spawn(0, is_a(IO), engine.directory, {}, 5100) { [] }
34
- subject.start("alpha")
35
- end
10
+ it "provides default options" do
11
+ subject.send(:options)["formation"].should == "alpha=2"
36
12
  end
37
13
 
38
- describe "with an alternate root" do
39
- it "reads the Procfile from that root" do
40
- write_procfile "/some/app/Procfile"
41
- mock(Foreman::Procfile).new("/some/app/Procfile")
42
- mock.instance_of(Foreman::Engine).start
43
- foreman %{ start -d /some/app }
44
- end
14
+ it "is overridden by options at the cli" do
15
+ subject = Foreman::CLI.new([], :formation => "alpha=3")
16
+ subject.send(:options)["formation"].should == "alpha=3"
45
17
  end
46
18
  end
47
19
 
48
- describe "export" do
49
- describe "options" do
50
- it "uses .foreman" do
51
- write_procfile
52
- File.open(".foreman", "w") { |f| f.puts "concurrency: alpha=2" }
53
- mock_export = mock(Foreman::Export::Upstart)
54
- mock(Foreman::Export::Upstart).new("/upstart", is_a(Foreman::Engine), { "concurrency" => "alpha=2" }) { mock_export }
55
- mock_export.export
56
- foreman %{ export upstart /upstart }
57
- end
58
-
59
- it "respects --env" do
60
- write_procfile
61
- write_env("envfile")
62
- mock_export = mock(Foreman::Export::Upstart)
63
- mock(Foreman::Export::Upstart).new("/upstart", is_a(Foreman::Engine), { "env" => "envfile" }) { mock_export }
64
- mock_export.export
65
- foreman %{ export upstart /upstart --env envfile }
66
- end
67
- end
68
-
69
- describe "with a non-existent Procfile" do
70
- it "prints an error" do
20
+ describe "start" do
21
+ describe "when a Procfile doesnt exist", :fakefs do
22
+ it "displays an error" do
71
23
  mock_error(subject, "Procfile does not exist.") do
72
- dont_allow.instance_of(Foreman::Engine).export
73
- subject.export("testapp")
24
+ dont_allow.instance_of(Foreman::Engine).start
25
+ subject.start
74
26
  end
75
27
  end
76
28
  end
77
29
 
78
- describe "with a Procfile" do
79
- before(:each) { write_procfile }
80
-
81
- describe "with a formatter with a generic error" do
82
- before do
83
- mock(Foreman::Export).formatter("errorful") { Class.new(Foreman::Export::Base) do
84
- def export
85
- raise Foreman::Export::Exception.new("foo")
86
- end
87
- end }
88
- end
89
-
90
- it "prints an error" do
91
- mock_error(subject, "foo") do
92
- subject.export("errorful")
93
- end
30
+ describe "with a valid Procfile" do
31
+ it "can run a single command" do
32
+ without_fakefs do
33
+ output = foreman("start env -f #{resource_path("Procfile")}")
34
+ output.should =~ /env.1/
35
+ output.should_not =~ /test.1/
94
36
  end
95
37
  end
96
38
 
97
- describe "with a valid config" do
98
- before(:each) { write_foreman_config("testapp") }
99
-
100
- it "runs successfully" do
101
- dont_allow(subject).error
102
- mock_export = mock(Foreman::Export::Upstart)
103
- mock(Foreman::Export::Upstart).new("/tmp/foo", is_a(Foreman::Engine), {}) { mock_export }
104
- mock_export.export
105
- subject.export("upstart", "/tmp/foo")
39
+ it "can run all commands" do
40
+ without_fakefs do
41
+ output = foreman("start -f #{resource_path("Procfile")} -e #{resource_path(".env")}")
42
+ output.should =~ /echo.1 \| echoing/
43
+ output.should =~ /env.1 \| bar/
44
+ output.should =~ /test.1 \| testing/
106
45
  end
107
46
  end
108
47
  end
109
48
  end
110
49
 
111
50
  describe "check" do
112
- describe "with a valid Procfile" do
113
- before { write_procfile }
114
-
115
- it "displays the jobs" do
116
- mock(subject).puts("valid procfile detected (alpha, bravo)")
117
- subject.check
118
- end
51
+ it "with a valid Procfile displays the jobs" do
52
+ write_procfile
53
+ foreman("check").should == "valid procfile detected (alpha, bravo)\n"
119
54
  end
120
55
 
121
- describe "with a blank Procfile" do
122
- before do
123
- FileUtils.touch("Procfile")
124
- end
125
-
126
- it "displays an error" do
127
- mock_error(subject, "no processes defined") do
128
- subject.check
129
- end
130
- end
56
+ it "with a blank Procfile displays an error" do
57
+ FileUtils.touch "Procfile"
58
+ foreman("check").should == "ERROR: no processes defined\n"
131
59
  end
132
60
 
133
- describe "without a Procfile" do
134
- it "displays an error" do
135
- mock_error(subject, "Procfile does not exist.") do
136
- subject.check
137
- end
138
- end
61
+ it "without a Procfile displays an error" do
62
+ FileUtils.rm_f "Procfile"
63
+ foreman("check").should == "ERROR: Procfile does not exist.\n"
139
64
  end
140
65
  end
141
66
 
142
67
  describe "run" do
143
- describe "with a valid Procfile" do
144
- before { write_procfile }
145
-
146
- describe "and a command" do
147
- let(:command) { ["ls", "-l", "foo bar"] }
148
-
149
- before(:each) do
150
- stub(subject).exec
151
- end
152
-
153
- it "should load the environment file" do
154
- write_env
155
- preserving_env do
156
- subject.run *command
157
- ENV["FOO"].should == "bar"
158
- end
159
-
160
- ENV["FOO"].should be_nil
161
- end
162
-
163
- it "should exec the argument list as a shell command" do
164
- mock(subject).exec(command.shelljoin)
165
- subject.run *command
166
- end
167
- end
168
-
169
- describe "and a non-existent command" do
170
- let(:command) { "iuhtngrglhulhdfg" }
68
+ it "can run a command" do
69
+ forked_foreman("run echo 1").should == "1\n"
70
+ end
171
71
 
172
- it "should print an error" do
173
- mock_error(subject, "command not found: #{command}") do
174
- subject.run command
175
- end
176
- end
177
- end
72
+ it "includes the environment" do
73
+ forked_foreman("run #{resource_path("bin/env FOO")} -e #{resource_path(".env")}").should == "bar\n"
74
+ end
75
+ end
178
76
 
179
- describe "and a non-executable command" do
180
- let(:command) { __FILE__ }
77
+ describe "version" do
78
+ it "displays gem version" do
79
+ foreman("version").chomp.should == Foreman::VERSION
80
+ end
181
81
 
182
- it "should print an error" do
183
- mock_error(subject, "not executable: #{command}") do
184
- subject.run command
185
- end
186
- end
187
- end
82
+ it "displays gem version on shortcut command" do
83
+ foreman("-v").chomp.should == Foreman::VERSION
188
84
  end
189
85
  end
190
86
 
@@ -1,14 +1,25 @@
1
1
  require "spec_helper"
2
2
  require "foreman/engine"
3
3
 
4
- describe "Foreman::Engine", :fakefs do
5
- subject { Foreman::Engine.new("Procfile", {}) }
4
+ class Foreman::Engine::Tester < Foreman::Engine
5
+ attr_reader :buffer
6
6
 
7
- before do
8
- any_instance_of(Foreman::Engine) do |engine|
9
- stub(engine).proctitle
10
- stub(engine).termtitle
11
- end
7
+ def startup
8
+ @buffer = ""
9
+ end
10
+
11
+ def output(name, data)
12
+ @buffer += "#{name}: #{data}"
13
+ end
14
+
15
+ def shutdown
16
+ end
17
+ end
18
+
19
+ describe "Foreman::Engine", :fakefs do
20
+ subject do
21
+ write_procfile "Procfile"
22
+ Foreman::Engine::Tester.new.load_procfile("Procfile")
12
23
  end
13
24
 
14
25
  describe "initialize" do
@@ -16,65 +27,53 @@ describe "Foreman::Engine", :fakefs do
16
27
  before { write_procfile }
17
28
 
18
29
  it "reads the processes" do
19
- subject.procfile["alpha"].command.should == "./alpha"
20
- subject.procfile["bravo"].command.should == "./bravo"
30
+ subject.process("alpha").command.should == "./alpha"
31
+ subject.process("bravo").command.should == "./bravo"
21
32
  end
22
33
  end
23
34
  end
24
35
 
25
36
  describe "start" do
26
37
  it "forks the processes" do
27
- write_procfile
28
- mock.instance_of(Foreman::Process).run_process(Dir.pwd, "./alpha", is_a(IO))
29
- mock.instance_of(Foreman::Process).run_process(Dir.pwd, "./bravo", is_a(IO))
38
+ mock(subject.process("alpha")).run(anything)
39
+ mock(subject.process("bravo")).run(anything)
30
40
  mock(subject).watch_for_output
31
41
  mock(subject).watch_for_termination
32
42
  subject.start
33
43
  end
34
44
 
35
45
  it "handles concurrency" do
36
- write_procfile
37
- engine = Foreman::Engine.new("Procfile",:concurrency => "alpha=2")
38
- mock.instance_of(Foreman::Process).run_process(Dir.pwd, "./alpha", is_a(IO)).twice
39
- mock.instance_of(Foreman::Process).run_process(Dir.pwd, "./bravo", is_a(IO)).never
40
- mock(engine).watch_for_output
41
- mock(engine).watch_for_termination
42
- engine.start
46
+ subject.options[:formation] = "alpha=2"
47
+ mock(subject.process("alpha")).run(anything).twice
48
+ mock(subject.process("bravo")).run(anything).never
49
+ mock(subject).watch_for_output
50
+ mock(subject).watch_for_termination
51
+ subject.start
43
52
  end
44
53
  end
45
54
 
46
55
  describe "directories" do
47
56
  it "has the directory default relative to the Procfile" do
48
57
  write_procfile "/some/app/Procfile"
49
- engine = Foreman::Engine.new("/some/app/Procfile")
50
- engine.directory.should == "/some/app"
58
+ engine = Foreman::Engine.new.load_procfile("/some/app/Procfile")
59
+ engine.root.should == "/some/app"
51
60
  end
52
61
  end
53
62
 
54
63
  describe "environment" do
55
- before(:each) do
56
- write_procfile
57
- stub(Process).fork
58
- any_instance_of(Foreman::Engine) do |engine|
59
- stub(engine).info
60
- stub(engine).spawn_processes
61
- stub(engine).watch_for_termination
62
- end
63
- end
64
-
65
- it "should read if specified" do
64
+ it "should read env files" do
66
65
  File.open("/tmp/env", "w") { |f| f.puts("FOO=baz") }
67
- engine = Foreman::Engine.new("Procfile", :env => "/tmp/env")
68
- engine.environment.should == {"FOO"=>"baz"}
69
- engine.start
66
+ subject.load_env("/tmp/env")
67
+ subject.env["FOO"].should == "baz"
70
68
  end
71
69
 
72
70
  it "should read more than one if specified" do
73
71
  File.open("/tmp/env1", "w") { |f| f.puts("FOO=bar") }
74
72
  File.open("/tmp/env2", "w") { |f| f.puts("BAZ=qux") }
75
- engine = Foreman::Engine.new("Procfile", :env => "/tmp/env1,/tmp/env2")
76
- engine.environment.should == { "FOO"=>"bar", "BAZ"=>"qux" }
77
- engine.start
73
+ subject.load_env "/tmp/env1"
74
+ subject.load_env "/tmp/env2"
75
+ subject.env["FOO"].should == "bar"
76
+ subject.env["BAZ"].should == "qux"
78
77
  end
79
78
 
80
79
  it "should handle quoted values" do
@@ -84,55 +83,22 @@ describe "Foreman::Engine", :fakefs do
84
83
  f.puts "FRED='barney'"
85
84
  f.puts 'OTHER="escaped\"quote"'
86
85
  end
87
- engine = Foreman::Engine.new("Procfile", :env => "/tmp/env")
88
- engine.environment.should == { "FOO" => "bar", "BAZ" => "qux", "FRED" => "barney", "OTHER" => 'escaped"quote' }
86
+ subject.load_env "/tmp/env"
87
+ subject.env["FOO"].should == "bar"
88
+ subject.env["BAZ"].should == "qux"
89
+ subject.env["FRED"].should == "barney"
90
+ subject.env["OTHER"].should == 'escaped"quote'
89
91
  end
90
92
 
91
93
  it "should fail if specified and doesnt exist" do
92
- mock.instance_of(Foreman::Engine).error("No such file: /tmp/env")
93
- engine = Foreman::Engine.new("Procfile", :env => "/tmp/env")
94
- end
95
-
96
- it "should read .env if none specified" do
97
- File.open(".env", "w") { |f| f.puts("FOO=qoo") }
98
- engine = Foreman::Engine.new("Procfile")
99
- engine.environment.should == {"FOO"=>"qoo"}
100
- engine.start
94
+ lambda { subject.load_env "/tmp/env" }.should raise_error(Errno::ENOENT)
101
95
  end
102
96
 
103
97
  it "should set port from .env if specified" do
104
- File.open(".env", "w") { |f| f.puts("PORT=8017") }
105
- engine = Foreman::Engine.new("Procfile")
106
- engine.send(:base_port).should == "8017"
107
- engine.start
108
- end
109
-
110
- it "should be loaded relative to the Procfile" do
111
- FileUtils.mkdir_p "/some/app"
112
- File.open("/some/app/.env", "w") { |f| f.puts("FOO=qoo") }
113
- write_procfile "/some/app/Procfile"
114
- engine = Foreman::Engine.new("/some/app/Procfile")
115
- engine.environment.should == {"FOO"=>"qoo"}
116
- engine.start
98
+ File.open("/tmp/env", "w") { |f| f.puts("PORT=9000") }
99
+ subject.load_env "/tmp/env"
100
+ subject.send(:base_port).should == 9000
117
101
  end
118
102
  end
119
103
 
120
- describe "utf8" do
121
- before(:each) do
122
- File.open("Procfile", "w") do |file|
123
- file.puts "utf8: #{resource_path("bin/utf8")}"
124
- end
125
- end
126
-
127
- it "should spawn" do
128
- stub(subject).watch_for_output
129
- stub(subject).watch_for_termination
130
- subject.start
131
- Process.waitall
132
- mock(subject).info(/started with pid \d+/, "utf8.1", anything)
133
- mock(subject).info("\xff\x03\n", "utf8.1", anything)
134
- subject.send(:poll_readers)
135
- subject.send(:poll_readers)
136
- end
137
- end
138
104
  end
@@ -1,10 +1,11 @@
1
1
  require "spec_helper"
2
- require "foreman/export/base"
2
+ require "foreman/engine"
3
+ require "foreman/export"
3
4
 
4
- describe "Foreman::Export::Base" do
5
+ describe "Foreman::Export::Base", :fakefs do
5
6
  let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile") }
6
7
  let(:location) { "/tmp/init" }
7
- let(:engine) { Foreman::Engine.new(procfile) }
8
+ let(:engine) { Foreman::Engine.new().load_procfile(procfile) }
8
9
  let(:subject) { Foreman::Export::Base.new(location, engine) }
9
10
 
10
11
  it "has a say method for displaying info" do
@@ -12,10 +13,6 @@ describe "Foreman::Export::Base" do
12
13
  subject.send(:say, "foo")
13
14
  end
14
15
 
15
- it "export needs to be overridden" do
16
- lambda { subject.export }.should raise_error("export method must be overridden")
17
- end
18
-
19
16
  it "raises errors as a Foreman::Export::Exception" do
20
17
  lambda { subject.send(:error, "foo") }.should raise_error(Foreman::Export::Exception, "foo")
21
18
  end
@@ -4,10 +4,11 @@ require "foreman/export/bluepill"
4
4
  require "tmpdir"
5
5
 
6
6
  describe Foreman::Export::Bluepill, :fakefs do
7
- let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile") }
8
- let(:engine) { Foreman::Engine.new(procfile) }
9
- let(:options) { Hash.new }
10
- let(:bluepill) { Foreman::Export::Bluepill.new("/tmp/init", engine, options) }
7
+ let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile") }
8
+ let(:formation) { nil }
9
+ let(:engine) { Foreman::Engine.new(:formation => formation).load_procfile(procfile) }
10
+ let(:options) { Hash.new }
11
+ let(:bluepill) { Foreman::Export::Bluepill.new("/tmp/init", engine, options) }
11
12
 
12
13
  before(:each) { load_export_templates_into_fakefs("bluepill") }
13
14
  before(:each) { stub(bluepill).say }
@@ -24,8 +25,8 @@ describe Foreman::Export::Bluepill, :fakefs do
24
25
  bluepill.export
25
26
  end
26
27
 
27
- context "with concurrency" do
28
- let(:options) { Hash[:concurrency => "alpha=2"] }
28
+ context "with a process formation" do
29
+ let(:formation) { "alpha=2" }
29
30
 
30
31
  it "exports to the filesystem with concurrency" do
31
32
  bluepill.export
@@ -4,12 +4,12 @@ require "foreman/export/inittab"
4
4
  require "tmpdir"
5
5
 
6
6
  describe Foreman::Export::Inittab, :fakefs do
7
- let(:location) { "/tmp/inittab" }
8
- let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile") }
9
- let(:location) { "/tmp/inittab" }
10
- let(:engine) { Foreman::Engine.new(procfile) }
11
- let(:options) { Hash.new }
12
- let(:inittab) { Foreman::Export::Inittab.new(location, engine, options) }
7
+ let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile") }
8
+ let(:location) { "/tmp/inittab" }
9
+ let(:formation) { nil }
10
+ let(:engine) { Foreman::Engine.new(:formation => formation).load_procfile(procfile) }
11
+ let(:options) { Hash.new }
12
+ let(:inittab) { Foreman::Export::Inittab.new(location, engine, options) }
13
13
 
14
14
  before(:each) { load_export_templates_into_fakefs("inittab") }
15
15
  before(:each) { stub(inittab).say }
@@ -29,7 +29,7 @@ describe Foreman::Export::Inittab, :fakefs do
29
29
  end
30
30
 
31
31
  context "with concurrency" do
32
- let(:options) { Hash[:concurrency => "alpha=2"] }
32
+ let(:formation) { "alpha=2" }
33
33
 
34
34
  it "exports to the filesystem with concurrency" do
35
35
  inittab.export
@@ -5,20 +5,17 @@ require "tmpdir"
5
5
 
6
6
  describe Foreman::Export::Launchd, :fakefs do
7
7
  let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile") }
8
- let(:engine) { Foreman::Engine.new(procfile) }
9
8
  let(:options) { Hash.new }
10
- let(:launchd) { Foreman::Export::Launchd.new("/tmp/init", engine, options) }
9
+ let(:engine) { Foreman::Engine.new().load_procfile(procfile) }
10
+ let(:launchd) { Foreman::Export::Launchd.new("/tmp/init", engine, options) }
11
11
 
12
12
  before(:each) { load_export_templates_into_fakefs("launchd") }
13
13
  before(:each) { stub(launchd).say }
14
14
 
15
15
  it "exports to the filesystem" do
16
16
  launchd.export
17
-
18
- normalize_space(File.read("/tmp/init/app-alpha-1.plist")).should == normalize_space(example_export_file("launchd/launchd-a.default"))
19
-
20
- normalize_space(File.read("/tmp/init/app-bravo-1.plist")).should == normalize_space(example_export_file("launchd/launchd-b.default"))
21
-
17
+ File.read("/tmp/init/app-alpha-1.plist").should == example_export_file("launchd/launchd-a.default")
18
+ File.read("/tmp/init/app-bravo-1.plist").should == example_export_file("launchd/launchd-b.default")
22
19
  end
23
20
 
24
21
  end
@@ -5,33 +5,28 @@ require "tmpdir"
5
5
 
6
6
  describe Foreman::Export::Runit, :fakefs do
7
7
  let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile", 'bar=baz') }
8
- let(:engine) { Foreman::Engine.new(procfile) }
9
- let(:runit) { Foreman::Export::Runit.new('/tmp/init', engine, :concurrency => 'alpha=2,bravo=1') }
8
+ let(:engine) { Foreman::Engine.new(:formation => "alpha=2,bravo=1").load_procfile(procfile) }
9
+ let(:options) { Hash.new }
10
+ let(:runit) { Foreman::Export::Runit.new('/tmp/init', engine, options) }
10
11
 
11
12
  before(:each) { load_export_templates_into_fakefs("runit") }
12
13
  before(:each) { stub(runit).say }
13
14
  before(:each) { stub(FakeFS::FileUtils).chmod }
14
15
 
15
16
  it "exports to the filesystem" do
16
- FileUtils.mkdir_p('/tmp/init')
17
-
17
+ engine.env["BAR"] = "baz"
18
18
  runit.export
19
19
 
20
- File.read("/tmp/init/app-alpha-1/run").should == example_export_file('runit/app-alpha-1-run')
21
- File.read("/tmp/init/app-alpha-1/log/run").should ==
22
- example_export_file('runit/app-alpha-1-log-run')
20
+ File.read("/tmp/init/app-alpha-1/run").should == example_export_file('runit/app-alpha-1/run')
21
+ File.read("/tmp/init/app-alpha-1/log/run").should == example_export_file('runit/app-alpha-1/log/run')
23
22
  File.read("/tmp/init/app-alpha-1/env/PORT").should == "5000\n"
24
- File.read("/tmp/init/app-alpha-1/env/BAR").should == "baz\n"
25
-
26
- File.read("/tmp/init/app-alpha-2/run").should == example_export_file('runit/app-alpha-2-run')
27
- File.read("/tmp/init/app-alpha-2/log/run").should ==
28
- example_export_file('runit/app-alpha-2-log-run')
23
+ File.read("/tmp/init/app-alpha-1/env/BAR").should == "baz\n"
24
+ File.read("/tmp/init/app-alpha-2/run").should == example_export_file('runit/app-alpha-2/run')
25
+ File.read("/tmp/init/app-alpha-2/log/run").should == example_export_file('runit/app-alpha-2/log/run')
29
26
  File.read("/tmp/init/app-alpha-2/env/PORT").should == "5001\n"
30
- File.read("/tmp/init/app-alpha-2/env/BAR").should == "baz\n"
31
-
32
- File.read("/tmp/init/app-bravo-1/run").should == example_export_file('runit/app-bravo-1-run')
33
- File.read("/tmp/init/app-bravo-1/log/run").should ==
34
- example_export_file('runit/app-bravo-1-log-run')
27
+ File.read("/tmp/init/app-alpha-2/env/BAR").should == "baz\n"
28
+ File.read("/tmp/init/app-bravo-1/run").should == example_export_file('runit/app-bravo-1/run')
29
+ File.read("/tmp/init/app-bravo-1/log/run").should == example_export_file('runit/app-bravo-1/log/run')
35
30
  File.read("/tmp/init/app-bravo-1/env/PORT").should == "5100\n"
36
31
  end
37
32