Use Correct Project Config File Path When Generating Config File

* 440-fix-config-file-path-in-project-config - use full project config file path when generating project config file

* MISC - refactor "should always generate a project file" spec -- use Dir.mktmpdir

* 440-fix-config-file-path-in-project-config - update CHANGELOG.md

Closes #440.
This commit is contained in:
Pete Doherty
2018-05-26 13:24:22 -04:00
committed by GitHub
parent 0bf56f9381
commit 84b47360b2
3 changed files with 20 additions and 14 deletions

View File

@@ -1,4 +1,5 @@
## Unreleased
- use correct paths in generated config file comment (#440)
- fix "wrong namespace" RuboCop warnings (#620)
## 0.11.2

View File

@@ -1,4 +1,4 @@
# ~/.tmuxinator/<%= name %>.yml
# <%= path %>
name: <%= name %>
root: ~/

View File

@@ -638,21 +638,26 @@ describe Tmuxinator::Cli do
end
describe "#generate_project_file" do
let(:name) { "foobar" }
let(:path) { Tmuxinator::Config.default_project(name) }
before do
expect(File).not_to exist(path), "expected file at #{path} not to exist"
end
after(:each) do
FileUtils.remove_file(path) if File.exist?(path)
end
let(:name) { "foobar-#{Time.now.to_i}" }
it "should always generate a project file" do
new_path = Tmuxinator::Cli.new.generate_project_file(name, path)
expect(new_path).to eq path
expect(File).to exist new_path
Dir.mktmpdir do |dir|
path = "#{dir}/#{name}.yml"
expect(File).not_to exist(path), "expected file at #{path} not to exist"
new_path = Tmuxinator::Cli.new.generate_project_file(name, path)
expect(new_path).to eq path
expect(File).to exist new_path
end
end
it "should generate a project file using the correct project file path" do
file = StringIO.new
allow(File).to receive(:open) { |&block| block.yield file }
Dir.mktmpdir do |dir|
path = "#{dir}/#{name}.yml"
_ = Tmuxinator::Cli.new.generate_project_file(name, path)
expect(file.string).to match %r{\A# #{path}$}
end
end
end