pulsar 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,33 +1,33 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Pulsar::UtilsCommand do
4
- let(:pulsar) { Pulsar::UtilsCommand.new("") }
4
+ let(:pulsar) { Pulsar::UtilsCommand.new('') }
5
5
 
6
- context "--version option" do
6
+ context '--version option' do
7
7
  before do
8
8
  begin
9
- pulsar.parse(["--version"])
9
+ pulsar.parse(['--version'])
10
10
  rescue SystemExit => e
11
11
  @system_exit = e
12
12
  end
13
13
  end
14
14
 
15
- it "shows version" do
16
- stdout.should include(Pulsar::VERSION)
15
+ it 'shows version' do
16
+ expect(stdout).to include(Pulsar::VERSION)
17
17
  end
18
18
 
19
- it "exits with a zero status" do
20
- @system_exit.should_not be_nil
21
- @system_exit.status.should == 0
19
+ it 'exits with a zero status' do
20
+ expect(@system_exit).not_to be_nil
21
+ expect(@system_exit.status).to be 0
22
22
  end
23
23
  end
24
24
 
25
- context "subcommands" do
26
- it "should be cap and list and init" do
25
+ context 'subcommands' do
26
+ it 'should be cap and list and init' do
27
27
  help = pulsar.help
28
- help.should =~ /Subcommands:/
29
- help.should =~ /list/
30
- help.should =~ /init/
28
+ expect(help).to match(/Subcommands:/)
29
+ expect(help).to match(/list/)
30
+ expect(help).to match(/init/)
31
31
  end
32
32
  end
33
33
  end
@@ -3,62 +3,68 @@ require 'spec_helper'
3
3
  describe Pulsar::Helpers::Capistrano do
4
4
  include Pulsar::Helpers::Capistrano
5
5
 
6
- context "load_recipes" do
7
- it "loads capistrano recipes from CONFIG_PATH env variable" do
8
- ENV['CONFIG_PATH'] = "/config/path"
9
- File.stub(:directory?).and_return(true)
10
- File.stub(:exists?).and_return(true)
11
-
12
- self.should_receive(:load).with("/config/path/recipes/generic/recipe.rb")
6
+ context 'load_recipes' do
7
+ it 'loads capistrano recipes from CONFIG_PATH env variable' do
8
+ ENV['CONFIG_PATH'] = '/config/path'
9
+ allow(File).to receive(:directory?).and_return(true)
10
+ allow(File).to receive(:exist?).and_return(true)
11
+ allow(self).to receive(:load)
13
12
 
14
13
  load_recipes { generic :recipe }
14
+
15
+ expect(self)
16
+ .to have_received(:load).with('/config/path/recipes/generic/recipe.rb')
15
17
  end
16
18
 
17
- it "raises a missing recipe type exception when no recipe folder is found" do
18
- File.stub(:directory?).and_return(false)
19
+ it 'raises a missing recipe exception when no recipe folder is found' do
20
+ allow(File).to receive(:directory?).and_return(false)
19
21
 
20
- expect { load_recipes { generic :recipe } }.to raise_error(RuntimeError, /no recipes of type generic/)
22
+ expect { load_recipes { generic :recipe } }
23
+ .to raise_error(RuntimeError, /no recipes of type generic/)
21
24
  end
22
25
 
23
- it "raises a missing recipe exception when no recipe is found" do
24
- File.stub(:directory?).and_return(true)
25
- File.stub(:exists?).and_return(false)
26
+ it 'raises a missing recipe exception when no recipe is found' do
27
+ allow(File).to receive(:directory?).and_return(true)
28
+ allow(File).to receive(:exist?).and_return(false)
26
29
 
27
- expect { load_recipes { generic :missing_recipe } }.to raise_error(RuntimeError, /no missing_recipe recipe/)
30
+ expect { load_recipes { generic :missing_recipe } }
31
+ .to raise_error(RuntimeError, /no missing_recipe recipe/)
28
32
  end
29
33
 
30
- it "does not call load if :app_only is true and pulsar is not called from inside application" do
34
+ it 'does not load if :app_only and pulsar is not inside an application' do
31
35
  ENV.delete('APP_PATH')
32
- File.stub(:directory?).and_return(true)
33
- File.stub(:exists?).and_return(true)
36
+ allow(File).to receive(:directory?).and_return(true)
37
+ allow(File).to receive(:exist?).and_return(true)
38
+ allow(self).to receive(:load)
34
39
 
35
- self.should_not_receive(:load)
40
+ load_recipes(app_only: true) { generic :recipe }
36
41
 
37
- load_recipes(:app_only => true) { generic :recipe }
42
+ expect(self).not_to have_received(:load)
38
43
  end
39
44
 
40
- it "calls load if :app_only is true and pulsar is called from inside application" do
41
- ENV['APP_PATH'] = "/app/path"
42
- File.stub(:directory?).and_return(true)
43
- File.stub(:exists?).and_return(true)
45
+ it 'loads if :app_only is true and pulsar is inside an application' do
46
+ ENV['APP_PATH'] = '/app/path'
47
+ allow(File).to receive(:directory?).and_return(true)
48
+ allow(File).to receive(:exist?).and_return(true)
49
+ allow(self).to receive(:load)
44
50
 
45
- self.should_receive(:load)
51
+ load_recipes(app_only: true) { generic :recipe }
46
52
 
47
- load_recipes(:app_only => true) { generic :recipe }
53
+ expect(self).to have_received(:load)
48
54
  end
49
55
  end
50
56
 
51
- context "from_application_path?" do
52
- it "returns true if APP_PATH env variable is set" do
53
- ENV['APP_PATH'] = "/app/path"
57
+ context 'from_application_path?' do
58
+ it 'returns true if APP_PATH env variable is set' do
59
+ ENV['APP_PATH'] = '/app/path'
54
60
 
55
- from_application_path?.should be_true
61
+ expect(from_application_path?).to be true
56
62
  end
57
63
 
58
- it "returns false if APP_PATH env variable is not set" do
64
+ it 'returns false if APP_PATH env variable is not set' do
59
65
  ENV.delete('APP_PATH')
60
66
 
61
- from_application_path?.should be_false
67
+ expect(from_application_path?).to be false
62
68
  end
63
69
  end
64
70
  end
@@ -3,72 +3,103 @@ require 'spec_helper'
3
3
  describe Pulsar::Helpers::Clamp do
4
4
  include Pulsar::Helpers::Clamp
5
5
 
6
- context "fetch_repo" do
7
- it "supports directories" do
8
- File.stub(:directory?).and_return(true)
9
- self.stub!(:conf_repo).and_return("conf-repo/path")
10
-
11
- self.should_receive(:fetch_directory_repo).with("conf-repo/path")
6
+ context 'fetch_repo' do
7
+ it 'supports directories' do
8
+ allow(File).to receive(:directory?).and_return(true)
9
+ allow(self).to receive(:conf_repo).and_return('conf-repo/path')
10
+ allow(self).to receive(:fetch_directory_repo)
12
11
 
13
12
  fetch_repo
14
- end
15
13
 
16
- it "supports full git path" do
17
- File.stub(:directory?).and_return(false)
18
- self.stub!(:conf_repo).and_return("git://github.com/gh_user/pulsar-conf.git")
14
+ expect(self)
15
+ .to have_received(:fetch_directory_repo).with('conf-repo/path')
16
+ end
19
17
 
20
- self.should_receive(:fetch_git_repo).with("git://github.com/gh_user/pulsar-conf.git")
18
+ it 'supports full git path' do
19
+ allow(File).to receive(:directory?).and_return(false)
20
+ allow(self).to receive(:fetch_git_repo)
21
+ allow(self)
22
+ .to receive(:conf_repo)
23
+ .and_return('git://github.com/gh_user/pulsar-conf.git')
21
24
 
22
25
  fetch_repo
23
- end
24
26
 
25
- it "supports full git path on ssh" do
26
- File.stub(:directory?).and_return(false)
27
- self.stub!(:conf_repo).and_return("git@github.com:gh_user/pulsar-conf.git")
27
+ expect(self)
28
+ .to have_received(:fetch_git_repo)
29
+ .with('git://github.com/gh_user/pulsar-conf.git')
30
+ end
28
31
 
29
- self.should_receive(:fetch_git_repo).with("git@github.com:gh_user/pulsar-conf.git")
32
+ it 'supports full git path on ssh' do
33
+ allow(File).to receive(:directory?).and_return(false)
34
+ allow(self).to receive(:fetch_git_repo)
35
+ allow(self)
36
+ .to receive(:conf_repo)
37
+ .and_return('git@github.com:gh_user/pulsar-conf.git')
30
38
 
31
39
  fetch_repo
32
- end
33
40
 
34
- it "supports full git path on http" do
35
- File.stub(:directory?).and_return(false)
36
- self.stub!(:conf_repo).and_return("https://github.com/gh_user/pulsar.git")
41
+ expect(self)
42
+ .to have_received(:fetch_git_repo)
43
+ .with('git@github.com:gh_user/pulsar-conf.git')
44
+ end
37
45
 
38
- self.should_receive(:fetch_git_repo).with("https://github.com/gh_user/pulsar.git")
46
+ it 'supports full git path on http' do
47
+ allow(File).to receive(:directory?).and_return(false)
48
+ allow(self).to receive(:fetch_git_repo)
49
+ allow(self)
50
+ .to receive(:conf_repo)
51
+ .and_return('https://github.com/gh_user/pulsar.git')
39
52
 
40
53
  fetch_repo
41
- end
42
54
 
43
- it "supports github path" do
44
- File.stub(:directory?).and_return(false)
45
- self.stub!(:conf_repo).and_return("gh-user/pulsar-conf")
55
+ expect(self)
56
+ .to have_received(:fetch_git_repo)
57
+ .with('https://github.com/gh_user/pulsar.git')
58
+ end
46
59
 
47
- self.should_receive(:fetch_git_repo).with("git@github.com:gh-user/pulsar-conf.git")
60
+ it 'supports github path' do
61
+ allow(File).to receive(:directory?).and_return(false)
62
+ allow(self).to receive(:conf_repo).and_return('gh-user/pulsar-conf')
63
+ allow(self).to receive(:fetch_git_repo)
48
64
 
49
65
  fetch_repo
66
+
67
+ expect(self)
68
+ .to have_received(:fetch_git_repo)
69
+ .with('git@github.com:gh-user/pulsar-conf.git')
50
70
  end
51
71
  end
52
72
 
53
- context "run_capistrano" do
73
+ context 'run_capistrano' do
54
74
  before do
55
- self.stub!(:config_path).and_return(dummy_conf_path)
56
- self.stub!(:verbose?).and_return(false)
57
- self.stub!(:capfile_path).and_return('/stubbed/capfile')
75
+ allow(self).to receive(:config_path).and_return(dummy_conf_path)
76
+ allow(self).to receive(:verbose?).and_return(false)
77
+ allow(self).to receive(:capfile_path).and_return('/stubbed/capfile')
78
+ allow(self).to receive(:run_cmd)
58
79
  end
59
80
 
60
- it "runs capistrano when pulsar is invoked from outside the application directory" do
61
- self.should_receive(:run_cmd).with("bundle exec cap CONFIG_PATH=#{config_path} --file #{capfile_path} deploy", anything)
81
+ it 'runs capistrano when pulsar is invoked from outside an application' do
82
+ cap_cmd = 'bundle exec cap'
83
+ env_vars = "CONFIG_PATH=#{config_path}"
84
+ cmd_args = "--file #{capfile_path} deploy"
85
+ full_cmd = "#{cap_cmd} #{env_vars} #{cmd_args}"
86
+
87
+ run_capistrano('deploy')
62
88
 
63
- run_capistrano("deploy")
89
+ expect(self).to have_received(:run_cmd).with(full_cmd, anything)
64
90
  end
65
91
 
66
- it "runs capistrano when pulsar is invoked from inside the application directory" do
67
- self.stub!(:application_path).and_return("/app/path")
92
+ it 'runs capistrano when pulsar is invoked from inside an application' do
93
+ allow(self).to receive(:application_path).and_return('/app/path')
94
+
95
+ cap_cmd = 'bundle exec cap'
96
+ env_vars = "CONFIG_PATH=#{config_path} APP_PATH=#{application_path}"
97
+ cmd_args = "--file #{capfile_path} deploy"
98
+ full_cmd = "#{cap_cmd} #{env_vars} #{cmd_args}"
68
99
 
69
- self.should_receive(:run_cmd).with("bundle exec cap CONFIG_PATH=#{config_path} APP_PATH=#{application_path} --file #{capfile_path} deploy", anything)
100
+ run_capistrano('deploy')
70
101
 
71
- run_capistrano("deploy")
102
+ expect(self).to have_received(:run_cmd).with(full_cmd, anything)
72
103
  end
73
104
  end
74
105
  end
@@ -3,9 +3,9 @@ require 'spec_helper'
3
3
  describe Pulsar::Helpers::Shell do
4
4
  include Pulsar::Helpers::Shell
5
5
 
6
- context "run_cmd" do
7
- it "raises exception if command fails" do
8
- expect { run_cmd("false", {}) }.to raise_error
6
+ context 'run_cmd' do
7
+ it 'raises exception if command fails' do
8
+ expect { run_cmd('false', {}) }.to raise_error
9
9
  end
10
10
  end
11
11
  end
data/spec/spec_helper.rb CHANGED
@@ -1,30 +1,31 @@
1
- require "rspec"
2
- require "stringio"
3
- require "fileutils"
4
- require "coveralls"
5
- require "pulsar"
6
- require "pulsar/commands/main"
7
- require "pulsar/commands/utils"
1
+ require 'rspec'
2
+ require 'stringio'
3
+ require 'fileutils'
4
+ require 'codeclimate-test-reporter'
5
+ require 'pulsar'
6
+ require 'pulsar/commands/main'
7
+ require 'pulsar/commands/utils'
8
8
 
9
9
  #
10
10
  # Code coverage
11
11
  #
12
- Coveralls.wear!
12
+ CodeClimate::TestReporter.start
13
13
 
14
14
  #
15
15
  # Require all helper modules
16
16
  #
17
- Dir[File.join(File.dirname(__FILE__), 'support/modules/**/*.rb')].each { |f| require f }
17
+ Dir[File.join(File.dirname(__FILE__), 'support/modules/**/*.rb')].each do |f|
18
+ require f
19
+ end
18
20
 
19
21
  RSpec.configure do |config|
20
22
  config.mock_with :rspec
23
+ config.raise_errors_for_deprecations!
21
24
 
22
25
  config.include Helpers
23
26
  config.include OutputCapture
24
27
 
25
28
  config.before(:each) do
26
- Dir.stub(:home).and_return("/fake/home")
27
-
28
29
  dummy_dotfile_options.keys.each do |variable|
29
30
  ENV.delete(variable.to_s)
30
31
  end
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Require from local gem
4
- gem 'pulsar', :path => '../../../../'
4
+ gem 'pulsar', path: '../../../../'
@@ -29,18 +29,18 @@ end
29
29
  #
30
30
  set :scm, :git
31
31
 
32
- set :ssh_options, { :forward_agent => true }
32
+ set :ssh_options, forward_agent: true
33
33
 
34
- set :default_run_options, { :pty => true }
34
+ set :default_run_options, pty: true
35
35
 
36
36
  set :deploy_to, defer { "/var/www/#{application}" }
37
37
 
38
38
  set :deploy_via, :remote_cache
39
39
 
40
- set :user, "www-data"
40
+ set :user, 'www-data'
41
41
 
42
42
  set :use_sudo, false
43
43
 
44
- set :rake, "bundle exec rake"
44
+ set :rake, 'bundle exec rake'
45
45
 
46
- set :rails_env, defer { "#{stage}" }
46
+ set :rails_env, defer { stage }
@@ -1,5 +1,5 @@
1
1
  # This is apps/dummy_app/custom_stage.rb
2
2
 
3
- server "dummy.it", :db, :web, :app, :primary => true
3
+ server 'dummy.it', :db, :web, :app, primary: true
4
4
 
5
- set :stage, "custom_stage"
5
+ set :stage, 'custom_stage'
@@ -1,6 +1,6 @@
1
1
  # This is apps/dummy_app/defaults.rb
2
2
 
3
- set :application, "dummy_app"
3
+ set :application, 'dummy_app'
4
4
 
5
5
  load_recipes do
6
6
  generic :recipe
@@ -1,5 +1,5 @@
1
1
  # This is apps/dummy_app/production.rb
2
2
 
3
- server "dummy.it", :db, :web, :app, :primary => true
3
+ server 'dummy.it', :db, :web, :app, primary: true
4
4
 
5
- set :stage, "production"
5
+ set :stage, 'production'
@@ -1,5 +1,5 @@
1
1
  # This is apps/dummy_app/staging.rb
2
2
 
3
- server "staging.dummy.it", :db, :web, :app, :primary => true
3
+ server 'staging.dummy.it', :db, :web, :app, primary: true
4
4
 
5
- set :stage, "staging"
5
+ set :stage, 'staging'
@@ -1,5 +1,5 @@
1
1
  # This is apps/other_dummy_app/custom_stage.rb
2
2
 
3
- server "dummy.it", :db, :web, :app, :primary => true
3
+ server 'dummy.it', :db, :web, :app, primary: true
4
4
 
5
- set :stage, "custom_stage"
5
+ set :stage, 'custom_stage'
@@ -1,6 +1,6 @@
1
1
  # This is apps/other_dummy_app/defaults.rb
2
2
 
3
- set :application, "other_dummy_app"
3
+ set :application, 'other_dummy_app'
4
4
 
5
5
  load_recipes do
6
6
  generic :recipe
@@ -1,5 +1,5 @@
1
1
  # This is apps/other_dummy_app/production.rb
2
2
 
3
- server "other_dummy.it", :db, :web, :app, :primary => true
3
+ server 'other_dummy.it', :db, :web, :app, primary: true
4
4
 
5
- set :stage, "production"
5
+ set :stage, 'production'
@@ -1,5 +1,5 @@
1
1
  # This is apps/other_dummy_app/staging.rb
2
2
 
3
- server "staging.other_dummy.it", :db, :web, :app, :primary => true
3
+ server 'staging.other_dummy.it', :db, :web, :app, primary: true
4
4
 
5
- set :stage, "staging"
5
+ set :stage, 'staging'