diff --git a/lib/teamocil/layout.rb b/lib/teamocil/layout.rb index eb5267d..e9a3e74 100644 --- a/lib/teamocil/layout.rb +++ b/lib/teamocil/layout.rb @@ -27,7 +27,7 @@ module Teamocil if @layout["session"].nil? windows = @layout["windows"] 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"] end diff --git a/spec/fixtures/layouts.yml b/spec/fixtures/layouts.yml index b87748f..9fe32a9 100644 --- a/spec/fixtures/layouts.yml +++ b/spec/fixtures/layouts.yml @@ -11,3 +11,27 @@ two-windows: - cmd: "echo 'bar'" - cmd: "echo 'bar again'" 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" diff --git a/spec/layout_spec.rb b/spec/layout_spec.rb index 41d44c8..ececdc8 100644 --- a/spec/layout_spec.rb +++ b/spec/layout_spec.rb @@ -3,10 +3,23 @@ require File.join(File.dirname(__FILE__), "spec_helper.rb") describe Teamocil::Layout do context "initializing" do - it "create two windows" do # {{{ + it "creates windows" do # {{{ layout = Teamocil::Layout.new(layouts["two-windows"], {}) 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