tmuxinator 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/bin/tmuxinator +1 -1
  3. data/lib/tmuxinator.rb +6 -7
  4. data/lib/tmuxinator/assets/sample.yml +13 -1
  5. data/lib/tmuxinator/assets/template-stop.erb +11 -0
  6. data/lib/tmuxinator/assets/template.erb +15 -1
  7. data/lib/tmuxinator/cli.rb +85 -15
  8. data/lib/tmuxinator/config.rb +74 -30
  9. data/lib/tmuxinator/deprecations.rb +8 -0
  10. data/lib/tmuxinator/doctor.rb +17 -0
  11. data/lib/tmuxinator/hooks.rb +14 -0
  12. data/lib/tmuxinator/hooks/project.rb +42 -0
  13. data/lib/tmuxinator/pane.rb +26 -18
  14. data/lib/tmuxinator/project.rb +113 -48
  15. data/lib/tmuxinator/version.rb +1 -1
  16. data/lib/tmuxinator/wemux_support.rb +18 -9
  17. data/lib/tmuxinator/window.rb +42 -26
  18. data/spec/fixtures/TMUXINATOR_CONFIG/TMUXINATOR_CONFIG.yml +0 -0
  19. data/spec/fixtures/dot-tmuxinator/both.yml +0 -0
  20. data/spec/fixtures/dot-tmuxinator/dup/local-dup.yml +0 -0
  21. data/spec/fixtures/dot-tmuxinator/home.yml +0 -0
  22. data/spec/fixtures/dot-tmuxinator/local-dup.yml +0 -0
  23. data/spec/fixtures/sample.yml +0 -1
  24. data/spec/fixtures/xdg-tmuxinator/both.yml +0 -0
  25. data/spec/fixtures/xdg-tmuxinator/xdg.yml +0 -0
  26. data/spec/lib/tmuxinator/cli_spec.rb +87 -13
  27. data/spec/lib/tmuxinator/config_spec.rb +163 -91
  28. data/spec/lib/tmuxinator/doctor_spec.rb +69 -0
  29. data/spec/lib/tmuxinator/hooks/project_spec.rb +63 -0
  30. data/spec/lib/tmuxinator/hooks_spec.rb +31 -0
  31. data/spec/lib/tmuxinator/pane_spec.rb +24 -1
  32. data/spec/lib/tmuxinator/project_spec.rb +58 -23
  33. data/spec/lib/tmuxinator/window_spec.rb +8 -6
  34. data/spec/spec_helper.rb +2 -1
  35. metadata +177 -7
@@ -2,39 +2,53 @@ module Tmuxinator
2
2
  class Window
3
3
  include Tmuxinator::Util
4
4
 
5
- attr_reader :name, :root, :panes, :layout, :commands, :index, :project, :synchronize
5
+ attr_reader :commands, :index, :name, :project
6
6
 
7
7
  def initialize(window_yaml, index, project)
8
- @name = if !window_yaml.keys.first.nil?
9
- window_yaml.keys.first.to_s.shellescape
10
- end
11
- @root = nil
12
- @panes = []
13
- @synchronize = false
14
- @layout = nil
15
- @pre = nil
8
+ first_key = window_yaml.keys.first
9
+
10
+ @name = first_key.to_s.shellescape unless first_key.nil?
11
+ @yaml = window_yaml.values.first
16
12
  @project = project
17
13
  @index = index
14
+ @commands = build_commands(tmux_window_command_prefix, @yaml)
15
+ end
16
+
17
+ def panes
18
+ build_panes(yaml["panes"]) || []
19
+ end
18
20
 
19
- value = window_yaml.values.first
21
+ def _hashed?
22
+ @yaml.is_a?(Hash)
23
+ end
20
24
 
21
- if value.is_a?(Hash)
22
- @synchronize = value["synchronize"] || false
23
- @layout = value["layout"] ? value["layout"].shellescape : nil
24
- @pre = value["pre"] if value["pre"]
25
- @root = if value["root"]
26
- File.expand_path(value["root"]).shellescape
27
- elsif project.root?
28
- project.root
29
- end
25
+ def yaml
26
+ _hashed? ? @yaml : {}
27
+ end
30
28
 
31
- @panes = build_panes(value["panes"])
32
- end
29
+ def layout
30
+ yaml["layout"] ? yaml["layout"].shellescape : nil
31
+ end
33
32
 
34
- @commands = build_commands(tmux_window_command_prefix, value)
33
+ def synchronize
34
+ yaml["synchronize"] || false
35
+ end
36
+
37
+ def root
38
+ _yaml_root || _project_root
39
+ end
40
+
41
+ def _yaml_root
42
+ File.expand_path(yaml["root"]).shellescape if yaml["root"]
43
+ end
44
+
45
+ def _project_root
46
+ project.root if project.root?
35
47
  end
36
48
 
37
49
  def build_panes(panes_yml)
50
+ return if panes_yml.nil?
51
+
38
52
  Array(panes_yml).map.with_index do |pane_yml, index|
39
53
  commands = case pane_yml
40
54
  when Hash
@@ -62,10 +76,12 @@ module Tmuxinator
62
76
  end
63
77
 
64
78
  def pre
65
- if @pre.is_a?(Array)
66
- @pre.join(" && ")
67
- elsif @pre.is_a?(String)
68
- @pre
79
+ _pre = yaml["pre"]
80
+
81
+ if _pre.is_a?(Array)
82
+ _pre.join(" && ")
83
+ elsif _pre.is_a?(String)
84
+ _pre
69
85
  end
70
86
  end
71
87
 
File without changes
File without changes
@@ -4,7 +4,6 @@
4
4
  name: sample
5
5
  root: ~/test
6
6
  socket_name: foo # Remove to use default socket
7
- pre: sudo /etc/rc.d/mysqld start # Runs before everything
8
7
  pre_window: rbenv shell 2.0.0-p247 # Runs in each tab and pane
9
8
  tmux_options: -f ~/.tmux.mac.conf # Pass arguments to tmux
10
9
  tmux_detached: false
File without changes
File without changes
@@ -1,4 +1,5 @@
1
1
  require "spec_helper"
2
+
2
3
  describe Tmuxinator::Cli do
3
4
  let(:cli) { Tmuxinator::Cli }
4
5
 
@@ -73,7 +74,7 @@ describe Tmuxinator::Cli do
73
74
  end
74
75
 
75
76
  it "accepts a flag for alternate name" do
76
- ARGV.replace(["start", "foo" "--name=bar"])
77
+ ARGV.replace(["start", "foo", "--name=bar"])
77
78
 
78
79
  expect(Kernel).to receive(:exec)
79
80
  capture_io { cli.start }
@@ -231,16 +232,16 @@ describe Tmuxinator::Cli do
231
232
  end
232
233
  end
233
234
 
234
- context "files exists" do
235
- let(:root_path) { "#{ENV['HOME']}\/\.tmuxinator\/#{name}\.yml" }
235
+ context "file exists" do
236
+ let(:project_path) { Tmuxinator::Config.project(name).to_s }
236
237
 
237
238
  before do
238
239
  allow(File).to receive(:exist?).with(anything).and_return(false)
239
- expect(File).to receive(:exist?).with(root_path).and_return(true)
240
+ expect(File).to receive(:exist?).with(project_path).and_return(true)
240
241
  end
241
242
 
242
243
  it "just opens the file" do
243
- expect(Kernel).to receive(:system).with(%r{#{root_path}})
244
+ expect(Kernel).to receive(:system).with(%r{#{project_path}})
244
245
  capture_io { cli.start }
245
246
  end
246
247
  end
@@ -264,7 +265,7 @@ describe Tmuxinator::Cli do
264
265
  end
265
266
  end
266
267
 
267
- context "files exists" do
268
+ context "file exists" do
268
269
  let(:path) { Tmuxinator::Config::LOCAL_DEFAULT }
269
270
  before do
270
271
  expect(File).to receive(:exist?).with(path) { true }
@@ -276,6 +277,62 @@ describe Tmuxinator::Cli do
276
277
  end
277
278
  end
278
279
  end
280
+
281
+ # this command variant only works for tmux version 1.6 and up.
282
+ context "from a session" do
283
+ context "with tmux >= 1.6", if: Tmuxinator::Config.version >= 1.6 do
284
+ before do
285
+ # Necessary to make `Doctor.installed?` work in specs
286
+ allow(Tmuxinator::Doctor).to receive(:installed?).and_return(true)
287
+ end
288
+
289
+ context "session exists" do
290
+ before(:all) do
291
+ # Can't add variables through `let` in `before :all`.
292
+ @session = "for-testing-tmuxinator"
293
+ # Pass the -d option, so that the session is not attached.
294
+ Kernel.system "tmux new-session -d -s #{@session}"
295
+ end
296
+
297
+ before do
298
+ ARGV.replace ["new", name, @session]
299
+ end
300
+
301
+ after(:all) do
302
+ puts @session
303
+ Kernel.system "tmux kill-session -t #{@session}"
304
+ end
305
+
306
+ it "creates a project file" do
307
+ capture_io { cli.start }
308
+ expect(file.string).to_not be_empty
309
+ # make sure the output is valid YAML
310
+ expect { YAML.parse file.string }.to_not raise_error
311
+ end
312
+ end
313
+
314
+ context "session doesn't exist" do
315
+ before do
316
+ ARGV.replace ["new", name, "sessiondoesnotexist"]
317
+ end
318
+
319
+ it "fails" do
320
+ expect { cli.start }.to raise_error RuntimeError
321
+ end
322
+ end
323
+ end
324
+
325
+ context "with tmux < 1.6" do
326
+ before do
327
+ ARGV.replace ["new", name, "sessionname"]
328
+ allow(Tmuxinator::Config).to receive(:version).and_return(1.5)
329
+ end
330
+
331
+ it "is unsupported" do
332
+ expect { cli.start }.to raise_error RuntimeError
333
+ end
334
+ end
335
+ end
279
336
  end
280
337
 
281
338
  describe "#copy" do
@@ -295,7 +352,7 @@ describe Tmuxinator::Cli do
295
352
  end
296
353
  end
297
354
 
298
- context "existing project doens't exist" do
355
+ context "existing project doesn't exist" do
299
356
  before do
300
357
  allow(Tmuxinator::Config).to receive(:exists?) { false }
301
358
  end
@@ -444,10 +501,27 @@ describe Tmuxinator::Cli do
444
501
  capture_io { cli.start }
445
502
  end
446
503
 
447
- it "deletes all projects" do
448
- expect(FileUtils).to receive(:remove_dir)
504
+ it "deletes the configuration directory(s)" do
505
+ allow(Tmuxinator::Config).to receive(:directories) \
506
+ { [Tmuxinator::Config.xdg, Tmuxinator::Config.home] }
507
+ expect(FileUtils).to receive(:remove_dir).once.
508
+ with(Tmuxinator::Config.xdg)
509
+ expect(FileUtils).to receive(:remove_dir).once.
510
+ with(Tmuxinator::Config.home)
511
+ expect(FileUtils).to receive(:remove_dir).never
449
512
  capture_io { cli.start }
450
513
  end
514
+
515
+ context "$TMUXINATOR_CONFIG specified" do
516
+ it "only deletes projects in that directory" do
517
+ allow(ENV).to receive(:[]).and_call_original
518
+ allow(ENV).to receive(:[]).with("TMUXINATOR_CONFIG").and_return "dir"
519
+ allow(File).to receive(:directory?).with("dir").and_return true
520
+ expect(FileUtils).to receive(:remove_dir).once.with("dir")
521
+ expect(FileUtils).to receive(:remove_dir).never
522
+ capture_io { cli.start }
523
+ end
524
+ end
451
525
  end
452
526
 
453
527
  describe "#list" do
@@ -478,9 +552,9 @@ describe Tmuxinator::Cli do
478
552
  end
479
553
 
480
554
  it "checks requirements" do
481
- expect(Tmuxinator::Config).to receive(:installed?)
482
- expect(Tmuxinator::Config).to receive(:editor?)
483
- expect(Tmuxinator::Config).to receive(:shell?)
555
+ expect(Tmuxinator::Doctor).to receive(:installed?)
556
+ expect(Tmuxinator::Doctor).to receive(:editor?)
557
+ expect(Tmuxinator::Doctor).to receive(:shell?)
484
558
  capture_io { cli.start }
485
559
  end
486
560
  end
@@ -571,7 +645,7 @@ describe Tmuxinator::Cli do
571
645
  subject { described_class.new.create_project(params) }
572
646
 
573
647
  before do
574
- allow(Tmuxinator::Config).to receive_messages(root: path)
648
+ allow(Tmuxinator::Config).to receive_messages(directory: path)
575
649
  end
576
650
 
577
651
  it_should_behave_like :a_proper_project
@@ -1,9 +1,133 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Tmuxinator::Config do
4
- describe "#root" do
5
- it "is ~/.tmuxintaor" do
6
- expect(Tmuxinator::Config.root).to eq "#{ENV['HOME']}/.tmuxinator"
4
+ let(:fixtures_dir) { File.expand_path("../../../fixtures/", __FILE__) }
5
+ let(:xdg_config_dir) { "#{fixtures_dir}/xdg-tmuxinator" }
6
+ let(:home_config_dir) { "#{fixtures_dir}/dot-tmuxinator" }
7
+
8
+ describe "#directory" do
9
+ context "environment variable $TMUXINATOR_CONFIG non-blank" do
10
+ it "is $TMUXINATOR_CONFIG" do
11
+ allow(ENV).to receive(:[]).with("TMUXINATOR_CONFIG").
12
+ and_return "expected"
13
+ allow(File).to receive(:directory?).and_return true
14
+ expect(Tmuxinator::Config.directory).to eq "expected"
15
+ end
16
+ end
17
+
18
+ context "only ~/.tmuxinator exists" do
19
+ it "is ~/.tmuxinator" do
20
+ allow(File).to receive(:directory?).
21
+ with(Tmuxinator::Config.environment).and_return false
22
+ allow(File).to receive(:directory?).
23
+ with(Tmuxinator::Config.xdg).and_return false
24
+ allow(File).to receive(:directory?).
25
+ with(Tmuxinator::Config.home).and_return true
26
+ expect(Tmuxinator::Config.directory).to eq Tmuxinator::Config.home
27
+ end
28
+ end
29
+
30
+ context "only $XDG_CONFIG_HOME/tmuxinator exists" do
31
+ it "is #xdg" do
32
+ allow(File).to receive(:directory?).
33
+ with(Tmuxinator::Config.environment).and_return false
34
+ allow(File).to receive(:directory?).
35
+ with(Tmuxinator::Config.xdg).and_return true
36
+ allow(File).to receive(:directory?).
37
+ with(Tmuxinator::Config.home).and_return false
38
+ expect(Tmuxinator::Config.directory).to eq Tmuxinator::Config.xdg
39
+ end
40
+ end
41
+
42
+ context "both $XDG_CONFIG_HOME/tmuxinator and ~/.tmuxinator exist" do
43
+ it "is #xdg" do
44
+ allow(File).to receive(:directory?).
45
+ with(Tmuxinator::Config.environment).and_return false
46
+ allow(File).to receive(:directory?).
47
+ with(Tmuxinator::Config.xdg).and_return true
48
+ allow(File).to receive(:directory?).
49
+ with(Tmuxinator::Config.home).and_return true
50
+ expect(Tmuxinator::Config.directory).to eq Tmuxinator::Config.xdg
51
+ end
52
+ end
53
+
54
+ context "parent directory(s) do not exist" do
55
+ it "creates parent directories if required" do
56
+ allow(File).to receive(:directory?).and_call_original
57
+ allow(File).to receive(:directory?).with(Tmuxinator::Config.home).
58
+ and_return false
59
+ Dir.mktmpdir do |dir|
60
+ config_parent = "#{dir}/non_existant_parent/s"
61
+ allow(XDG).to receive(:[]).with("CONFIG").and_return config_parent
62
+ expect(Tmuxinator::Config.directory).
63
+ to eq "#{config_parent}/tmuxinator"
64
+ expect(File.directory?("#{config_parent}/tmuxinator")).to be true
65
+ end
66
+ end
67
+ end
68
+ end
69
+
70
+ describe "#enviroment" do
71
+ context "environment variable $TMUXINATOR_CONFIG is not empty" do
72
+ it "is $TMUXINATOR_CONFIG" do
73
+ allow(ENV).to receive(:[]).with("TMUXINATOR_CONFIG").
74
+ and_return "expected"
75
+ # allow(XDG).to receive(:[]).with("CONFIG").and_return "expected"
76
+ allow(File).to receive(:directory?).and_return true
77
+ expect(Tmuxinator::Config.environment).to eq "expected"
78
+ end
79
+ end
80
+
81
+ context "environment variable $TMUXINATOR_CONFIG is nil" do
82
+ it "is an empty string" do
83
+ allow(ENV).to receive(:[]).with("TMUXINATOR_CONFIG").
84
+ and_return nil
85
+ # allow(XDG).to receive(:[]).with("CONFIG").and_return nil
86
+ allow(File).to receive(:directory?).and_return true
87
+ expect(Tmuxinator::Config.environment).to eq ""
88
+ end
89
+ end
90
+
91
+ context "environment variable $TMUXINATOR_CONFIG is set and empty" do
92
+ it "is an empty string" do
93
+ allow(XDG).to receive(:[]).with("CONFIG").and_return ""
94
+ expect(Tmuxinator::Config.environment).to eq ""
95
+ end
96
+ end
97
+ end
98
+
99
+ describe "#directories" do
100
+ it "is empty if no configuration directories exist" do
101
+ allow(File).to receive(:directory?).and_return false
102
+ expect(Tmuxinator::Config.directories).to eq []
103
+ end
104
+
105
+ it "is only [$TMUXINATOR_CONFIG] if set" do
106
+ allow(ENV).to receive(:[]).with("TMUXINATOR_CONFIG").
107
+ and_return "expected"
108
+ allow(File).to receive(:directory?).and_return true
109
+ expect(Tmuxinator::Config.directories).to eq ["expected"]
110
+ end
111
+
112
+ it "contains #xdg before #home" do
113
+ allow(File).to receive(:directory?).with(Tmuxinator::Config.xdg).
114
+ and_return true
115
+ allow(File).to receive(:directory?).with(Tmuxinator::Config.home).
116
+ and_return true
117
+ expect(Tmuxinator::Config.directories).to eq \
118
+ [Tmuxinator::Config.xdg, Tmuxinator::Config.home]
119
+ end
120
+ end
121
+
122
+ describe "#home" do
123
+ it "is ~/.tmuxinator" do
124
+ expect(Tmuxinator::Config.home).to eq "#{ENV['HOME']}/.tmuxinator"
125
+ end
126
+ end
127
+
128
+ describe "#xdg" do
129
+ it "is $XDG_CONFIG_HOME/tmuxinator" do
130
+ expect(Tmuxinator::Config.xdg).to eq "#{XDG['CONFIG_HOME']}/tmuxinator"
7
131
  end
8
132
  end
9
133
 
@@ -42,7 +166,7 @@ describe Tmuxinator::Config do
42
166
  end
43
167
 
44
168
  describe "#default?" do
45
- let(:root) { Tmuxinator::Config.root }
169
+ let(:directory) { Tmuxinator::Config.directory }
46
170
  let(:local_default) { Tmuxinator::Config::LOCAL_DEFAULT }
47
171
  let(:proj_default) { Tmuxinator::Config.default }
48
172
 
@@ -71,77 +195,19 @@ describe Tmuxinator::Config do
71
195
 
72
196
  describe "#configs" do
73
197
  before do
74
- allow(Dir).to receive_messages(:[] => ["test.yml"])
75
- end
76
-
77
- it "gets a list of all projects" do
78
- expect(Tmuxinator::Config.configs).to include("test")
79
- end
80
- end
81
-
82
- describe "#installed?" do
83
- context "tmux is installed" do
84
- before do
85
- allow(Kernel).to receive(:system) { true }
86
- end
87
-
88
- it "returns true" do
89
- expect(Tmuxinator::Config.installed?).to be_truthy
90
- end
91
- end
92
-
93
- context "tmux is not installed" do
94
- before do
95
- allow(Kernel).to receive(:system) { false }
96
- end
97
-
98
- it "returns true" do
99
- expect(Tmuxinator::Config.installed?).to be_falsey
100
- end
101
- end
102
- end
103
-
104
- describe "#editor?" do
105
- context "$EDITOR is set" do
106
- before do
107
- allow(ENV).to receive(:[]).with("EDITOR") { "vim" }
108
- end
109
-
110
- it "returns true" do
111
- expect(Tmuxinator::Config.editor?).to be_truthy
112
- end
113
- end
114
-
115
- context "$EDITOR is not set" do
116
- before do
117
- allow(ENV).to receive(:[]).with("EDITOR") { nil }
118
- end
119
-
120
- it "returns false" do
121
- expect(Tmuxinator::Config.editor?).to be_falsey
122
- end
198
+ allow(Tmuxinator::Config).to receive_messages(xdg: xdg_config_dir)
199
+ allow(Tmuxinator::Config).to receive_messages(home: home_config_dir)
123
200
  end
124
- end
125
-
126
- describe "#shell?" do
127
- context "$SHELL is set" do
128
- before do
129
- allow(ENV).to receive(:[]).with("SHELL") { "vim" }
130
- end
131
201
 
132
- it "returns true" do
133
- expect(Tmuxinator::Config.shell?).to be_truthy
134
- end
202
+ it "gets a sorted list of all projects" do
203
+ expect(Tmuxinator::Config.configs).
204
+ to eq ["both", "both", "dup/local-dup", "home", "local-dup", "xdg"]
135
205
  end
136
206
 
137
- context "$SHELL is not set" do
138
- before do
139
- allow(ENV).to receive(:[]).with("SHELL") { nil }
140
- end
141
-
142
- it "returns false" do
143
- expect(Tmuxinator::Config.shell?).to be_falsey
144
- end
207
+ it "lists only projects in $TMUXINATOR_CONFIG when set" do
208
+ allow(ENV).to receive(:[]).with("TMUXINATOR_CONFIG").
209
+ and_return "#{fixtures_dir}/TMUXINATOR_CONFIG"
210
+ expect(Tmuxinator::Config.configs).to eq ["TMUXINATOR_CONFIG"]
145
211
  end
146
212
  end
147
213
 
@@ -156,24 +222,31 @@ describe Tmuxinator::Config do
156
222
  end
157
223
  end
158
224
 
159
- describe "#project_in_root" do
160
- let(:root) { Tmuxinator::Config.root }
161
- let(:base) { "#{root}/sample.yml" }
225
+ describe "#global_project" do
226
+ let(:directory) { Tmuxinator::Config.directory }
227
+ let(:base) { "#{directory}/sample.yml" }
228
+ let(:first_dup) { "#{home_config_dir}/dup/local-dup.yml" }
162
229
 
163
230
  before do
164
- path = File.expand_path("../../../fixtures/", __FILE__)
165
- allow(Tmuxinator::Config).to receive_messages(root: path)
231
+ allow(Tmuxinator::Config).to receive_messages(xdg: fixtures_dir)
232
+ allow(Tmuxinator::Config).to receive_messages(home: fixtures_dir)
166
233
  end
167
234
 
168
235
  context "with project yml" do
169
236
  it "gets the project as path to the yml file" do
170
- expect(Tmuxinator::Config.project_in_root("sample")).to eq base
237
+ expect(Tmuxinator::Config.global_project("sample")).to eq base
171
238
  end
172
239
  end
173
240
 
174
241
  context "without project yml" do
175
242
  it "gets the project as path to the yml file" do
176
- expect(Tmuxinator::Config.project_in_root("new-project")).to be_nil
243
+ expect(Tmuxinator::Config.global_project("new-project")).to be_nil
244
+ end
245
+ end
246
+
247
+ context "with duplicate project files" do
248
+ it "is the first .yml file found" do
249
+ expect(Tmuxinator::Config.global_project("local-dup")).to eq first_dup
177
250
  end
178
251
  end
179
252
  end
@@ -186,39 +259,39 @@ describe Tmuxinator::Config do
186
259
  end
187
260
  end
188
261
 
189
- describe "#project_in_local" do
262
+ describe "#local_project" do
190
263
  let(:default) { Tmuxinator::Config::LOCAL_DEFAULT }
191
264
 
192
265
  context "with a project yml" do
193
266
  it "gets the project as path to the yml file" do
194
267
  expect(File).to receive(:exist?).with(default) { true }
195
- expect(Tmuxinator::Config.project_in_local).to eq default
268
+ expect(Tmuxinator::Config.local_project).to eq default
196
269
  end
197
270
  end
198
271
 
199
272
  context "without project yml" do
200
273
  it "gets the project as path to the yml file" do
201
- expect(Tmuxinator::Config.project_in_local).to be_nil
274
+ expect(Tmuxinator::Config.local_project).to be_nil
202
275
  end
203
276
  end
204
277
  end
205
278
 
206
279
  describe "#project" do
207
- let(:root) { Tmuxinator::Config.root }
208
- let(:path) { File.expand_path("../../../fixtures/", __FILE__) }
280
+ let(:directory) { Tmuxinator::Config.directory }
209
281
  let(:default) { Tmuxinator::Config::LOCAL_DEFAULT }
210
282
 
211
- context "with project yml in the root directory" do
283
+ context "with an non-local project yml" do
212
284
  before do
213
- allow(Tmuxinator::Config).to receive_messages(root: path)
285
+ allow(Tmuxinator::Config).to receive_messages(directory: fixtures_dir)
214
286
  end
215
287
 
216
288
  it "gets the project as path to the yml file" do
217
- expect(Tmuxinator::Config.project("sample")).to eq "#{root}/sample.yml"
289
+ expect(Tmuxinator::Config.project("sample")).
290
+ to eq "#{directory}/sample.yml"
218
291
  end
219
292
  end
220
293
 
221
- context "with a local project, but no project in root" do
294
+ context "with a local project, but no global project" do
222
295
  it "gets the project as path to the yml file" do
223
296
  expect(File).to receive(:exist?).with(default) { true }
224
297
  expect(Tmuxinator::Config.project("sample")).to eq "./.tmuxinator.yml"
@@ -226,7 +299,7 @@ describe Tmuxinator::Config do
226
299
  end
227
300
 
228
301
  context "without project yml" do
229
- let(:expected) { "#{root}/new-project.yml" }
302
+ let(:expected) { "#{directory}/new-project.yml" }
230
303
  it "gets the project as path to the yml file" do
231
304
  expect(Tmuxinator::Config.project("new-project")).to eq expected
232
305
  end
@@ -234,7 +307,6 @@ describe Tmuxinator::Config do
234
307
  end
235
308
 
236
309
  describe "#validate" do
237
- let(:path) { File.expand_path("../../../fixtures", __FILE__) }
238
310
  let(:default) { Tmuxinator::Config::LOCAL_DEFAULT }
239
311
 
240
312
  context "when a project name is provided" do
@@ -245,7 +317,7 @@ describe Tmuxinator::Config do
245
317
  end
246
318
 
247
319
  it "should load and validate the project" do
248
- expect(Tmuxinator::Config).to receive_messages(root: path)
320
+ expect(Tmuxinator::Config).to receive_messages(directory: fixtures_dir)
249
321
  expect(Tmuxinator::Config.validate(name: "sample")).to \
250
322
  be_a Tmuxinator::Project
251
323
  end
@@ -260,7 +332,7 @@ describe Tmuxinator::Config do
260
332
  end
261
333
 
262
334
  it "should load and validate the project" do
263
- content = File.read(File.join(path, "sample.yml"))
335
+ content = File.read(File.join(fixtures_dir, "sample.yml"))
264
336
 
265
337
  expect(File).to receive(:exist?).with(default).at_least(:once) { true }
266
338
  expect(File).to receive(:read).with(default).and_return(content)