pulsar 1.0.0.pre → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/{bin → exe}/pulsar +0 -0
  3. data/lib/pulsar/cli.rb +13 -1
  4. data/lib/pulsar/interactors/add_applications.rb +5 -5
  5. data/lib/pulsar/interactors/clone_repository.rb +2 -1
  6. data/lib/pulsar/interactors/copy_environment_file.rb +5 -1
  7. data/lib/pulsar/interactors/copy_initial_repository.rb +1 -1
  8. data/lib/pulsar/interactors/create_capfile.rb +4 -1
  9. data/lib/pulsar/interactors/create_deploy_file.rb +1 -1
  10. data/lib/pulsar/interactors/identify_repository_location.rb +1 -1
  11. data/lib/pulsar/interactors/identify_repository_type.rb +2 -7
  12. data/lib/pulsar/interactors/run_bundle_install.rb +1 -1
  13. data/lib/pulsar/interactors/run_capistrano.rb +2 -2
  14. data/lib/pulsar/organizers/deploy.rb +1 -0
  15. data/lib/pulsar/version.rb +1 -1
  16. data/pulsar.gemspec +2 -1
  17. data/spec/features/deploy_spec.rb +46 -49
  18. data/spec/features/install_spec.rb +2 -2
  19. data/spec/features/list_spec.rb +10 -40
  20. data/spec/features/version_spec.rb +17 -0
  21. data/spec/spec_helper.rb +2 -1
  22. data/spec/units/cli/list_spec.rb +6 -6
  23. data/spec/units/interactors/add_applications_spec.rb +1 -1
  24. data/spec/units/interactors/clone_repository_spec.rb +1 -0
  25. data/spec/units/interactors/copy_environment_file_spec.rb +4 -1
  26. data/spec/units/interactors/create_capfile_spec.rb +1 -1
  27. data/spec/units/interactors/identify_repository_type_spec.rb +0 -22
  28. data/spec/units/interactors/run_bundle_install_spec.rb +3 -3
  29. data/spec/units/interactors/run_capistrano_spec.rb +2 -2
  30. data/spec/units/organizers/deploy_spec.rb +1 -0
  31. metadata +8 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 921914916a66521e123a39711c7b62f7336cb901
4
- data.tar.gz: 15e6595fcaa432a63321128e515cfd2141af9ec3
3
+ metadata.gz: 49da97e3127c662682484d2c3339d873a2dc7cea
4
+ data.tar.gz: ef831d3995741f3fdee35ff56a6c603f5095e649
5
5
  SHA512:
6
- metadata.gz: f7c0a941f8cce88aadf721b9d5dda5a98169be84853447dfd061046c3a6475fc667eb519019eb324b65922e93814d7b85ac01ca69994c8af82dba23e8d1bfe0b
7
- data.tar.gz: e508f7f5149735f13802e5506c33ae592a3ffb08a11eb2254b3fea1d6b2d08560b05a056ebeadab78f1689db59514754e1f9224e06de6078d5ef00c1db9910e1
6
+ metadata.gz: cad9605fa0f1f5e8564e2aa0620d20dea1c50ca5c766a0d4ae524c370c0a7777137390d78b34e0f26d965cebe5637e3bcd6bec2c2cfeac1ee4d87b36625caac3
7
+ data.tar.gz: 4cc0710f834e143f5e0b7969e42f03c76334a001ef5782d3d191e47e6c45be16bdcca89e3f338f938d752629045eb746761b6faf67ed5e99447b248ebb205a61
File without changes
@@ -1,5 +1,7 @@
1
1
  module Pulsar
2
2
  class CLI < Thor
3
+ map %w[--version -v] => :__print_version
4
+
3
5
  desc 'install [DIRECTORY]', 'Install initial repository in DIRECTORY'
4
6
  long_desc <<-LONGDESC
5
7
  `pulsar install` will install the initial pulsar repository in the
@@ -15,6 +17,7 @@ module Pulsar
15
17
  puts 'Successfully created intial repo!'
16
18
  else
17
19
  puts 'Failed to create intial repo.'
20
+ puts result.error
18
21
  end
19
22
  end
20
23
 
@@ -29,9 +32,12 @@ module Pulsar
29
32
  result = Pulsar::List.call(repository: load_option_or_env!(:conf_repo))
30
33
 
31
34
  if result.success?
32
- puts result.applications
35
+ result.applications.each do |app, stages|
36
+ puts "#{app}: #{stages.join(', ')}"
37
+ end
33
38
  else
34
39
  puts 'Failed to list application and environments.'
40
+ puts result.error
35
41
  end
36
42
  end
37
43
 
@@ -53,9 +59,15 @@ module Pulsar
53
59
  puts "Deployed #{application} on #{environment}!"
54
60
  else
55
61
  puts "Failed to deploy #{application} on #{environment}."
62
+ puts result.error
56
63
  end
57
64
  end
58
65
 
66
+ desc "--version, -v", "print the version"
67
+ def __print_version
68
+ puts Pulsar::VERSION
69
+ end
70
+
59
71
  private
60
72
 
61
73
  def load_config
@@ -7,16 +7,16 @@ module Pulsar
7
7
 
8
8
  def call
9
9
  each_application_path do |app|
10
- context.applications << "#{File.basename(app)}: #{stages_for(app)}"
10
+ context.applications[File.basename(app)] = stages_for(app)
11
11
  end
12
12
  rescue
13
- context.fail!
13
+ context.fail! error: $!.message
14
14
  end
15
15
 
16
16
  private
17
17
 
18
18
  def prepare_context
19
- context.applications = []
19
+ context.applications = {}
20
20
  end
21
21
 
22
22
  def validate_input!
@@ -24,7 +24,7 @@ module Pulsar
24
24
  end
25
25
 
26
26
  def validate_output!
27
- context.fail! if context.applications.empty?
27
+ context.fail! error: "No application found on repository #{context.repository}" if context.applications.empty?
28
28
  end
29
29
 
30
30
  def each_application_path
@@ -42,7 +42,7 @@ module Pulsar
42
42
  end
43
43
  stage_files.reject do |stage|
44
44
  %w(deploy Capfile).include?(stage)
45
- end.join(', ')
45
+ end
46
46
  end
47
47
  end
48
48
  end
@@ -11,7 +11,7 @@ module Pulsar
11
11
  when :folder then copy_local_folder
12
12
  end
13
13
  rescue
14
- context.fail!
14
+ context.fail! error: $!.message
15
15
  end
16
16
 
17
17
  private
@@ -44,6 +44,7 @@ module Pulsar
44
44
  end
45
45
 
46
46
  def copy_local_folder
47
+ raise "No repository found at #{context.repository}" unless File.exist? context.repository
47
48
  FileUtils.cp_r("#{context.repository}/.", context.config_path)
48
49
  end
49
50
  end
@@ -10,7 +10,7 @@ module Pulsar
10
10
  FileUtils.mkdir_p(context.cap_deploy_path)
11
11
  FileUtils.cp(env_file, context.environment_file_path)
12
12
  rescue
13
- context.fail!
13
+ context.fail! error: $!.message
14
14
  end
15
15
 
16
16
  private
@@ -24,7 +24,11 @@ module Pulsar
24
24
  context.fail! if context.config_path.nil? ||
25
25
  context.cap_path.nil? ||
26
26
  context.application.nil? ||
27
+ context.applications.nil? ||
27
28
  context.environment.nil?
29
+ unless context.applications[context.application].include? context.environment
30
+ context.fail! error: "The application #{context.application} does not have an environment called #{context.environment}"
31
+ end
28
32
  end
29
33
  end
30
34
  end
@@ -10,7 +10,7 @@ module Pulsar
10
10
 
11
11
  FileUtils.cp_r(File.expand_path(initial_repo), context.directory)
12
12
  rescue
13
- context.fail!
13
+ context.fail! error: $!.message
14
14
  end
15
15
 
16
16
  private
@@ -14,7 +14,7 @@ module Pulsar
14
14
  Rake.sh("cat #{app_capfile} >> #{context.capfile_path}") if File.exist?(app_capfile)
15
15
  Rake.sh("echo '#{import_tasks}' >> #{context.capfile_path}")
16
16
  rescue
17
- context.fail!
17
+ context.fail! error: $!.message
18
18
  end
19
19
 
20
20
  private
@@ -27,6 +27,9 @@ module Pulsar
27
27
  context.fail! if context.config_path.nil? ||
28
28
  context.cap_path.nil? ||
29
29
  context.application.nil?
30
+ unless context.applications.keys.include? context.application
31
+ context.fail! error: "The application #{context.application} does not exist in your repository"
32
+ end
30
33
  end
31
34
  end
32
35
  end
@@ -13,7 +13,7 @@ module Pulsar
13
13
  Rake.sh("cat #{default_deploy} >> #{context.deploy_file_path}") if File.exist?(default_deploy)
14
14
  Rake.sh("cat #{app_deploy} >> #{context.deploy_file_path}") if File.exist?(app_deploy)
15
15
  rescue
16
- context.fail!
16
+ context.fail! error: $!.message
17
17
  end
18
18
 
19
19
  private
@@ -11,7 +11,7 @@ module Pulsar
11
11
  :remote
12
12
  end
13
13
  rescue
14
- context.fail!
14
+ context.fail! error: $!.message
15
15
  end
16
16
 
17
17
  private
@@ -7,12 +7,12 @@ module Pulsar
7
7
  def call
8
8
  case context.repository_location
9
9
  when :local
10
- context.repository_type = git_repository? ? :git : :folder
10
+ context.repository_type = :folder
11
11
  when :remote
12
12
  context.repository_type = github_repository? ? :github : :git
13
13
  end
14
14
  rescue
15
- context.fail!
15
+ context.fail! error: $!.message
16
16
  end
17
17
 
18
18
  private
@@ -22,11 +22,6 @@ module Pulsar
22
22
  context.fail! if context.repository_location.nil?
23
23
  end
24
24
 
25
- def git_repository?
26
- Rake.sh("git -C #{context.repository} status >/dev/null 2>&1") &&
27
- File.exist?("#{context.repository}/.git")
28
- end
29
-
30
25
  def github_repository?
31
26
  context.repository =~ %r{^[\w-]+\/[\w-]+$}
32
27
  end
@@ -12,7 +12,7 @@ module Pulsar
12
12
  bundle_cmd = "#{cmd_env} bundle check || #{cmd_env} bundle install"
13
13
 
14
14
  Bundler.with_clean_env do
15
- context.fail! unless system("#{bundle_cmd}#{out_redir}")
15
+ Rake.sh("#{bundle_cmd}#{out_redir}")
16
16
  end
17
17
  rescue
18
18
  context.fail!
@@ -12,10 +12,10 @@ module Pulsar
12
12
  out_redir = ENV['DRY_RUN'] ? '> /dev/null 2>&1' : nil
13
13
  cap_cmd = "bundle exec cap #{cap_opts}#{context.environment} deploy"
14
14
 
15
- context.fail! unless system("#{gemfile_env} #{bundle_env} #{cap_cmd}#{out_redir}")
15
+ Rake.sh("#{gemfile_env} #{bundle_env} #{cap_cmd}#{out_redir}")
16
16
  end
17
17
  rescue
18
- context.fail!
18
+ context.fail! error: $!.message
19
19
  end
20
20
 
21
21
  private
@@ -6,6 +6,7 @@ module Pulsar
6
6
  IdentifyRepositoryType,
7
7
  CreateRunDirs,
8
8
  CloneRepository,
9
+ AddApplications,
9
10
  CreateCapfile,
10
11
  CreateDeployFile,
11
12
  CopyEnvironmentFile,
@@ -1,3 +1,3 @@
1
1
  module Pulsar
2
- VERSION = '1.0.0.pre'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
@@ -17,7 +17,8 @@ Gem::Specification.new do |gem|
17
17
  '
18
18
 
19
19
  gem.files = `git ls-files`.split($/)
20
- gem.executables = gem.files.grep(%r{^bin\/}).map { |f| File.basename(f) }
20
+ gem.bindir = 'exe'
21
+ gem.executables = gem.files.grep(%r{^exe\/}).map { |f| File.basename(f) }
21
22
  gem.test_files = gem.files.grep(%r{^(test|spec|features)\/})
22
23
  gem.require_paths = ['lib']
23
24
 
@@ -4,12 +4,14 @@ RSpec.describe 'Deploy' do
4
4
  subject { -> { command } }
5
5
 
6
6
  let(:command) do
7
- `DRY_RUN=true ruby #{RSpec.configuration.pulsar_command} deploy #{options} #{arguments}`
7
+ `DRY_RUN=true #{RSpec.configuration.pulsar_command} deploy #{options} #{arguments}`
8
8
  end
9
9
 
10
- let(:repo) { RSpec.configuration.pulsar_conf_path }
11
- let(:options) { "--conf-repo #{repo}" }
12
- let(:arguments) { 'blog production' }
10
+ let(:repo) { RSpec.configuration.pulsar_conf_path }
11
+ let(:options) { "--conf-repo #{repo}" }
12
+ let(:app) { 'blog' }
13
+ let(:environment) { 'production' }
14
+ let(:arguments) { "#{app} #{environment}" }
13
15
 
14
16
  context 'via a subcommand named deploy' do
15
17
  let(:error) { /Could not find command/ }
@@ -37,8 +39,9 @@ RSpec.describe 'Deploy' do
37
39
  end
38
40
 
39
41
  context 'requires application and environment arguments' do
40
- let(:arguments) { nil }
41
- let(:error) { /Usage: "pulsar deploy APPLICATION ENVIRONMENT"/ }
42
+ let(:app) { nil }
43
+ let(:environment) { nil }
44
+ let(:error) { /Usage: "pulsar deploy APPLICATION ENVIRONMENT"/ }
42
45
 
43
46
  it { is_expected.to output(error).to_stderr_from_any_process }
44
47
  end
@@ -50,6 +53,12 @@ RSpec.describe 'Deploy' do
50
53
  let(:output) { "Deployed blog on production!\n" }
51
54
 
52
55
  context 'from a local folder' do
56
+ let(:repo) { Dir.mktmpdir }
57
+
58
+ before do
59
+ FileUtils.cp_r("#{RSpec.configuration.pulsar_conf_path}/.", repo)
60
+ end
61
+
53
62
  it { is_expected.to match(output) }
54
63
 
55
64
  context 'leaves the tmp folder empty' do
@@ -61,47 +70,11 @@ RSpec.describe 'Deploy' do
61
70
  end
62
71
  end
63
72
 
64
- context 'from a local repository' do
65
- let(:repo) { RSpec.configuration.pulsar_local_conf_repo_path }
66
-
67
- before do
68
- FileUtils.cp_r(RSpec.configuration.pulsar_conf_path, repo)
69
- `git init #{repo}`
70
- end
71
-
72
- context 'uncommitted changes' do
73
- it { is_expected.not_to match(output) }
74
-
75
- context 'leaves the tmp folder empty' do
76
- subject { Dir.glob("#{Pulsar::PULSAR_TMP}/*") }
77
-
78
- before { command }
79
-
80
- it { is_expected.to be_empty }
81
- end
82
- end
83
-
84
- context 'committed changes' do
85
- before do
86
- `git -C #{repo} add . && git -C #{repo} commit -m 'Initial Commit'`
87
- end
88
-
89
- it { is_expected.to match(output) }
90
-
91
- context 'leaves the tmp folder empty' do
92
- subject { Dir.glob("#{Pulsar::PULSAR_TMP}/*") }
93
-
94
- before { command }
95
-
96
- it { is_expected.to be_empty }
97
- end
98
- end
99
- end
100
-
101
73
  context 'from a remote Git repository' do
102
- let(:repo) { RSpec.configuration.pulsar_remote_git_conf }
103
- let(:arguments) { 'your_app staging' }
104
- let(:output) { "Deployed your_app on staging!\n" }
74
+ let(:repo) { RSpec.configuration.pulsar_remote_git_conf }
75
+ let(:app) { 'your_app' }
76
+ let(:environment) { 'staging' }
77
+ let(:output) { "Deployed your_app on staging!\n" }
105
78
 
106
79
  it { is_expected.to match(output) }
107
80
 
@@ -115,9 +88,10 @@ RSpec.describe 'Deploy' do
115
88
  end
116
89
 
117
90
  context 'from a remote GitHub repository' do
118
- let(:repo) { RSpec.configuration.pulsar_remote_github_conf }
119
- let(:arguments) { 'your_app staging' }
120
- let(:output) { "Deployed your_app on staging!\n" }
91
+ let(:repo) { RSpec.configuration.pulsar_remote_github_conf }
92
+ let(:app) { 'your_app' }
93
+ let(:environment) { 'staging' }
94
+ let(:output) { "Deployed your_app on staging!\n" }
121
95
 
122
96
  it { is_expected.to match(output) }
123
97
 
@@ -145,6 +119,7 @@ RSpec.describe 'Deploy' do
145
119
  let(:repo) { RSpec.configuration.pulsar_empty_conf_path }
146
120
 
147
121
  it { is_expected.to match("Failed to deploy blog on production.\n") }
122
+ it { is_expected.to match "No application found on repository #{RSpec.configuration.pulsar_empty_conf_path}\n" }
148
123
  end
149
124
 
150
125
  context 'because Bundler failed' do
@@ -158,5 +133,27 @@ RSpec.describe 'Deploy' do
158
133
 
159
134
  it { is_expected.to match("Failed to deploy blog on production.\n") }
160
135
  end
136
+
137
+ context 'because the application does not exists in the repository' do
138
+ let(:repo) { RSpec.configuration.pulsar_conf_path }
139
+ let(:app) { 'foobuzz' }
140
+ let(:environment) { 'staging' }
141
+
142
+ it { is_expected.to match("The application foobuzz does not exist in your repository") }
143
+ end
144
+
145
+ context 'because the environment does not exists for the application' do
146
+ let(:repo) { RSpec.configuration.pulsar_conf_path }
147
+ let(:app) { 'blog' }
148
+ let(:environment) { 'foobuzz' }
149
+
150
+ it { is_expected.to match("The application blog does not have an environment called foobuzz") }
151
+
152
+ context 'but \'no application error\' message takes precedence' do
153
+ let(:app) { 'foobuzz' }
154
+
155
+ it { is_expected.to match("The application foobuzz does not exist in your repository") }
156
+ end
157
+ end
161
158
  end
162
159
  end
@@ -4,7 +4,7 @@ RSpec.describe 'Install' do
4
4
  subject { command }
5
5
 
6
6
  let(:command) do
7
- `ruby #{RSpec.configuration.pulsar_command} install #{arguments}`
7
+ `#{RSpec.configuration.pulsar_command} install #{arguments}`
8
8
  end
9
9
 
10
10
  let(:arguments) { nil }
@@ -55,7 +55,7 @@ RSpec.describe 'Install' do
55
55
  context 'when fails' do
56
56
  let(:arguments) { '/pulsar-conf' }
57
57
 
58
- it { is_expected.to eql "Failed to create intial repo.\n" }
58
+ it { is_expected.to match "Failed to create intial repo.\n" }
59
59
 
60
60
  context 'does not create a directory' do
61
61
  subject { -> { command } }
@@ -4,7 +4,7 @@ RSpec.describe 'List' do
4
4
  subject { -> { command } }
5
5
 
6
6
  let(:command) do
7
- `ruby #{RSpec.configuration.pulsar_command} list #{arguments}`
7
+ `#{RSpec.configuration.pulsar_command} list #{arguments}`
8
8
  end
9
9
 
10
10
  let(:repo) { RSpec.configuration.pulsar_conf_path }
@@ -42,6 +42,12 @@ RSpec.describe 'List' do
42
42
  let(:output) { "blog: production, staging\necommerce: staging\n" }
43
43
 
44
44
  context 'from a local folder' do
45
+ let(:repo) { Dir.mktmpdir }
46
+
47
+ before do
48
+ FileUtils.cp_r("#{RSpec.configuration.pulsar_conf_path}/.", repo)
49
+ end
50
+
45
51
  it { is_expected.to eql(output) }
46
52
 
47
53
  context 'leaves the tmp folder empty' do
@@ -53,43 +59,6 @@ RSpec.describe 'List' do
53
59
  end
54
60
  end
55
61
 
56
- context 'from a local repository' do
57
- let(:repo) { RSpec.configuration.pulsar_local_conf_repo_path }
58
-
59
- before do
60
- FileUtils.cp_r(RSpec.configuration.pulsar_conf_path, repo)
61
- `git init #{repo}`
62
- end
63
-
64
- context 'uncommitted changes' do
65
- it { is_expected.not_to eql(output) }
66
-
67
- context 'leaves the tmp folder empty' do
68
- subject { Dir.glob("#{Pulsar::PULSAR_TMP}/*") }
69
-
70
- before { command }
71
-
72
- it { is_expected.to be_empty }
73
- end
74
- end
75
-
76
- context 'committed changes' do
77
- before do
78
- `git -C #{repo} add . && git -C #{repo} commit -m 'Initial Commit'`
79
- end
80
-
81
- it { is_expected.to eql(output) }
82
-
83
- context 'leaves the tmp folder empty' do
84
- subject { Dir.glob("#{Pulsar::PULSAR_TMP}/*") }
85
-
86
- before { command }
87
-
88
- it { is_expected.to be_empty }
89
- end
90
- end
91
- end
92
-
93
62
  context 'from a remote Git repository' do
94
63
  let(:repo) { RSpec.configuration.pulsar_remote_git_conf }
95
64
  let(:output) { "your_app: production, staging\n" }
@@ -128,13 +97,14 @@ RSpec.describe 'List' do
128
97
  context 'because of wrong directory' do
129
98
  let(:repo) { './some-wrong-directory' }
130
99
 
131
- it { is_expected.to eql "Failed to list application and environments.\n" }
100
+ it { is_expected.to match "Failed to list application and environments.\n" }
132
101
  end
133
102
 
134
103
  context 'because of empty directory' do
135
104
  let(:repo) { RSpec.configuration.pulsar_empty_conf_path }
136
105
 
137
- it { is_expected.to eql "Failed to list application and environments.\n" }
106
+ it { is_expected.to match "Failed to list application and environments.\n" }
107
+ it { is_expected.to match "No application found on repository #{RSpec.configuration.pulsar_empty_conf_path}\n" }
138
108
  end
139
109
  end
140
110
  end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe 'Version' do
4
+ subject { command }
5
+
6
+ let(:command) do
7
+ `#{RSpec.configuration.pulsar_command} #{arguments}`
8
+ end
9
+
10
+ let(:arguments) { "--version" }
11
+
12
+ context 'via a --version flag' do
13
+ let(:version) { "#{Pulsar::VERSION}\n" }
14
+
15
+ it { is_expected.to eql version }
16
+ end
17
+ end
@@ -2,6 +2,7 @@ require 'rspec'
2
2
  require 'stringio'
3
3
  require 'fileutils'
4
4
  require 'timecop'
5
+ require 'tmpdir'
5
6
  require 'codeclimate-test-reporter'
6
7
  require 'pulsar'
7
8
 
@@ -24,7 +25,7 @@ RSpec.configure do |config|
24
25
  config.add_setting :pulsar_remote_git_conf
25
26
  config.add_setting :pulsar_remote_github_conf
26
27
 
27
- config.pulsar_command = File.expand_path('./bin/pulsar')
28
+ config.pulsar_command = "ruby -Ilib #{File.expand_path('./exe/pulsar')}"
28
29
  config.pulsar_conf_path = File.expand_path('./spec/support/dummies/conf/dir')
29
30
  config.pulsar_empty_conf_path = File.expand_path('./spec/support/dummies/conf/empty')
30
31
  config.pulsar_wrong_cap_conf_path = File.expand_path('./spec/support/dummies/conf/wrong_cap')
@@ -27,10 +27,10 @@ RSpec.describe Pulsar::CLI do
27
27
  context 'success' do
28
28
  subject { -> { described_instance.list } }
29
29
 
30
- let(:applications) { 'blog: staging' }
30
+ let(:applications) { { 'blog' => %w(staging) } }
31
31
  let(:result) { spy(success?: true, applications: applications) }
32
32
 
33
- it { is_expected.to output(/#{applications}/).to_stdout }
33
+ it { is_expected.to output(/blog: staging/).to_stdout }
34
34
  end
35
35
 
36
36
  context 'failure' do
@@ -62,10 +62,10 @@ RSpec.describe Pulsar::CLI do
62
62
  context 'success' do
63
63
  subject { -> { described_instance.list } }
64
64
 
65
- let(:applications) { 'blog: staging' }
65
+ let(:applications) { { 'blog' => %w(staging) } }
66
66
  let(:result) { spy(success?: true, applications: applications) }
67
67
 
68
- it { is_expected.to output(/#{applications}/).to_stdout }
68
+ it { is_expected.to output(/blog: staging/).to_stdout }
69
69
  end
70
70
 
71
71
  context 'failure' do
@@ -89,10 +89,10 @@ RSpec.describe Pulsar::CLI do
89
89
  context 'success' do
90
90
  subject { -> { described_instance.list } }
91
91
 
92
- let(:applications) { 'blog: staging' }
92
+ let(:applications) { { 'blog' => %w(staging) } }
93
93
  let(:result) { spy(success?: true, applications: applications) }
94
94
 
95
- it { is_expected.to output(/#{applications}/).to_stdout }
95
+ it { is_expected.to output(/blog: staging/).to_stdout }
96
96
  end
97
97
 
98
98
  context 'failure' do
@@ -19,7 +19,7 @@ RSpec.describe Pulsar::AddApplications do
19
19
  context 'returns a list of applications and stages' do
20
20
  subject { described_class.call(config_path: './my-conf').applications }
21
21
 
22
- it { is_expected.to eql(['blog: production, staging']) }
22
+ it { is_expected.to eql('blog' => %w(production staging)) }
23
23
  end
24
24
  end
25
25
 
@@ -20,6 +20,7 @@ RSpec.describe Pulsar::CloneRepository do
20
20
  context 'success' do
21
21
  context 'when repository_type is :folder' do
22
22
  let(:type) { :folder }
23
+ let(:repo) { RSpec.configuration.pulsar_conf_path }
23
24
 
24
25
  before do
25
26
  expect(FileUtils).to receive(:cp_r).with("#{repo}/.", run_path).ordered
@@ -13,7 +13,10 @@ RSpec.describe Pulsar::CopyEnvironmentFile do
13
13
  let(:args) do
14
14
  {
15
15
  config_path: RSpec.configuration.pulsar_conf_path,
16
- cap_path: cap_path, application: 'blog', environment: 'production'
16
+ cap_path: cap_path,
17
+ applications: { 'blog' => %w(production staging) },
18
+ application: 'blog',
19
+ environment: 'production'
17
20
  }
18
21
  end
19
22
 
@@ -13,7 +13,7 @@ RSpec.describe Pulsar::CreateCapfile do
13
13
  let(:args) do
14
14
  {
15
15
  config_path: RSpec.configuration.pulsar_conf_path,
16
- cap_path: cap_path, application: 'blog'
16
+ cap_path: cap_path, application: 'blog', applications: { 'blog' => %w(staging) }
17
17
  }
18
18
  end
19
19
 
@@ -14,30 +14,14 @@ RSpec.describe Pulsar::IdentifyRepositoryType do
14
14
 
15
15
  context 'success' do
16
16
  context 'when local' do
17
- before do
18
- expect(Rake)
19
- .to receive(:sh).with("git -C #{repo} status >/dev/null 2>&1")
20
- end
21
-
22
17
  it { is_expected.to be_a_success }
23
18
 
24
19
  context 'the configuration repository' do
25
20
  subject { described_class.call(args).repository_type }
26
21
 
27
22
  context 'is a folder' do
28
- before { allow(Rake).to receive(:sh).and_return(false) }
29
-
30
23
  it { is_expected.to eql :folder }
31
24
  end
32
-
33
- context 'is a git repository' do
34
- before do
35
- allow(Rake).to receive(:sh).and_return(true)
36
- allow(File).to receive(:exist?).and_return(true)
37
- end
38
-
39
- it { is_expected.to eql :git }
40
- end
41
25
  end
42
26
  end
43
27
 
@@ -74,12 +58,6 @@ RSpec.describe Pulsar::IdentifyRepositoryType do
74
58
 
75
59
  it { is_expected.to be_a_failure }
76
60
  end
77
-
78
- context 'when an exception is triggered' do
79
- before { allow(Rake).to receive(:sh).and_raise(RuntimeError) }
80
-
81
- it { is_expected.to be_a_failure }
82
- end
83
61
  end
84
62
  end
85
63
  end
@@ -18,11 +18,11 @@ RSpec.describe Pulsar::RunBundleInstall do
18
18
  end
19
19
 
20
20
  before do
21
- allow(subject).to receive(:system)
21
+ allow(Rake).to receive(:sh).and_return(true)
22
22
  subject.run
23
23
  end
24
24
 
25
- it { is_expected.to have_received(:system).with(bundle_install_cmd) }
25
+ it { expect(Rake).to have_received(:sh).with(bundle_install_cmd) }
26
26
  end
27
27
 
28
28
  context 'failure' do
@@ -50,7 +50,7 @@ RSpec.describe Pulsar::RunBundleInstall do
50
50
  end
51
51
 
52
52
  before do
53
- allow(subject).to receive(:system).and_raise(RuntimeError)
53
+ allow(Rake).to receive(:sh).and_raise(RuntimeError)
54
54
  subject.run
55
55
  end
56
56
 
@@ -19,11 +19,11 @@ RSpec.describe Pulsar::RunCapistrano do
19
19
  end
20
20
 
21
21
  before do
22
- allow(subject).to receive(:system)
22
+ allow(Rake).to receive(:sh).and_return(true)
23
23
  subject.run
24
24
  end
25
25
 
26
- it { is_expected.to have_received(:system).with("#{bundle_cmd} #{cap_cmd}") }
26
+ it { expect(Rake).to have_received(:sh).with("#{bundle_cmd} #{cap_cmd}") }
27
27
  end
28
28
 
29
29
  context 'failure' do
@@ -14,6 +14,7 @@ RSpec.describe Pulsar::Deploy do
14
14
  Pulsar::IdentifyRepositoryType,
15
15
  Pulsar::CreateRunDirs,
16
16
  Pulsar::CloneRepository,
17
+ Pulsar::AddApplications,
17
18
  Pulsar::CreateCapfile,
18
19
  Pulsar::CreateDeployFile,
19
20
  Pulsar::CopyEnvironmentFile,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pulsar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matteo Latini
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-15 00:00:00.000000000 Z
11
+ date: 2017-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -153,8 +153,8 @@ files:
153
153
  - LICENSE.txt
154
154
  - README.md
155
155
  - Rakefile
156
- - bin/pulsar
157
156
  - circle.yml
157
+ - exe/pulsar
158
158
  - lib/pulsar.rb
159
159
  - lib/pulsar/cli.rb
160
160
  - lib/pulsar/constants.rb
@@ -188,6 +188,7 @@ files:
188
188
  - spec/features/deploy_spec.rb
189
189
  - spec/features/install_spec.rb
190
190
  - spec/features/list_spec.rb
191
+ - spec/features/version_spec.rb
191
192
  - spec/spec_helper.rb
192
193
  - spec/support/dummies/.gitkeep
193
194
  - spec/support/dummies/conf/dir/Gemfile
@@ -249,9 +250,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
249
250
  version: '0'
250
251
  required_rubygems_version: !ruby/object:Gem::Requirement
251
252
  requirements:
252
- - - ">"
253
+ - - ">="
253
254
  - !ruby/object:Gem::Version
254
- version: 1.3.1
255
+ version: '0'
255
256
  requirements: []
256
257
  rubyforge_project:
257
258
  rubygems_version: 2.6.8
@@ -264,6 +265,7 @@ test_files:
264
265
  - spec/features/deploy_spec.rb
265
266
  - spec/features/install_spec.rb
266
267
  - spec/features/list_spec.rb
268
+ - spec/features/version_spec.rb
267
269
  - spec/spec_helper.rb
268
270
  - spec/support/dummies/.gitkeep
269
271
  - spec/support/dummies/conf/dir/Gemfile