Improve specs

This commit is contained in:
Rémi Prévost 2011-10-23 17:43:48 -04:00
parent fb9822064e
commit a424684c5a
3 changed files with 40 additions and 3 deletions

View File

@ -27,7 +27,7 @@ module Teamocil
if @layout["session"].nil? if @layout["session"].nil?
windows = @layout["windows"] windows = @layout["windows"]
else else
output << "tmux rename-session #{@layout["session"]["name"]}" if @layout["session"]["name"] output << "tmux rename-session \"#{@layout["session"]["name"]}\"" if @layout["session"]["name"]
windows = @layout["session"]["windows"] windows = @layout["session"]["windows"]
end end

View File

@ -11,3 +11,27 @@ two-windows:
- cmd: "echo 'bar'" - cmd: "echo 'bar'"
- cmd: "echo 'bar again'" - cmd: "echo 'bar again'"
width: 50 width: 50
# Simple two windows layout in session
two-windows-in-a-session:
session:
name: my-new-session
windows:
- name: "foo"
splits:
- cmd: "echo 'foo'"
- cmd: "echo 'foo again'"
width: 50
- name: "bar"
splits:
- cmd: "echo 'bar'"
- cmd: "echo 'bar again'"
width: 50
four-splits:
windows:
- name: "foo"
splits:
- cmd: "echo 1"
- cmd: "echo 2"
- cmd: "echo 3"
- cmd: "echo 4"

View File

@ -3,10 +3,23 @@ require File.join(File.dirname(__FILE__), "spec_helper.rb")
describe Teamocil::Layout do describe Teamocil::Layout do
context "initializing" do context "initializing" do
it "create two windows" do # {{{ it "creates windows" do # {{{
layout = Teamocil::Layout.new(layouts["two-windows"], {}) layout = Teamocil::Layout.new(layouts["two-windows"], {})
commands = layout.generate_commands commands = layout.generate_commands
commands.grep(/new-window/).length.should be 2 commands.grep(/new-window/).length.should == 2
end # }}}
it "renames the current session" do # {{{
layout = Teamocil::Layout.new(layouts["two-windows-in-a-session"], {})
commands = layout.generate_commands
commands.grep(/rename-session/).first.should == "tmux rename-session \"my-new-session\""
commands.grep(/new-window/).length.should == 2
end # }}}
it "creates splits" do # {{{
layout = Teamocil::Layout.new(layouts["four-splits"], {})
commands = layout.generate_commands
commands.grep(/split-window/).length.should == 3
end # }}} end # }}}
end end