Only run tmux specs if tmux is installed
This commit is contained in:
@@ -35,39 +35,41 @@ describe "Foreman::TmuxEngine", :fakefs do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "start" do
|
if system("which tmux")
|
||||||
before do
|
describe "start" do
|
||||||
write_procfile
|
before do
|
||||||
@pid = fork do
|
write_procfile
|
||||||
exec("tmux start-server")
|
@pid = fork do
|
||||||
end
|
exec("tmux start-server")
|
||||||
end
|
|
||||||
|
|
||||||
after do
|
|
||||||
Process.waitpid(@pid)
|
|
||||||
%x{tmux kill-session -t #{session} &> /dev/null}
|
|
||||||
end
|
|
||||||
|
|
||||||
it "creates a tmux session and attaches" do
|
|
||||||
%x{tmux has-session -t #{session} &> /dev/null}
|
|
||||||
$?.exitstatus.should == 1
|
|
||||||
|
|
||||||
mock(Kernel).exec("tmux attach-session -t #{session}")
|
|
||||||
subject.start
|
|
||||||
|
|
||||||
%x{tmux has-session -t #{session}}
|
|
||||||
$?.exitstatus.should == 0
|
|
||||||
|
|
||||||
%x{tmux list-windows -t #{session}}.split("\n").map { |window|
|
|
||||||
if window =~ /[0-9]+:\s(.+?)\s/
|
|
||||||
$1
|
|
||||||
end
|
end
|
||||||
}.should == ["alpha.1", "bravo.1", "all"]
|
end
|
||||||
sleep 1
|
|
||||||
%x{tmux kill-session -t #{session}}
|
after do
|
||||||
output = %x[cat /tmp/foreman.#{session}.log]
|
Process.waitpid(@pid)
|
||||||
output.should =~ /alpha\.1.+\.\/alpha: No such file or directory/
|
%x{tmux kill-session -t #{session} &> /dev/null}
|
||||||
output.should =~ /bravo\.1.+\.\/bravo: No such file or directory/
|
end
|
||||||
|
|
||||||
|
it "creates a tmux session and attaches" do
|
||||||
|
%x{tmux has-session -t #{session} &> /dev/null}
|
||||||
|
$?.exitstatus.should == 1
|
||||||
|
|
||||||
|
mock(Kernel).exec("tmux attach-session -t #{session}")
|
||||||
|
subject.start
|
||||||
|
|
||||||
|
%x{tmux has-session -t #{session}}
|
||||||
|
$?.exitstatus.should == 0
|
||||||
|
|
||||||
|
%x{tmux list-windows -t #{session}}.split("\n").map { |window|
|
||||||
|
if window =~ /[0-9]+:\s(.+?)\s/
|
||||||
|
$1
|
||||||
|
end
|
||||||
|
}.should == ["alpha.1", "bravo.1", "all"]
|
||||||
|
sleep 1
|
||||||
|
%x{tmux kill-session -t #{session}}
|
||||||
|
output = %x[cat /tmp/foreman.#{session}.log]
|
||||||
|
output.should =~ /alpha\.1.+\.\/alpha: No such file or directory/
|
||||||
|
output.should =~ /bravo\.1.+\.\/bravo: No such file or directory/
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user