pulsar 0.3.4 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.hound.yml +3 -0
  3. data/.rubocop.yml +5 -0
  4. data/.ruby-version +1 -1
  5. data/.travis.yml +4 -1
  6. data/README.md +4 -4
  7. data/Rakefile +3 -3
  8. data/lib/pulsar.rb +9 -8
  9. data/lib/pulsar/commands/all.rb +4 -4
  10. data/lib/pulsar/commands/init.rb +7 -5
  11. data/lib/pulsar/commands/main.rb +43 -32
  12. data/lib/pulsar/commands/utils.rb +7 -3
  13. data/lib/pulsar/generators/init_repo/apps/your_app/defaults.rb +1 -1
  14. data/lib/pulsar/generators/init_repo/apps/your_app/production.rb +2 -2
  15. data/lib/pulsar/generators/init_repo/apps/your_app/staging.rb +2 -2
  16. data/lib/pulsar/generators/init_repo/recipes/generic/cleanup.rb +9 -9
  17. data/lib/pulsar/generators/init_repo/recipes/generic/utils.rb +6 -3
  18. data/lib/pulsar/helpers/all.rb +7 -5
  19. data/lib/pulsar/helpers/capistrano.rb +4 -4
  20. data/lib/pulsar/helpers/clamp.rb +32 -33
  21. data/lib/pulsar/helpers/path.rb +15 -2
  22. data/lib/pulsar/helpers/shell.rb +3 -3
  23. data/lib/pulsar/options/all.rb +5 -3
  24. data/lib/pulsar/options/conf_repo.rb +17 -16
  25. data/lib/pulsar/options/shared.rb +3 -2
  26. data/lib/pulsar/version.rb +1 -1
  27. data/pulsar.gemspec +17 -17
  28. data/spec/pulsar/commands/init_spec.rb +4 -3
  29. data/spec/pulsar/commands/list_spec.rb +63 -47
  30. data/spec/pulsar/commands/main_spec.rb +175 -125
  31. data/spec/pulsar/commands/utils_spec.rb +13 -13
  32. data/spec/pulsar/helpers/capistrano_spec.rb +37 -31
  33. data/spec/pulsar/helpers/clamp_spec.rb +68 -37
  34. data/spec/pulsar/helpers/shell_spec.rb +3 -3
  35. data/spec/spec_helper.rb +12 -11
  36. data/spec/support/dummies/dummy_conf/Gemfile +1 -1
  37. data/spec/support/dummies/dummy_conf/apps/base.rb +5 -5
  38. data/spec/support/dummies/dummy_conf/apps/dummy_app/custom_stage.rb +2 -2
  39. data/spec/support/dummies/dummy_conf/apps/dummy_app/defaults.rb +1 -1
  40. data/spec/support/dummies/dummy_conf/apps/dummy_app/production.rb +2 -2
  41. data/spec/support/dummies/dummy_conf/apps/dummy_app/staging.rb +2 -2
  42. data/spec/support/dummies/dummy_conf/apps/other_dummy_app/custom_stage.rb +2 -2
  43. data/spec/support/dummies/dummy_conf/apps/other_dummy_app/defaults.rb +1 -1
  44. data/spec/support/dummies/dummy_conf/apps/other_dummy_app/production.rb +2 -2
  45. data/spec/support/dummies/dummy_conf/apps/other_dummy_app/staging.rb +2 -2
  46. data/spec/support/modules/helpers.rb +40 -35
  47. metadata +20 -17
@@ -2,11 +2,11 @@ module Pulsar
2
2
  module Helpers
3
3
  module Path
4
4
  def capfile_path
5
- "#{tmp_dir}/capfile-#{deploy_time}"
5
+ "#{tmp_path}/capfile-#{deploy_time}"
6
6
  end
7
7
 
8
8
  def config_path
9
- "#{tmp_dir}/conf-repo-#{setup_time}"
9
+ "#{tmp_path}/conf-repo-#{setup_time}"
10
10
  end
11
11
 
12
12
  def config_app_path(app)
@@ -41,7 +41,20 @@ module Pulsar
41
41
  clear_deploy_time
42
42
  end
43
43
 
44
+ def home_path
45
+ home_dir
46
+ end
47
+
48
+ def bundle_path
49
+ File.join(home_path, 'bundle')
50
+ end
51
+
52
+ def tmp_path
53
+ File.join(home_path, 'tmp')
54
+ end
55
+
44
56
  private
57
+
45
58
  def clear_deploy_time
46
59
  @deploy = nil
47
60
  end
@@ -1,11 +1,11 @@
1
- require "fileutils"
1
+ require 'fileutils'
2
2
 
3
3
  module Pulsar
4
4
  module Helpers
5
5
  module Shell
6
6
  include FileUtils
7
7
 
8
- def cd(path, opts, &block)
8
+ def cd(path, opts)
9
9
  puts "Directory: #{path.white}".yellow if opts[:verbose]
10
10
  FileUtils.cd(path) { yield }
11
11
  end
@@ -19,7 +19,7 @@ module Pulsar
19
19
  puts "Command: #{cmd.white}".yellow if opts[:verbose]
20
20
  system(cmd)
21
21
 
22
- raise "Command #{cmd} Failed" if $? != 0
22
+ fail "Command #{cmd} Failed" if $? != 0
23
23
  end
24
24
 
25
25
  def touch(file, opts)
@@ -1,4 +1,6 @@
1
- module Pulsar::Options
2
- autoload :ConfRepo, "pulsar/options/conf_repo"
3
- autoload :Shared, "pulsar/options/shared"
1
+ module Pulsar
2
+ module Options
3
+ autoload :ConfRepo, 'pulsar/options/conf_repo'
4
+ autoload :Shared, 'pulsar/options/shared'
5
+ end
4
6
  end
@@ -2,26 +2,27 @@ module Pulsar
2
2
  module Options
3
3
  module ConfRepo
4
4
  def self.included(base)
5
- base.option [ "-c", "--conf-repo" ], "REPO URL",
6
- "a git repository with deploy configurations, mainly apps and recipes",
7
- :environment_variable => "PULSAR_CONF_REPO",
8
- :required => true
5
+ base.option ['-c', '--conf-repo'], 'REPO URL',
6
+ 'a git repository with deploy configurations, mainly apps and recipes',
7
+ environment_variable: 'PULSAR_CONF_REPO',
8
+ required: true
9
9
 
10
- base.option [ "-k", "--keep-capfile" ], :flag,
11
- "don't remove the generated capfile in the TMP DIR directory",
12
- :default => false
10
+ base.option ['-k', '--keep-capfile'], :flag,
11
+ 'don\'t remove the generated capfile in the TMP DIR directory',
12
+ default: false
13
13
 
14
- base.option [ "-r", "--keep-repo" ], :flag,
15
- "don't remove the downloaded configuration repository from the TMP DIR directory",
16
- :default => false
14
+ base.option ['-r', '--keep-repo'], :flag,
15
+ 'don\'t remove the downloaded configuration repository from the TMP DIR directory',
16
+ default: false
17
17
 
18
- base.option [ "-b", "--conf-branch" ], "REPO BRANCH",
19
- "specify a branch for the configuration repository",
20
- :default => "master"
18
+ base.option ['-b', '--conf-branch'], 'REPO BRANCH',
19
+ 'specify a branch for the configuration repository',
20
+ default: 'master'
21
21
 
22
- base.option [ "-d", "--tmp-dir" ], "TMP DIR",
23
- "a directory where to put the configuration repo to build capfile with",
24
- :default => "/tmp/pulsar"
22
+ base.option ['-h', '--home-dir'], 'HOME DIR',
23
+ 'a directory to store per-user state',
24
+ environment_variable: 'PULSAR_HOME',
25
+ default: File.join(Dir.home, '.pulsar')
25
26
  end
26
27
 
27
28
  #
@@ -2,12 +2,13 @@ module Pulsar
2
2
  module Options
3
3
  module Shared
4
4
  def self.included(base)
5
- base.option [ "-V", "--version" ], :flag, "print out pulsar version" do
5
+ base.option ['-V', '--version'], :flag, 'print out pulsar version' do
6
6
  puts(VERSION)
7
7
  exit(0)
8
8
  end
9
9
 
10
- base.option [ "-v", "--verbose" ], :flag, "print out what pulsar is doing", :default => false
10
+ base.option ['-v', '--verbose'], :flag,
11
+ 'print out what pulsar is doing', default: false
11
12
  end
12
13
  end
13
14
  end
@@ -1,3 +1,3 @@
1
1
  module Pulsar
2
- VERSION = "0.3.4"
2
+ VERSION = '0.3.5'
3
3
  end
data/pulsar.gemspec CHANGED
@@ -4,29 +4,29 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'pulsar/version'
5
5
 
6
6
  Gem::Specification.new do |gem|
7
- gem.name = "pulsar"
7
+ gem.name = 'pulsar'
8
8
  gem.version = Pulsar::VERSION
9
- gem.authors = ["Alberto Vena", "Matteo Latini"]
10
- gem.email = ["info@nebulab.it"]
11
- gem.description = %q{Manage your Capistrano deployments with ease}
12
- gem.summary = %q{
9
+ gem.authors = ['Alberto Vena', 'Matteo Latini']
10
+ gem.email = ['info@nebulab.it']
11
+ gem.homepage = 'http://pulsar.nebulab.it'
12
+ gem.description = 'Manage your Capistrano deployments with ease'
13
+ gem.summary = '
13
14
  Pulsar helps with Capistrano configuration management. It uses a repository
14
15
  to store all your precious configurations and recipes to build Capistrano
15
16
  deploys on it.
16
- }
17
- gem.homepage = "http://pulsar.nebulab.it"
17
+ '
18
18
 
19
19
  gem.files = `git ls-files`.split($/)
20
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
21
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
22
- gem.require_paths = ["lib"]
20
+ gem.executables = gem.files.grep(/^bin\//).map { |f| File.basename(f) }
21
+ gem.test_files = gem.files.grep(/^(test|spec|features)\//)
22
+ gem.require_paths = ['lib']
23
23
 
24
- gem.add_dependency "clamp", "~> 0.5"
25
- gem.add_dependency "bundler", "~> 1.2"
26
- gem.add_dependency "colored", "~> 1.2"
24
+ gem.add_dependency 'clamp', '~> 0.5'
25
+ gem.add_dependency 'bundler', '~> 1.2'
26
+ gem.add_dependency 'colored', '~> 1.2'
27
27
 
28
- gem.add_development_dependency "rake", "10.0.4"
29
- gem.add_development_dependency "rspec", "2.12.0"
30
- gem.add_development_dependency "rr", "1.0.4"
31
- gem.add_development_dependency "coveralls", "0.6.3"
28
+ gem.add_development_dependency 'rake', '10.3.2'
29
+ gem.add_development_dependency 'rspec', '3.1.0'
30
+ gem.add_development_dependency 'codeclimate-test-reporter', '~> 0.4.6'
31
+ gem.add_development_dependency 'rubocop', '~> 0.29.1'
32
32
  end
@@ -1,9 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Pulsar::InitCommand do
4
- let(:pulsar) { Pulsar::InitCommand.new("init") }
4
+ let(:pulsar) { Pulsar::InitCommand.new('init') }
5
5
 
6
- it "copies over the configuration repo" do
7
- expect { pulsar.run(["#{tmp_path}/new-conf-repo"]) }.to change{ Dir.glob("#{tmp_path}/new-conf-repo").length }.by(1)
6
+ it 'copies over the configuration repo' do
7
+ expect { pulsar.run(["#{spec_tmp_path}/new-conf-repo"]) }
8
+ .to change { Dir.glob("#{spec_tmp_path}/new-conf-repo").length }.by(1)
8
9
  end
9
10
  end
@@ -1,74 +1,86 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Pulsar::ListCommand do
4
- let(:pulsar) { Pulsar::ListCommand.new("list") }
4
+ let(:pulsar) { Pulsar::ListCommand.new('list') }
5
5
 
6
- it "copies a the repo over to temp directory" do
7
- expect { pulsar.run(full_list_args + %w(--keep-repo)) }.to change{ Dir.glob("#{tmp_path}/conf-repo*").length }.by(1)
6
+ it 'copies a the repo over to temp directory' do
7
+ expect { pulsar.run(full_list_args + %w(--keep-repo)) }
8
+ .to change { Dir.glob("#{spec_tmp_path}/tmp/conf-repo*").length }.by(1)
8
9
  end
9
10
 
10
- it "copies a the repo when there is a dir with same name" do
11
- system("mkdir #{tmp_path}/conf-repo")
12
- expect { pulsar.run(full_list_args + %w(--keep-repo)) }.to change{ Dir.glob("#{tmp_path}/conf-repo*").length }.by(1)
11
+ it 'copies a the repo when there is a dir with same name' do
12
+ system("mkdir -p #{spec_tmp_path}/conf-repo")
13
+
14
+ expect { pulsar.run(full_list_args + %w(--keep-repo)) }
15
+ .to change { Dir.glob("#{spec_tmp_path}/tmp/conf-repo*").length }.by(1)
13
16
  end
14
17
 
15
- it "removes the temp directory even if it's raised an error" do
16
- Pulsar::ListCommand.any_instance.stub(:list_apps) { raise 'error' }
17
- pulsar.run(full_list_args) rescue nil
18
+ it 'removes the temp directory even if it\'s raised an error' do
19
+ allow_any_instance_of(Pulsar::ListCommand)
20
+ .to receive(:list_apps) { fail('error') }
18
21
 
19
- Dir.glob("#{tmp_path}/conf-repo*").should be_empty
22
+ begin
23
+ pulsar.run(full_list_args)
24
+ rescue
25
+ nil
26
+ end
27
+
28
+ expect(Dir.glob("#{spec_tmp_path}/tmp/conf-repo*")).to be_empty
20
29
  end
21
30
 
22
- it "lists configured apps and stages" do
23
- app_one = Regexp.escape("dummy_app".cyan)
24
- app_two = Regexp.escape("other_dummy_app".cyan)
31
+ it 'lists configured apps and stages' do
32
+ app_one = Regexp.escape('dummy_app'.cyan)
33
+ app_two = Regexp.escape('other_dummy_app'.cyan)
25
34
 
26
- stages = [ "custom_stage".magenta, "production".magenta, "staging".magenta ]
35
+ stages = ['custom_stage'.magenta, 'production'.magenta, 'staging'.magenta]
27
36
  escaped_stages = Regexp.escape(stages.join(', '))
28
37
 
29
38
  pulsar.run(full_list_args)
30
39
 
31
- stdout.should match(/#{app_one}: #{escaped_stages}/)
32
- stdout.should match(/#{app_two}: #{escaped_stages}/)
40
+ expect(stdout).to match(/#{app_one}: #{escaped_stages}/)
41
+ expect(stdout).to match(/#{app_two}: #{escaped_stages}/)
33
42
  end
34
43
 
35
- context "dotfile options" do
36
- it "reads configuration variables from .pulsar file in home" do
37
- stub_dotfile(Dir.home, dummy_dotfile_options)
44
+ context 'dotfile options' do
45
+ it 'reads configuration variables from config file in home' do
46
+ stub_config(File.join(pulsar.home_path, 'config'), dummy_dotfile_options)
38
47
 
39
48
  pulsar.run(full_list_args)
40
49
 
41
- ENV.to_hash.should include(dummy_dotfile_options)
50
+ expect(ENV.to_hash).to include(dummy_dotfile_options)
42
51
  end
43
52
 
44
- it "reads configuration variables from .pulsar file in rack app directory" do
45
- stub_dotfile(dummy_rack_app_path, dummy_dotfile_options)
53
+ it 'reads configurations from .pulsar file in rack app directory' do
54
+ stub_config(File.join(dummy_app_path, '.pulsar'), dummy_dotfile_options)
46
55
 
47
- FileUtils.cd(dummy_rack_app_path) do
56
+ FileUtils.cd(dummy_app_path) do
48
57
  reload_main_command
49
58
 
50
59
  pulsar.run(full_list_args)
51
60
  end
52
61
 
53
- ENV.to_hash.should include(dummy_dotfile_options)
62
+ expect(ENV.to_hash).to include(dummy_dotfile_options)
54
63
  end
55
64
 
56
- it "skips lines which cannot parse when reading .pulsar file" do
57
- stub_dotfile(dummy_rack_app_path, [ "wrong_line", "# comment" ])
65
+ it 'skips lines which cannot parse when reading .pulsar file' do
66
+ stub_config(
67
+ File.join(dummy_app_path, '.pulsar'), ['wrong_line', '# comment'])
58
68
 
59
- FileUtils.cd(dummy_rack_app_path) do
69
+ FileUtils.cd(dummy_app_path) do
60
70
  reload_main_command
61
71
 
62
72
  expect { pulsar.run(full_list_args) }.not_to raise_error
63
73
  end
64
74
  end
65
75
 
66
- it "falls back to .pulsar file in home directory if it's not in the rack app directory" do
67
- stub_dotfile(Dir.home, dummy_dotfile_options)
76
+ it 'falls back to default config file if it\'s not in the app directory' do
77
+ stub_config(File.join(pulsar.home_path, 'config'), dummy_dotfile_options)
68
78
 
69
- File.stub(:file?).with("#{File.expand_path(dummy_rack_app_path)}/.pulsar").and_return(false)
79
+ allow(File)
80
+ .to receive(:file?)
81
+ .with("#{File.expand_path(dummy_app_path)}/.pulsar").and_return(false)
70
82
 
71
- FileUtils.cd(dummy_rack_app_path) do
83
+ FileUtils.cd(dummy_app_path) do
72
84
  reload_main_command
73
85
 
74
86
  pulsar.run(full_list_args)
@@ -76,36 +88,40 @@ describe Pulsar::ListCommand do
76
88
  end
77
89
  end
78
90
 
79
- context "--conf-repo option" do
80
- it "is required" do
91
+ context '--conf-repo option' do
92
+ it 'is required' do
81
93
  expect { pulsar.parse([]) }.to raise_error(Clamp::UsageError)
82
94
  end
83
95
 
84
- it "supports environment variable" do
85
- ENV["PULSAR_CONF_REPO"] = dummy_conf_path
86
- expect { pulsar.parse([]) }.not_to raise_error(Clamp::UsageError)
96
+ it 'supports environment variable' do
97
+ ENV['PULSAR_CONF_REPO'] = dummy_conf_path
98
+ expect { pulsar.parse([]) }.not_to raise_error
87
99
  end
88
100
 
89
- it "supports directories" do
90
- expect { pulsar.run(full_list_args) }.not_to raise_error(Errno::ENOENT)
101
+ it 'supports directories' do
102
+ expect { pulsar.run(full_list_args) }.not_to raise_error
91
103
  end
92
104
  end
93
105
 
94
- context "--tmp-dir option" do
95
- it "is supported" do
96
- expect { pulsar.parse(base_args + %w(--tmp-dir dummy_tmp)) }.to_not raise_error(Clamp::UsageError)
106
+ context '--home-dir option' do
107
+ it 'is supported' do
108
+ expect { pulsar.parse(base_args + %w(--home-dir dummy_tmp)) }
109
+ .not_to raise_error
97
110
  end
98
111
 
99
- it "creates the tmp directory if it doesn't exist" do
100
- run_options = base_args + [ "--tmp-dir", tmp_path("tmp/non_existent") ]
112
+ it 'creates the tmp directory if it doesn\'t exist' do
113
+ Dir.mktmpdir do |dir|
114
+ run_options = base_args + ['--home-dir', dir]
101
115
 
102
- expect { pulsar.run(run_options) }.not_to raise_error
116
+ expect { pulsar.run(run_options) }.not_to raise_error
117
+ expect(File.directory?(pulsar.tmp_path)).to be(true)
118
+ end
103
119
  end
104
120
  end
105
121
 
106
- context "--keep-capfile option" do
107
- it "is supported" do
108
- expect { pulsar.parse(base_args + %w(--keep-capfile)) }.to_not raise_error(Clamp::UsageError)
122
+ context '--keep-capfile option' do
123
+ it 'is supported' do
124
+ expect { pulsar.parse(base_args + %w(--keep-capfile)) }.not_to raise_error
109
125
  end
110
126
  end
111
127
  end
@@ -1,310 +1,360 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Pulsar::MainCommand do
4
- let(:pulsar) { Pulsar::MainCommand.new("") }
4
+ let(:pulsar) { Pulsar::MainCommand.new('') }
5
5
 
6
6
  before(:each) { reload_main_command }
7
7
 
8
- it "builds a Capfile file in tmp dir" do
9
- expect { pulsar.run(full_cap_args + dummy_app) }.to change{ capfile_count }.by(1)
8
+ it 'builds a Capfile file in tmp dir' do
9
+ expect { pulsar.run(full_cap_args + dummy_app) }
10
+ .to change { capfile_count }.by(1)
10
11
  end
11
12
 
12
- it "copies a the repo over to temp directory" do
13
- expect { pulsar.run(full_cap_args + %w(--keep-repo) + dummy_app) }.to change{ capfile_count }.by(1)
13
+ it 'copies a the repo over to temp directory' do
14
+ expect { pulsar.run(full_cap_args + %w(--keep-repo) + dummy_app) }
15
+ .to change { capfile_count }.by(1)
14
16
  end
15
17
 
16
- it "removes the temp directory even if it's raised an error" do
17
- Pulsar::MainCommand.any_instance.stub(:run_capistrano) { raise 'error' }
18
- pulsar.run(base_args + [ "--tmp-dir", tmp_path, "--keep-capfile" ] + dummy_app) rescue nil
18
+ it 'removes the temp directory even if it\'s raised an error' do
19
+ allow_any_instance_of(Pulsar::MainCommand)
20
+ .to receive(:run_capistrano) { fail('error') }
19
21
 
20
- Dir.glob("#{tmp_path}/conf-repo*").should be_empty
22
+ begin
23
+ pulsar.run(
24
+ base_args + ['--home-dir', spec_tmp_path, '--keep-capfile'] + dummy_app)
25
+ rescue
26
+ nil
27
+ end
28
+
29
+ expect(Dir.glob("#{spec_tmp_path}/tmp/conf-repo*")).to be_empty
21
30
  end
22
31
 
23
- it "copies a the repo when there is a dir with same name" do
24
- system("mkdir #{tmp_path}/conf-repo")
25
- expect { pulsar.run(full_cap_args + %w(--keep-repo) + dummy_app) }.to change{ Dir.glob("#{tmp_path}/conf-repo*").length }.by(1)
32
+ it 'copies a the repo when there is a dir with same name' do
33
+ system("mkdir -p #{spec_tmp_path}/tmp/conf-repo")
34
+
35
+ expect { pulsar.run(full_cap_args + %w(--keep-repo) + dummy_app) }
36
+ .to change { Dir.glob("#{spec_tmp_path}/tmp/conf-repo*").length }.by(1)
26
37
  end
27
38
 
28
- it "uses dirname when inside a rack app directory" do
29
- FileUtils.cd(dummy_rack_app_path) do
39
+ it 'uses dirname when inside a rack app directory' do
40
+ FileUtils.cd(dummy_app_path) do
30
41
  reload_main_command
31
42
 
32
- expect { pulsar.run(full_cap_args + %w(production)) }.to change{ capfile_count }.by(1)
43
+ expect { pulsar.run(full_cap_args + %w(production)) }
44
+ .to change { capfile_count }.by(1)
33
45
  end
34
46
  end
35
47
 
36
- context "Multiple applications" do
48
+ context 'Multiple applications' do
37
49
  let :stage do
38
- "production"
50
+ 'production'
39
51
  end
40
52
 
41
53
  let :comma_separated_list do
42
- [ 'dummy_app,other_dummy_app', stage ]
54
+ ['dummy_app,other_dummy_app', stage]
43
55
  end
44
56
 
45
57
  let :pattern_list do
46
- [ 'dummy*', stage ]
58
+ ['dummy*', stage]
47
59
  end
48
60
 
49
61
  let :pattern_match_all do
50
- [ '*', stage ]
62
+ ['*', stage]
51
63
  end
52
64
 
53
65
  let :double_pattern do
54
- [ 'dummy*,*app', stage ]
66
+ ['dummy*,*app', stage]
55
67
  end
56
68
 
57
- it "supports multiple apps via comma separated argument" do
58
- expect { pulsar.run(full_cap_args + comma_separated_list) }.to change{ capfile_count }.by(2)
69
+ it 'supports multiple apps via comma separated argument' do
70
+ expect { pulsar.run(full_cap_args + comma_separated_list) }
71
+ .to change { capfile_count }.by(2)
59
72
  end
60
73
 
61
- it "supports pattern matching on app names" do
62
- expect { pulsar.run(full_cap_args + pattern_list) }.to change{ capfile_count }.by(1)
74
+ it 'supports pattern matching on app names' do
75
+ expect { pulsar.run(full_cap_args + pattern_list) }
76
+ .to change { capfile_count }.by(1)
63
77
  end
64
78
 
65
- it "matches all apps with *" do
66
- expect { pulsar.run(full_cap_args + pattern_match_all) }.to change { capfile_count }.by(2)
79
+ it 'matches all apps with *' do
80
+ expect { pulsar.run(full_cap_args + pattern_match_all) }
81
+ .to change { capfile_count }.by(2)
67
82
  end
68
83
 
69
- it "matches application only once" do
70
- expect { pulsar.run(full_cap_args + double_pattern) }.to change { capfile_count }.by(2)
84
+ it 'matches application only once' do
85
+ expect { pulsar.run(full_cap_args + double_pattern) }
86
+ .to change { capfile_count }.by(2)
71
87
  end
72
88
  end
73
89
 
74
- context "dotfile options" do
75
- it "reads configuration variables from .pulsar file in home" do
76
- stub_dotfile(Dir.home, dummy_dotfile_options)
90
+ context 'dotfile options' do
91
+ it 'reads configuration variables from config file in home' do
92
+ stub_config(File.join(pulsar.home_path, 'config'), dummy_dotfile_options)
77
93
 
78
94
  pulsar.run(full_cap_args + dummy_app)
79
95
 
80
- ENV.to_hash.should include(dummy_dotfile_options)
96
+ expect(ENV.to_hash).to include(dummy_dotfile_options)
81
97
  end
82
98
 
83
- it "reads configuration variables from .pulsar file in rack app directory" do
84
- stub_dotfile(dummy_rack_app_path, dummy_dotfile_options)
99
+ it 'reads configurations from .pulsar file in rack app directory' do
100
+ stub_config(File.join(dummy_app_path, '.pulsar'), dummy_dotfile_options)
85
101
 
86
- FileUtils.cd(dummy_rack_app_path) do
102
+ FileUtils.cd(dummy_app_path) do
87
103
  reload_main_command
88
104
 
89
105
  pulsar.run(full_cap_args + %w(production))
90
106
  end
91
107
 
92
- ENV.to_hash.should include(dummy_dotfile_options)
108
+ expect(ENV.to_hash).to include(dummy_dotfile_options)
93
109
  end
94
110
 
95
- it "skips lines which cannot parse when reading .pulsar file" do
96
- stub_dotfile(dummy_rack_app_path, [ "wrong_line", "# comment"])
111
+ it 'skips lines which cannot parse when reading .pulsar file' do
112
+ stub_config(
113
+ File.join(dummy_app_path, '.pulsar'), ['wrong_line', '# comment'])
97
114
 
98
- FileUtils.cd(dummy_rack_app_path) do
115
+ FileUtils.cd(dummy_app_path) do
99
116
  reload_main_command
100
117
 
101
118
  expect { pulsar.run(full_cap_args + %w(production)) }.not_to raise_error
102
119
  end
103
120
  end
104
121
 
105
- it "falls back to .pulsar file in home directory if it's not in the rack app directory" do
106
- stub_dotfile(Dir.home, dummy_dotfile_options)
122
+ it 'falls back to default config file if it\'s not in the app directory' do
123
+ stub_config(File.join(spec_tmp_path, 'config'), dummy_dotfile_options)
107
124
 
108
- File.stub(:file?).with("#{File.expand_path(dummy_rack_app_path)}/.pulsar").and_return(false)
125
+ allow(File)
126
+ .to receive(:file?)
127
+ .with("#{File.expand_path(dummy_app_path)}/.pulsar").and_return(false)
109
128
 
110
- FileUtils.cd(dummy_rack_app_path) do
129
+ FileUtils.cd(dummy_app_path) do
111
130
  reload_main_command
112
131
 
113
- pulsar.run(full_cap_args + %w(production))
132
+ expect { pulsar.run(full_cap_args + %w(production)) }.not_to raise_error
114
133
  end
115
134
  end
116
135
  end
117
136
 
118
- it "errors out if application does not exist in configuration repository" do
119
- expect { pulsar.run(full_cap_args + %w(non_existent_app production)) }.to raise_error(ArgumentError)
137
+ it 'errors out if application does not exist in configuration repository' do
138
+ expect { pulsar.run(full_cap_args + %w(non_existent_app production)) }
139
+ .to raise_error(ArgumentError)
120
140
  end
121
141
 
122
- it "errors out if stage does not exist in configuration repository" do
123
- expect { pulsar.run(full_cap_args + dummy_app(:non_existent_stage)) }.to raise_error(ArgumentError)
142
+ it 'errors out if stage does not exist in configuration repository' do
143
+ expect { pulsar.run(full_cap_args + dummy_app(:non_existent_stage)) }
144
+ .to raise_error(ArgumentError)
124
145
  end
125
146
 
126
- context "Capfile" do
127
- it "uses base.rb in staging stage" do
147
+ context 'Capfile' do
148
+ it 'uses base.rb in staging stage' do
128
149
  pulsar.run(full_cap_args + dummy_app(:staging))
129
150
 
130
- latest_capfile.should include("# This is apps/base.rb")
151
+ expect(latest_capfile).to include('# This is apps/base.rb')
131
152
  end
132
153
 
133
- it "uses base.rb in production stage" do
154
+ it 'uses base.rb in production stage' do
134
155
  pulsar.run(full_cap_args + dummy_app)
135
156
 
136
- latest_capfile.should include("# This is apps/base.rb")
157
+ expect(latest_capfile).to include('# This is apps/base.rb')
137
158
  end
138
159
 
139
- it "uses defaults.rb in staging stage" do
160
+ it 'uses defaults.rb in staging stage' do
140
161
  pulsar.run(full_cap_args + dummy_app(:staging))
141
162
 
142
- latest_capfile.should include("# This is apps/dummy_app/defaults.rb")
163
+ expect(latest_capfile).to include('# This is apps/dummy_app/defaults.rb')
143
164
  end
144
165
 
145
- it "uses defaults.rb in production stage" do
166
+ it 'uses defaults.rb in production stage' do
146
167
  pulsar.run(full_cap_args + dummy_app)
147
168
 
148
- latest_capfile.should include("# This is apps/dummy_app/defaults.rb")
169
+ expect(latest_capfile).to include('# This is apps/dummy_app/defaults.rb')
149
170
  end
150
171
 
151
- it "uses defaults.rb in staging stage only" do
172
+ it 'uses defaults.rb in staging stage only' do
152
173
  pulsar.run(full_cap_args + dummy_app(:staging))
153
174
 
154
- latest_capfile.should include("# This is apps/dummy_app/staging.rb")
155
- latest_capfile.should_not include("# This is apps/dummy_app/production.rb")
175
+ expect(latest_capfile)
176
+ .to include('# This is apps/dummy_app/staging.rb')
177
+ expect(latest_capfile)
178
+ .not_to include('# This is apps/dummy_app/production.rb')
156
179
  end
157
180
 
158
- it "uses defaults.rb in production stage only" do
181
+ it 'uses defaults.rb in production stage only' do
159
182
  pulsar.run(full_cap_args + dummy_app)
160
183
 
161
- latest_capfile.should include("# This is apps/dummy_app/production.rb")
162
- latest_capfile.should_not include("# This is apps/dummy_app/staging.rb")
184
+ expect(latest_capfile)
185
+ .to include('# This is apps/dummy_app/production.rb')
186
+ expect(latest_capfile)
187
+ .not_to include('# This is apps/dummy_app/staging.rb')
163
188
  end
164
189
 
165
- it "uses custom recipes in staging stage" do
190
+ it 'uses custom recipes in staging stage' do
166
191
  pulsar.run(full_cap_args + dummy_app(:staging))
167
192
 
168
- latest_capfile.should include("# This is apps/dummy_app/recipes/custom_recipe.rb")
193
+ expect(latest_capfile)
194
+ .to include('# This is apps/dummy_app/recipes/custom_recipe.rb')
169
195
  end
170
196
 
171
- it "uses custom recipes in production stage" do
197
+ it 'uses custom recipes in production stage' do
172
198
  pulsar.run(full_cap_args + dummy_app)
173
199
 
174
- latest_capfile.should include("# This is apps/dummy_app/recipes/custom_recipe.rb")
200
+ expect(latest_capfile)
201
+ .to include('# This is apps/dummy_app/recipes/custom_recipe.rb')
175
202
  end
176
203
 
177
- it "uses custom staging recipes in staging stage only" do
204
+ it 'uses custom staging recipes in staging stage only' do
178
205
  pulsar.run(full_cap_args + dummy_app(:staging))
179
206
 
180
- latest_capfile.should include("# This is apps/dummy_app/recipes/staging/custom_recipe.rb")
181
- latest_capfile.should_not include("# This is apps/dummy_app/recipes/production/custom_recipe.rb")
207
+ expect(latest_capfile)
208
+ .to include('# This is apps/dummy_app/recipes/staging/custom_recipe.rb')
209
+ expect(latest_capfile)
210
+ .not_to include(
211
+ '# This is apps/dummy_app/recipes/production/custom_recipe.rb')
182
212
  end
183
213
 
184
- it "uses custom production recipes in production stage only" do
214
+ it 'uses custom production recipes in production stage only' do
185
215
  pulsar.run(full_cap_args + dummy_app)
186
216
 
187
- latest_capfile.should include("# This is apps/dummy_app/recipes/production/custom_recipe.rb")
188
- latest_capfile.should_not include("# This is apps/dummy_app/recipes/staging/custom_recipe.rb")
217
+ expect(latest_capfile)
218
+ .to include(
219
+ '# This is apps/dummy_app/recipes/production/custom_recipe.rb')
220
+ expect(latest_capfile)
221
+ .not_to include(
222
+ '# This is apps/dummy_app/recipes/staging/custom_recipe.rb')
189
223
  end
190
224
 
191
- it "uses dirname from PULSAR_APP_NAME when inside a rack app directory" do
192
- ENV["PULSAR_APP_NAME"] = "other_dummy_app"
225
+ it 'uses dirname from PULSAR_APP_NAME when inside a rack app directory' do
226
+ ENV['PULSAR_APP_NAME'] = 'other_dummy_app'
193
227
 
194
- FileUtils.cd(dummy_rack_app_path) do
228
+ FileUtils.cd(dummy_app_path) do
195
229
  reload_main_command
196
230
  pulsar.run(full_cap_args + %w(production))
197
231
  end
198
232
 
199
- latest_capfile.should include("# This is apps/other_dummy_app/defaults.rb")
200
- latest_capfile.should include("# This is apps/other_dummy_app/production.rb")
233
+ expect(latest_capfile)
234
+ .to include('# This is apps/other_dummy_app/defaults.rb')
235
+ expect(latest_capfile)
236
+ .to include('# This is apps/other_dummy_app/production.rb')
201
237
  end
202
238
  end
203
239
 
204
- context "--version option" do
240
+ context '--version option' do
205
241
  before do
206
242
  begin
207
- pulsar.parse(["--version"])
243
+ pulsar.parse(['--version'])
208
244
  rescue SystemExit => e
209
245
  @system_exit = e
210
246
  end
211
247
  end
212
248
 
213
- it "shows version" do
214
- stdout.should include(Pulsar::VERSION)
249
+ it 'shows version' do
250
+ expect(stdout).to include(Pulsar::VERSION)
215
251
  end
216
252
 
217
- it "exits with a zero status" do
218
- @system_exit.should_not be_nil
219
- @system_exit.status.should == 0
253
+ it 'exits with a zero status' do
254
+ expect(@system_exit).not_to be_nil
255
+ expect(@system_exit.status).to be 0
220
256
  end
221
257
  end
222
258
 
223
- context "--conf-repo option" do
224
- it "is required" do
259
+ context '--conf-repo option' do
260
+ it 'is required' do
225
261
  expect { pulsar.parse([]) }.to raise_error(Clamp::UsageError)
226
262
  end
227
263
 
228
- it "supports environment variable" do
229
- ENV["PULSAR_CONF_REPO"] = dummy_conf_path
230
- expect { pulsar.parse(dummy_app) }.not_to raise_error(Clamp::UsageError)
264
+ it 'supports environment variable' do
265
+ ENV['PULSAR_CONF_REPO'] = dummy_conf_path
266
+ expect { pulsar.parse(dummy_app) }.not_to raise_error
231
267
  end
232
268
 
233
- it "supports directories" do
234
- expect { pulsar.run(full_cap_args + dummy_app) }.not_to raise_error(Errno::ENOENT)
269
+ it 'supports directories' do
270
+ expect { pulsar.run(full_cap_args + dummy_app) }.not_to raise_error
235
271
  end
236
272
  end
237
273
 
238
- context "--tmp-dir option" do
239
- it "is supported" do
240
- expect { pulsar.parse(base_args + %w(--tmp-dir dummy_tmp) + dummy_app) }.to_not raise_error(Clamp::UsageError)
274
+ context '--home-dir option' do
275
+ it 'is supported' do
276
+ expect { pulsar.parse(base_args + %w(--home-dir dummy_tmp) + dummy_app) }
277
+ .not_to raise_error
241
278
  end
242
279
 
243
- it "creates the tmp directory if it doesn't exist" do
244
- run_options = base_args + [ "--tmp-dir", tmp_path("tmp/non_existent"), "--skip-cap-run" ] + dummy_app
280
+ it 'creates the tmp directory if it doesn\'t exist' do
281
+ Dir.mktmpdir do |dir|
282
+ run_options = base_args +
283
+ ['--home-dir', dir, '--skip-cap-run'] +
284
+ dummy_app
245
285
 
246
- expect { pulsar.run(run_options) }.not_to raise_error
286
+ expect { pulsar.run(run_options) }.not_to raise_error
287
+ expect(File.directory?(pulsar.tmp_path)).to be(true)
288
+ end
247
289
  end
248
290
  end
249
291
 
250
- context "--keep-capfile option" do
251
- it "is supported" do
252
- expect { pulsar.parse(base_args + %w(--keep-capfile) + dummy_app) }.to_not raise_error(Clamp::UsageError)
292
+ context '--keep-capfile option' do
293
+ it 'is supported' do
294
+ expect { pulsar.parse(base_args + %w(--keep-capfile) + dummy_app) }
295
+ .not_to raise_error
253
296
  end
254
297
  end
255
298
 
256
- context "--skip-cap-run option" do
257
- it "is supported" do
258
- expect { pulsar.parse(base_args + %w(--skip-cap-run) + dummy_app) }.to_not raise_error(Clamp::UsageError)
299
+ context '--skip-cap-run option' do
300
+ it 'is supported' do
301
+ expect { pulsar.parse(base_args + %w(--skip-cap-run) + dummy_app) }
302
+ .not_to raise_error
259
303
  end
260
304
  end
261
305
 
262
- context "--keep-repo option" do
263
- it "is supported" do
264
- expect { pulsar.parse(base_args + %w(--keep-repo) + dummy_app) }.to_not raise_error(Clamp::UsageError)
306
+ context '--keep-repo option' do
307
+ it 'is supported' do
308
+ expect { pulsar.parse(base_args + %w(--keep-repo) + dummy_app) }
309
+ .not_to raise_error
265
310
  end
266
311
  end
267
312
 
268
- context "--log-level option" do
269
- it "is supported" do
270
- expect { pulsar.parse(base_args + %w(--log-level debug) + dummy_app) }.to_not raise_error(Clamp::UsageError)
313
+ context '--log-level option' do
314
+ it 'is supported' do
315
+ expect { pulsar.parse(base_args + %w(--log-level debug) + dummy_app) }
316
+ .not_to raise_error
271
317
  end
272
318
 
273
- it "supports Capistrano IMPORTANT" do
319
+ it 'supports Capistrano IMPORTANT' do
274
320
  pulsar.run(full_cap_args + %w(--log-level important) + dummy_app)
275
321
 
276
- latest_capfile.should include("logger.level = logger.level = Capistrano::Logger::IMPORTANT")
322
+ expect(latest_capfile).to include(
323
+ 'logger.level = logger.level = Capistrano::Logger::IMPORTANT')
277
324
  end
278
325
 
279
- it "supports Capistrano INFO" do
326
+ it 'supports Capistrano INFO' do
280
327
  pulsar.run(full_cap_args + %w(--log-level info) + dummy_app)
281
328
 
282
- latest_capfile.should include("logger.level = logger.level = Capistrano::Logger::INFO")
329
+ expect(latest_capfile)
330
+ .to include('logger.level = logger.level = Capistrano::Logger::INFO')
283
331
  end
284
332
 
285
- it "supports Capistrano DEBUG" do
333
+ it 'supports Capistrano DEBUG' do
286
334
  pulsar.run(full_cap_args + %w(--log-level debug) + dummy_app)
287
335
 
288
- latest_capfile.should include("logger.level = logger.level = Capistrano::Logger::DEBUG")
336
+ expect(latest_capfile)
337
+ .to include('logger.level = logger.level = Capistrano::Logger::DEBUG')
289
338
  end
290
339
 
291
- it "supports Capistrano TRACE" do
340
+ it 'supports Capistrano TRACE' do
292
341
  pulsar.run(full_cap_args + %w(--log-level trace) + dummy_app)
293
342
 
294
- latest_capfile.should include("logger.level = logger.level = Capistrano::Logger::TRACE")
343
+ expect(latest_capfile)
344
+ .to include('logger.level = logger.level = Capistrano::Logger::TRACE')
295
345
  end
296
346
  end
297
347
 
298
- context "TASKS parameter" do
299
- it "defaults to deploy" do
300
- pulsar.tasks_list.should == "deploy"
348
+ context 'TASKS parameter' do
349
+ it 'defaults to deploy' do
350
+ expect(pulsar.tasks_list).to eq 'deploy'
301
351
  end
302
352
 
303
- it "supports environment variable" do
304
- ENV["PULSAR_DEFAULT_TASK"] = "custom:task"
353
+ it 'supports environment variable' do
354
+ ENV['PULSAR_DEFAULT_TASK'] = 'custom:task'
305
355
  pulsar.run(full_cap_args + dummy_app)
306
356
 
307
- pulsar.tasks_list.should == [ "custom:task" ]
357
+ expect(pulsar.tasks_list).to eq ['custom:task']
308
358
  end
309
359
  end
310
360
  end