From 68d07cd897727b20f21ef3b5fb09334a03db1b2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Re=CC=81mi=20Pre=CC=81vost?= Date: Sun, 23 Oct 2011 20:42:48 -0400 Subject: [PATCH] Add a case to check session handling --- lib/teamocil/layout.rb | 3 ++- spec/fixtures/layouts.yml | 8 ++++++++ spec/layout_spec.rb | 7 +++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/teamocil/layout.rb b/lib/teamocil/layout.rb index 276d708..b7077c4 100644 --- a/lib/teamocil/layout.rb +++ b/lib/teamocil/layout.rb @@ -44,7 +44,8 @@ module Teamocil @root = attrs["root"] @options = attrs["options"] @filters = attrs["filters"] - @splits = attrs["splits"].each_with_index.map { |split, index| Split.new(self, index, split) } + @splits = attrs["splits"] || [] + @splits = @splits.each_with_index.map { |split, index| Split.new(self, index, split) } @index = index @session = session diff --git a/spec/fixtures/layouts.yml b/spec/fixtures/layouts.yml index f70f880..c8e1f5d 100644 --- a/spec/fixtures/layouts.yml +++ b/spec/fixtures/layouts.yml @@ -33,3 +33,11 @@ two-windows-with-filters: - cmd: "echo 'foo'" - cmd: "echo 'foo again'" width: 50 + +three-windows-within-a-session: + session: + name: "my awesome session" + windows: + - name: "first window" + - name: "second window" + - name: "third window" diff --git a/spec/layout_spec.rb b/spec/layout_spec.rb index 7ad3365..3545605 100644 --- a/spec/layout_spec.rb +++ b/spec/layout_spec.rb @@ -86,6 +86,13 @@ describe Teamocil::Layout do session.windows.last.splits.first.target.should == "bottom-right" end # }}} + it "should handle windows within a session" do # {{{ + layout = Teamocil::Layout.new(layouts["three-windows-within-a-session"], {}) + session = layout.compile! + session.windows.length.should == 3 + session.name.should == "my awesome session" + end # }}} + end end