pulsar 0.3.5 → 1.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/.rubocop.yml +150 -0
- data/.ruby-version +1 -1
- data/LICENSE.txt +1 -1
- data/README.md +4 -265
- data/bin/pulsar +1 -1
- data/circle.yml +22 -0
- data/lib/pulsar.rb +28 -7
- data/lib/pulsar/cli.rb +79 -0
- data/lib/pulsar/constants.rb +5 -0
- data/lib/pulsar/generators/initial_repo/Gemfile +3 -0
- data/lib/pulsar/generators/{init_repo → initial_repo}/README.md +1 -1
- data/lib/pulsar/generators/initial_repo/apps/Capfile +8 -0
- data/lib/pulsar/generators/initial_repo/apps/deploy.rb +35 -0
- data/lib/pulsar/generators/initial_repo/apps/your_app/Capfile +18 -0
- data/lib/pulsar/generators/initial_repo/apps/your_app/deploy.rb +4 -0
- data/lib/pulsar/generators/initial_repo/apps/your_app/production.rb +3 -0
- data/lib/pulsar/generators/initial_repo/apps/your_app/staging.rb +3 -0
- data/lib/pulsar/generators/initial_repo/recipes/generic/rake.rake +12 -0
- data/lib/pulsar/generators/{init_repo/apps/your_app/recipes/production → initial_repo/recipes/rails}/.gitkeep +0 -0
- data/lib/pulsar/interactors/add_applications.rb +48 -0
- data/lib/pulsar/interactors/cleanup.rb +9 -0
- data/lib/pulsar/interactors/clone_repository.rb +50 -0
- data/lib/pulsar/interactors/copy_environment_file.rb +30 -0
- data/lib/pulsar/interactors/copy_initial_repository.rb +22 -0
- data/lib/pulsar/interactors/create_capfile.rb +32 -0
- data/lib/pulsar/interactors/create_deploy_file.rb +32 -0
- data/lib/pulsar/interactors/create_run_dirs.rb +21 -0
- data/lib/pulsar/interactors/identify_repository_location.rb +23 -0
- data/lib/pulsar/interactors/identify_repository_type.rb +34 -0
- data/lib/pulsar/interactors/run_bundle_install.rb +28 -0
- data/lib/pulsar/interactors/run_capistrano.rb +30 -0
- data/lib/pulsar/organizers/deploy.rb +16 -0
- data/lib/pulsar/organizers/install.rb +7 -0
- data/lib/pulsar/organizers/list.rb +12 -0
- data/lib/pulsar/version.rb +1 -1
- data/pulsar.gemspec +13 -11
- data/spec/features/deploy_spec.rb +162 -0
- data/spec/features/install_spec.rb +66 -0
- data/spec/features/list_spec.rb +140 -0
- data/spec/spec_helper.rb +26 -14
- data/{lib/pulsar/generators/init_repo/apps/your_app/recipes/staging → spec/support/dummies}/.gitkeep +0 -0
- data/spec/support/dummies/conf/dir/Gemfile +3 -0
- data/spec/support/dummies/conf/dir/apps/Capfile +9 -0
- data/spec/support/dummies/conf/dir/apps/blog/Capfile +1 -0
- data/spec/support/dummies/conf/dir/apps/blog/deploy.rb +4 -0
- data/spec/support/dummies/conf/dir/apps/blog/production.rb +4 -0
- data/spec/support/dummies/conf/dir/apps/blog/staging.rb +4 -0
- data/spec/support/dummies/conf/dir/apps/deploy.rb +1 -0
- data/{lib/pulsar/generators/init_repo/recipes/rails/.gitkeep → spec/support/dummies/conf/dir/apps/ecommerce/staging.rb} +0 -0
- data/spec/support/dummies/conf/dir/recipes/.gitkeep +0 -0
- data/spec/support/dummies/conf/dotenv +1 -0
- data/spec/support/dummies/conf/empty/apps/.gitkeep +0 -0
- data/spec/support/dummies/conf/empty/recipes/.gitkeep +0 -0
- data/spec/support/dummies/conf/wrong_bundle/Gemfile +3 -0
- data/spec/support/dummies/conf/wrong_bundle/apps/Capfile +9 -0
- data/spec/support/dummies/conf/wrong_bundle/apps/blog/Capfile +1 -0
- data/spec/support/dummies/conf/wrong_bundle/apps/blog/deploy.rb +4 -0
- data/spec/support/dummies/conf/wrong_bundle/apps/blog/production.rb +4 -0
- data/spec/support/dummies/conf/wrong_bundle/apps/deploy.rb +1 -0
- data/spec/support/dummies/conf/wrong_bundle/recipes/.gitkeep +0 -0
- data/spec/support/dummies/conf/wrong_cap/Gemfile +3 -0
- data/spec/support/dummies/conf/wrong_cap/apps/Capfile +0 -0
- data/spec/support/dummies/conf/wrong_cap/apps/blog/deploy.rb +4 -0
- data/spec/support/dummies/conf/wrong_cap/apps/blog/production.rb +4 -0
- data/spec/support/dummies/conf/wrong_cap/apps/deploy.rb +1 -0
- data/spec/support/dummies/conf/wrong_cap/recipes/.gitkeep +0 -0
- data/spec/units/cli/deploy_spec.rb +116 -0
- data/spec/units/cli/install_spec.rb +44 -0
- data/spec/units/cli/list_spec.rb +107 -0
- data/spec/units/constants_spec.rb +21 -0
- data/spec/units/interactors/add_applications_spec.rb +46 -0
- data/spec/units/interactors/cleanup_spec.rb +21 -0
- data/spec/units/interactors/clone_initial_repository_spec.rb +41 -0
- data/spec/units/interactors/clone_repository_spec.rb +122 -0
- data/spec/units/interactors/copy_environment_file_spec.rb +80 -0
- data/spec/units/interactors/create_capfile_spec.rb +77 -0
- data/spec/units/interactors/create_deploy_file_spec.rb +70 -0
- data/spec/units/interactors/create_run_dirs_spec.rb +47 -0
- data/spec/units/interactors/identify_repository_location_spec.rb +49 -0
- data/spec/units/interactors/identify_repository_type_spec.rb +85 -0
- data/spec/units/interactors/run_bundle_install_spec.rb +60 -0
- data/spec/units/interactors/run_capistrano_spec.rb +92 -0
- data/spec/units/organizers/deploy_spec.rb +28 -0
- data/spec/units/organizers/install_spec.rb +13 -0
- data/spec/units/organizers/list_spec.rb +24 -0
- metadata +179 -106
- data/.ruby-gemset +0 -1
- data/.travis.yml +0 -17
- data/bin/pulsar-utils +0 -5
- data/lib/pulsar/commands/all.rb +0 -6
- data/lib/pulsar/commands/init.rb +0 -23
- data/lib/pulsar/commands/list.rb +0 -19
- data/lib/pulsar/commands/main.rb +0 -64
- data/lib/pulsar/commands/utils.rb +0 -14
- data/lib/pulsar/generators/init_repo/Gemfile +0 -7
- data/lib/pulsar/generators/init_repo/apps/base.rb +0 -41
- data/lib/pulsar/generators/init_repo/apps/your_app/defaults.rb +0 -9
- data/lib/pulsar/generators/init_repo/apps/your_app/production.rb +0 -12
- data/lib/pulsar/generators/init_repo/apps/your_app/recipes/custom_recipe.rb +0 -14
- data/lib/pulsar/generators/init_repo/apps/your_app/staging.rb +0 -12
- data/lib/pulsar/generators/init_repo/recipes/generic/cleanup.rb +0 -50
- data/lib/pulsar/generators/init_repo/recipes/generic/utils.rb +0 -9
- data/lib/pulsar/helpers/all.rb +0 -8
- data/lib/pulsar/helpers/capistrano.rb +0 -47
- data/lib/pulsar/helpers/clamp.rb +0 -223
- data/lib/pulsar/helpers/path.rb +0 -71
- data/lib/pulsar/helpers/shell.rb +0 -31
- data/lib/pulsar/options/all.rb +0 -6
- data/lib/pulsar/options/conf_repo.rb +0 -41
- data/lib/pulsar/options/shared.rb +0 -15
- data/spec/pulsar/commands/init_spec.rb +0 -10
- data/spec/pulsar/commands/list_spec.rb +0 -127
- data/spec/pulsar/commands/main_spec.rb +0 -360
- data/spec/pulsar/commands/utils_spec.rb +0 -33
- data/spec/pulsar/helpers/capistrano_spec.rb +0 -70
- data/spec/pulsar/helpers/clamp_spec.rb +0 -105
- data/spec/pulsar/helpers/shell_spec.rb +0 -11
- data/spec/support/dummies/dummy_app/config.ru +0 -3
- data/spec/support/dummies/dummy_conf/Gemfile +0 -4
- data/spec/support/dummies/dummy_conf/apps/base.rb +0 -46
- data/spec/support/dummies/dummy_conf/apps/dummy_app/custom_stage.rb +0 -5
- data/spec/support/dummies/dummy_conf/apps/dummy_app/defaults.rb +0 -7
- data/spec/support/dummies/dummy_conf/apps/dummy_app/production.rb +0 -5
- data/spec/support/dummies/dummy_conf/apps/dummy_app/recipes/custom_recipe.rb +0 -1
- data/spec/support/dummies/dummy_conf/apps/dummy_app/recipes/production/custom_recipe.rb +0 -1
- data/spec/support/dummies/dummy_conf/apps/dummy_app/recipes/staging/custom_recipe.rb +0 -1
- data/spec/support/dummies/dummy_conf/apps/dummy_app/staging.rb +0 -5
- data/spec/support/dummies/dummy_conf/apps/other_dummy_app/custom_stage.rb +0 -5
- data/spec/support/dummies/dummy_conf/apps/other_dummy_app/defaults.rb +0 -7
- data/spec/support/dummies/dummy_conf/apps/other_dummy_app/production.rb +0 -5
- data/spec/support/dummies/dummy_conf/apps/other_dummy_app/staging.rb +0 -5
- data/spec/support/dummies/dummy_conf/recipes/generic/recipe.rb +0 -3
- data/spec/support/modules/helpers.rb +0 -85
- data/spec/support/modules/output_capture.rb +0 -21
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Pulsar::CreateCapfile do
|
4
|
+
subject { described_class.new }
|
5
|
+
|
6
|
+
it { is_expected.to be_kind_of(Interactor) }
|
7
|
+
|
8
|
+
describe '.call' do
|
9
|
+
subject { command }
|
10
|
+
|
11
|
+
let(:command) { described_class.call(args) }
|
12
|
+
let(:cap_path) { "#{Pulsar::PULSAR_TMP}/cap-path" }
|
13
|
+
let(:args) do
|
14
|
+
{
|
15
|
+
config_path: RSpec.configuration.pulsar_conf_path,
|
16
|
+
cap_path: cap_path, application: 'blog'
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
before { FileUtils.mkdir_p(cap_path) }
|
21
|
+
|
22
|
+
context 'success' do
|
23
|
+
it { is_expected.to be_a_success }
|
24
|
+
|
25
|
+
context 'creates a Capfile' do
|
26
|
+
subject { File }
|
27
|
+
|
28
|
+
it { is_expected.to exist(command.capfile_path) }
|
29
|
+
|
30
|
+
context 'with the required Capistrano path' do
|
31
|
+
subject { command.capfile_path }
|
32
|
+
|
33
|
+
it { is_expected.to eql "#{cap_path}/Capfile" }
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'with contents combined from pulsar configuration repo' do
|
37
|
+
subject { File.read(command.capfile_path) }
|
38
|
+
|
39
|
+
let(:load_recipes) do
|
40
|
+
"Dir.glob(\"#{RSpec.configuration.pulsar_conf_path}/recipes/**/*.rake\").each { |r| import r }"
|
41
|
+
end
|
42
|
+
|
43
|
+
it { is_expected.to match(/# Defaults Capfile.*# App Defaults Capfile/m) }
|
44
|
+
it { is_expected.to include(load_recipes) }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'failure' do
|
50
|
+
context 'when no config_path context is passed' do
|
51
|
+
subject { described_class.call }
|
52
|
+
|
53
|
+
it { is_expected.to be_a_failure }
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when no application context is passed' do
|
57
|
+
subject { described_class.call(config_path: './my-conf') }
|
58
|
+
|
59
|
+
it { is_expected.to be_a_failure }
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'when no cap_path context is passed' do
|
63
|
+
subject do
|
64
|
+
described_class.call(config_path: './my-conf', application: 'blog')
|
65
|
+
end
|
66
|
+
|
67
|
+
it { is_expected.to be_a_failure }
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'when an exception is triggered' do
|
71
|
+
before { allow(FileUtils).to receive(:touch).and_raise(RuntimeError) }
|
72
|
+
|
73
|
+
it { is_expected.to be_a_failure }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Pulsar::CreateDeployFile do
|
4
|
+
subject { described_class.new }
|
5
|
+
|
6
|
+
it { is_expected.to be_kind_of(Interactor) }
|
7
|
+
|
8
|
+
describe '.call' do
|
9
|
+
subject { command }
|
10
|
+
|
11
|
+
let(:command) { described_class.call(args) }
|
12
|
+
let(:cap_path) { "#{Pulsar::PULSAR_TMP}/cap-path" }
|
13
|
+
let(:args) do
|
14
|
+
{
|
15
|
+
config_path: RSpec.configuration.pulsar_conf_path,
|
16
|
+
cap_path: cap_path, application: 'blog'
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'success' do
|
21
|
+
it { is_expected.to be_a_success }
|
22
|
+
|
23
|
+
context 'creates a Capfile' do
|
24
|
+
subject { File }
|
25
|
+
|
26
|
+
it { is_expected.to exist(command.deploy_file_path) }
|
27
|
+
|
28
|
+
context 'with the required Capistrano path' do
|
29
|
+
subject { command.deploy_file_path }
|
30
|
+
|
31
|
+
it { is_expected.to eql "#{cap_path}/config/deploy.rb" }
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'with contents combined from pulsar configuration repo' do
|
35
|
+
subject { File.read(command.deploy_file_path) }
|
36
|
+
|
37
|
+
it { is_expected.to match(/# Defaults deployrb\n# App Defaults deployrb/) }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'failure' do
|
43
|
+
context 'when no config_path context is passed' do
|
44
|
+
subject { described_class.call }
|
45
|
+
|
46
|
+
it { is_expected.to be_a_failure }
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when no application context is passed' do
|
50
|
+
subject { described_class.call(config_path: './my-conf') }
|
51
|
+
|
52
|
+
it { is_expected.to be_a_failure }
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'when no cap_path context is passed' do
|
56
|
+
subject do
|
57
|
+
described_class.call(config_path: './my-conf', application: 'blog')
|
58
|
+
end
|
59
|
+
|
60
|
+
it { is_expected.to be_a_failure }
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'when an exception is triggered' do
|
64
|
+
before { allow(FileUtils).to receive(:touch).and_raise(RuntimeError) }
|
65
|
+
|
66
|
+
it { is_expected.to be_a_failure }
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Pulsar::CreateRunDirs do
|
4
|
+
subject { described_class.new }
|
5
|
+
|
6
|
+
it { is_expected.to be_kind_of(Interactor) }
|
7
|
+
|
8
|
+
describe '.success' do
|
9
|
+
around do |example|
|
10
|
+
Timecop.freeze { example.run }
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'uses a timestamp' do
|
14
|
+
subject { described_class.call.timestamp }
|
15
|
+
|
16
|
+
it { is_expected.to eql Time.now.to_f }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'creates some folders' do
|
20
|
+
subject { File }
|
21
|
+
|
22
|
+
let(:command) { described_class.call }
|
23
|
+
|
24
|
+
it { is_expected.to be_directory("#{Pulsar::PULSAR_HOME}/bundle") }
|
25
|
+
it { is_expected.to be_directory(command.bundle_path) }
|
26
|
+
it { is_expected.to be_directory(command.run_path) }
|
27
|
+
it { is_expected.to be_directory(command.config_path) }
|
28
|
+
it { is_expected.to be_directory(command.cap_path) }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '.rollback' do
|
33
|
+
subject { FileUtils }
|
34
|
+
|
35
|
+
let(:run_path) { '~/.pulsar/tmp/run' }
|
36
|
+
|
37
|
+
before do
|
38
|
+
allow(subject).to receive(:rm_rf)
|
39
|
+
allow_any_instance_of(Interactor::Context)
|
40
|
+
.to receive(:run_path).and_return(run_path)
|
41
|
+
|
42
|
+
described_class.new.rollback
|
43
|
+
end
|
44
|
+
|
45
|
+
it { is_expected.to have_received(:rm_rf).with(run_path) }
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Pulsar::IdentifyRepositoryLocation do
|
4
|
+
subject { described_class.new }
|
5
|
+
|
6
|
+
it { is_expected.to be_kind_of(Interactor) }
|
7
|
+
|
8
|
+
describe '.call' do
|
9
|
+
subject { described_class.call(repository: repo) }
|
10
|
+
|
11
|
+
let(:repo) { './my-conf' }
|
12
|
+
|
13
|
+
context 'success' do
|
14
|
+
before { allow(File).to receive(:exist?) }
|
15
|
+
|
16
|
+
it { is_expected.to be_a_success }
|
17
|
+
|
18
|
+
context 'when the repository' do
|
19
|
+
subject { described_class.call(repository: repo).repository_location }
|
20
|
+
|
21
|
+
context 'is a local folder' do
|
22
|
+
before { allow(File).to receive(:exist?).and_return(true) }
|
23
|
+
|
24
|
+
it { is_expected.to eql :local }
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'is a local git repository' do
|
28
|
+
before { allow(File).to receive(:exist?).and_return(false) }
|
29
|
+
|
30
|
+
it { is_expected.to eql :remote }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'failure' do
|
36
|
+
context 'when no repository context is passed' do
|
37
|
+
subject { described_class.call }
|
38
|
+
|
39
|
+
it { is_expected.to be_a_failure }
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when an exception is triggered' do
|
43
|
+
before { allow(File).to receive(:exist?).and_raise(RuntimeError) }
|
44
|
+
|
45
|
+
it { is_expected.to be_a_failure }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Pulsar::IdentifyRepositoryType do
|
4
|
+
subject { described_class.new }
|
5
|
+
|
6
|
+
it { is_expected.to be_kind_of(Interactor) }
|
7
|
+
|
8
|
+
describe '.call' do
|
9
|
+
subject { described_class.call(args) }
|
10
|
+
|
11
|
+
let(:repo) { './my-conf' }
|
12
|
+
let(:location) { :local }
|
13
|
+
let(:args) { { repository: repo, repository_location: location } }
|
14
|
+
|
15
|
+
context 'success' do
|
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
|
+
it { is_expected.to be_a_success }
|
23
|
+
|
24
|
+
context 'the configuration repository' do
|
25
|
+
subject { described_class.call(args).repository_type }
|
26
|
+
|
27
|
+
context 'is a folder' do
|
28
|
+
before { allow(Rake).to receive(:sh).and_return(false) }
|
29
|
+
|
30
|
+
it { is_expected.to eql :folder }
|
31
|
+
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
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'when remote' do
|
45
|
+
let(:location) { :remote }
|
46
|
+
|
47
|
+
it { is_expected.to be_a_success }
|
48
|
+
|
49
|
+
context 'the configuration repository' do
|
50
|
+
subject { described_class.call(args).repository_type }
|
51
|
+
|
52
|
+
context 'is a git repository' do
|
53
|
+
it { is_expected.to eql :git }
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'is a GitHub repository' do
|
57
|
+
let(:repo) { 'github-account/my-conf' }
|
58
|
+
|
59
|
+
it { is_expected.to eql :github }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'failure' do
|
66
|
+
context 'when no repository context is passed' do
|
67
|
+
subject { described_class.call(repository_location: :local) }
|
68
|
+
|
69
|
+
it { is_expected.to be_a_failure }
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'when no repository_location context is passed' do
|
73
|
+
subject { described_class.call(repository: repo) }
|
74
|
+
|
75
|
+
it { is_expected.to be_a_failure }
|
76
|
+
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
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Pulsar::RunBundleInstall do
|
4
|
+
subject { described_class.new }
|
5
|
+
|
6
|
+
it { is_expected.to be_kind_of(Interactor) }
|
7
|
+
|
8
|
+
describe '.success' do
|
9
|
+
subject do
|
10
|
+
described_class.new(config_path: './config-path', bundle_path: './bundle-path')
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:bundle_env) do
|
14
|
+
'BUNDLE_GEMFILE=./config-path/Gemfile BUNDLE_PATH=./bundle-path'
|
15
|
+
end
|
16
|
+
let(:bundle_install_cmd) do
|
17
|
+
"#{bundle_env} bundle check || #{bundle_env} bundle install"
|
18
|
+
end
|
19
|
+
|
20
|
+
before do
|
21
|
+
allow(subject).to receive(:system)
|
22
|
+
subject.run
|
23
|
+
end
|
24
|
+
|
25
|
+
it { is_expected.to have_received(:system).with(bundle_install_cmd) }
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'failure' do
|
29
|
+
context 'when no context is passed' do
|
30
|
+
subject { described_class.call }
|
31
|
+
|
32
|
+
it { is_expected.to be_a_failure }
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'when no config_path context is passed' do
|
36
|
+
subject { described_class.call(bundle_path: './some-path') }
|
37
|
+
|
38
|
+
it { is_expected.to be_a_failure }
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'when no bundle_path context is passed' do
|
42
|
+
subject { described_class.call(config_path: './some-path') }
|
43
|
+
|
44
|
+
it { is_expected.to be_a_failure }
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'when an exception is triggered' do
|
48
|
+
subject do
|
49
|
+
described_class.new(config_path: './config-path', bundle_path: './bundle-path')
|
50
|
+
end
|
51
|
+
|
52
|
+
before do
|
53
|
+
allow(subject).to receive(:system).and_raise(RuntimeError)
|
54
|
+
subject.run
|
55
|
+
end
|
56
|
+
|
57
|
+
it { expect(subject.context).to be_a_failure }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Pulsar::RunCapistrano do
|
4
|
+
subject { described_class.new }
|
5
|
+
|
6
|
+
it { is_expected.to be_kind_of(Interactor) }
|
7
|
+
|
8
|
+
describe '.success' do
|
9
|
+
subject do
|
10
|
+
described_class.new(
|
11
|
+
cap_path: RSpec.configuration.pulsar_conf_path, config_path: './config-path',
|
12
|
+
bundle_path: './bundle-path', environment: 'production'
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:cap_cmd) { "cap production deploy" }
|
17
|
+
let(:bundle_cmd) do
|
18
|
+
"BUNDLE_GEMFILE=./config-path/Gemfile BUNDLE_PATH=./bundle-path bundle exec"
|
19
|
+
end
|
20
|
+
|
21
|
+
before do
|
22
|
+
allow(subject).to receive(:system)
|
23
|
+
subject.run
|
24
|
+
end
|
25
|
+
|
26
|
+
it { is_expected.to have_received(:system).with("#{bundle_cmd} #{cap_cmd}") }
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'failure' do
|
30
|
+
context 'when no context is passed' do
|
31
|
+
subject { described_class.call }
|
32
|
+
|
33
|
+
it { is_expected.to be_a_failure }
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'when no cap_path context is passed' do
|
37
|
+
subject do
|
38
|
+
described_class.call(
|
39
|
+
config_path: './config-path', bundle_path: './bundle-path',
|
40
|
+
environment: 'production'
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
it { is_expected.to be_a_failure }
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'when no environment context is passed' do
|
48
|
+
subject do
|
49
|
+
described_class.call(
|
50
|
+
cap_path: './cap-path', config_path: './config-path',
|
51
|
+
bundle_path: './bundle-path'
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
it { is_expected.to be_a_failure }
|
56
|
+
end
|
57
|
+
context 'when no bundle_path context is passed' do
|
58
|
+
subject do
|
59
|
+
described_class.call(
|
60
|
+
cap_path: './cap-path', config_path: './config-path',
|
61
|
+
environment: 'production'
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
it { is_expected.to be_a_failure }
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'when no config_path context is passed' do
|
69
|
+
subject do
|
70
|
+
described_class.call(
|
71
|
+
cap_path: './cap-path', environment: 'production',
|
72
|
+
bundle_path: './bundle-path'
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
it { is_expected.to be_a_failure }
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'when an exception is triggered' do
|
80
|
+
subject do
|
81
|
+
described_class.call(
|
82
|
+
cap_path: './cap-path', config_path: './config-path',
|
83
|
+
bundle_path: './bundle-path', environment: 'production'
|
84
|
+
)
|
85
|
+
end
|
86
|
+
|
87
|
+
before { allow(Dir).to receive(:chdir).and_raise(RuntimeError) }
|
88
|
+
|
89
|
+
it { is_expected.to be_a_failure }
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|