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,140 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'List' do
|
4
|
+
subject { -> { command } }
|
5
|
+
|
6
|
+
let(:command) do
|
7
|
+
`ruby #{RSpec.configuration.pulsar_command} list #{arguments}`
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:repo) { RSpec.configuration.pulsar_conf_path }
|
11
|
+
let(:arguments) { "--conf-repo #{repo}" }
|
12
|
+
|
13
|
+
context 'via a subcommand named list' do
|
14
|
+
let(:error) { /Could not find command/ }
|
15
|
+
|
16
|
+
it { is_expected.not_to output(error).to_stderr_from_any_process }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'requires a --conf-repo option' do
|
20
|
+
let(:arguments) { nil }
|
21
|
+
let(:error) { /No value provided for required options '--conf-repo'/ }
|
22
|
+
|
23
|
+
it { is_expected.to output(error).to_stderr_from_any_process }
|
24
|
+
|
25
|
+
context 'can be specified via the alias -c' do
|
26
|
+
let(:arguments) { "-c #{repo}" }
|
27
|
+
|
28
|
+
it { is_expected.not_to output(error).to_stderr_from_any_process }
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'can be specified via the environment variable PULSAR_CONF_REPO' do
|
32
|
+
before { ENV['PULSAR_CONF_REPO'] = repo }
|
33
|
+
|
34
|
+
it { is_expected.not_to output(error).to_stderr_from_any_process }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when succeeds' do
|
39
|
+
subject { command }
|
40
|
+
|
41
|
+
context 'lists applications in the pulsar configuration' do
|
42
|
+
let(:output) { "blog: production, staging\necommerce: staging\n" }
|
43
|
+
|
44
|
+
context 'from a local folder' do
|
45
|
+
it { is_expected.to eql(output) }
|
46
|
+
|
47
|
+
context 'leaves the tmp folder empty' do
|
48
|
+
subject { Dir.glob("#{Pulsar::PULSAR_TMP}/*") }
|
49
|
+
|
50
|
+
before { command }
|
51
|
+
|
52
|
+
it { is_expected.to be_empty }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
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
|
+
context 'from a remote Git repository' do
|
94
|
+
let(:repo) { RSpec.configuration.pulsar_remote_git_conf }
|
95
|
+
let(:output) { "your_app: production, staging\n" }
|
96
|
+
|
97
|
+
it { is_expected.to eql output }
|
98
|
+
|
99
|
+
context 'leaves the tmp folder empty' do
|
100
|
+
subject { Dir.glob("#{Pulsar::PULSAR_TMP}/*") }
|
101
|
+
|
102
|
+
before { command }
|
103
|
+
|
104
|
+
it { is_expected.to be_empty }
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context 'from a remote GitHub repository' do
|
109
|
+
let(:repo) { RSpec.configuration.pulsar_remote_github_conf }
|
110
|
+
let(:output) { "your_app: production, staging\n" }
|
111
|
+
|
112
|
+
it { is_expected.to eql output }
|
113
|
+
|
114
|
+
context 'leaves the tmp folder empty' do
|
115
|
+
subject { Dir.glob("#{Pulsar::PULSAR_TMP}/*") }
|
116
|
+
|
117
|
+
before { command }
|
118
|
+
|
119
|
+
it { is_expected.to be_empty }
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
context 'when fails' do
|
126
|
+
subject { command }
|
127
|
+
|
128
|
+
context 'because of wrong directory' do
|
129
|
+
let(:repo) { './some-wrong-directory' }
|
130
|
+
|
131
|
+
it { is_expected.to eql "Failed to list application and environments.\n" }
|
132
|
+
end
|
133
|
+
|
134
|
+
context 'because of empty directory' do
|
135
|
+
let(:repo) { RSpec.configuration.pulsar_empty_conf_path }
|
136
|
+
|
137
|
+
it { is_expected.to eql "Failed to list application and environments.\n" }
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,37 +1,49 @@
|
|
1
1
|
require 'rspec'
|
2
2
|
require 'stringio'
|
3
3
|
require 'fileutils'
|
4
|
+
require 'timecop'
|
4
5
|
require 'codeclimate-test-reporter'
|
5
6
|
require 'pulsar'
|
6
|
-
require 'pulsar/commands/main'
|
7
|
-
require 'pulsar/commands/utils'
|
8
7
|
|
9
8
|
#
|
10
9
|
# Code coverage
|
11
10
|
#
|
12
11
|
CodeClimate::TestReporter.start
|
13
12
|
|
14
|
-
#
|
15
|
-
# Require all helper modules
|
16
|
-
#
|
17
|
-
Dir[File.join(File.dirname(__FILE__), 'support/modules/**/*.rb')].each do |f|
|
18
|
-
require f
|
19
|
-
end
|
20
|
-
|
21
13
|
RSpec.configure do |config|
|
22
14
|
config.mock_with :rspec
|
23
15
|
config.raise_errors_for_deprecations!
|
24
16
|
|
25
|
-
config.
|
26
|
-
config.
|
17
|
+
config.add_setting :pulsar_command
|
18
|
+
config.add_setting :pulsar_conf_path
|
19
|
+
config.add_setting :pulsar_empty_conf_path
|
20
|
+
config.add_setting :pulsar_wrong_cap_conf_path
|
21
|
+
config.add_setting :pulsar_wrong_bundle_conf_path
|
22
|
+
config.add_setting :pulsar_dotenv_conf_path
|
23
|
+
config.add_setting :pulsar_local_conf_repo_path
|
24
|
+
config.add_setting :pulsar_remote_git_conf
|
25
|
+
config.add_setting :pulsar_remote_github_conf
|
26
|
+
|
27
|
+
config.pulsar_command = File.expand_path('./bin/pulsar')
|
28
|
+
config.pulsar_conf_path = File.expand_path('./spec/support/dummies/conf/dir')
|
29
|
+
config.pulsar_empty_conf_path = File.expand_path('./spec/support/dummies/conf/empty')
|
30
|
+
config.pulsar_wrong_cap_conf_path = File.expand_path('./spec/support/dummies/conf/wrong_cap')
|
31
|
+
config.pulsar_wrong_bundle_conf_path = File.expand_path('./spec/support/dummies/conf/wrong_bundle')
|
32
|
+
config.pulsar_dotenv_conf_path = File.expand_path('./spec/support/dummies/conf/dotenv')
|
33
|
+
config.pulsar_local_conf_repo_path = File.expand_path('./spec/support/tmp/dummy-repo')
|
34
|
+
config.pulsar_remote_git_conf = 'git@github.com:nebulab/pulsar-conf-demo.git'
|
35
|
+
config.pulsar_remote_github_conf = 'nebulab/pulsar-conf-demo'
|
36
|
+
|
37
|
+
config.before(:suite) do
|
38
|
+
Dir.chdir('./spec/support/tmp')
|
39
|
+
end
|
27
40
|
|
28
41
|
config.before(:each) do
|
29
|
-
|
30
|
-
ENV.delete(variable.to_s)
|
31
|
-
end
|
42
|
+
ENV.delete_if { |name, _| name =~ /^PULSAR_/ }
|
32
43
|
end
|
33
44
|
|
34
45
|
config.after(:each) do
|
35
46
|
FileUtils.rm_rf(Dir.glob("#{File.dirname(__FILE__)}/support/tmp/*"))
|
47
|
+
FileUtils.rm_rf(Dir.glob("#{Pulsar::PULSAR_TMP}/*"))
|
36
48
|
end
|
37
49
|
end
|
data/{lib/pulsar/generators/init_repo/apps/your_app/recipes/staging → spec/support/dummies}/.gitkeep
RENAMED
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
# App Defaults Capfile
|
@@ -0,0 +1 @@
|
|
1
|
+
# Defaults deployrb
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
PULSAR_CONF_REPO=./conf_repo
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
# App Defaults Capfile
|
@@ -0,0 +1 @@
|
|
1
|
+
# Defaults deployrb
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
# Defaults deployrb
|
File without changes
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Pulsar::CLI do
|
4
|
+
subject { Pulsar::Deploy }
|
5
|
+
|
6
|
+
let(:described_instance) { described_class.new }
|
7
|
+
let(:fail_text) { /Failed to deploy blog on production./ }
|
8
|
+
|
9
|
+
context '#deploy' do
|
10
|
+
let(:result) { spy }
|
11
|
+
let(:repo) { './conf_repo' }
|
12
|
+
|
13
|
+
before do
|
14
|
+
allow($stdout).to receive(:puts)
|
15
|
+
allow(Pulsar::Deploy).to receive(:call).and_return(result)
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when using --conf-repo' do
|
19
|
+
before do
|
20
|
+
allow(described_instance)
|
21
|
+
.to receive(:options).and_return(conf_repo: repo)
|
22
|
+
described_instance.deploy('blog', 'production')
|
23
|
+
end
|
24
|
+
|
25
|
+
specify do
|
26
|
+
is_expected.to have_received(:call)
|
27
|
+
.with(repository: repo, application: 'blog', environment: 'production')
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'success' do
|
31
|
+
subject { -> { described_instance.deploy('blog', 'production') } }
|
32
|
+
|
33
|
+
let(:success) { "Deployed blog on production!" }
|
34
|
+
let(:result) { spy(success?: true) }
|
35
|
+
|
36
|
+
it { is_expected.to output(/#{success}/).to_stdout }
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'failure' do
|
40
|
+
subject { -> { described_instance.deploy('blog', 'production') } }
|
41
|
+
|
42
|
+
let(:result) { spy(success?: false) }
|
43
|
+
|
44
|
+
it { is_expected.to output(fail_text).to_stdout }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'when using configuration file' do
|
49
|
+
before do
|
50
|
+
allow(described_instance).to receive(:options).and_return({})
|
51
|
+
described_instance.deploy('blog', 'production')
|
52
|
+
end
|
53
|
+
|
54
|
+
around do |example|
|
55
|
+
old_const = Pulsar::PULSAR_CONF
|
56
|
+
Pulsar.send(:remove_const, 'PULSAR_CONF')
|
57
|
+
Pulsar::PULSAR_CONF = RSpec.configuration.pulsar_dotenv_conf_path
|
58
|
+
example.run
|
59
|
+
Pulsar.send(:remove_const, 'PULSAR_CONF')
|
60
|
+
Pulsar::PULSAR_CONF = old_const
|
61
|
+
end
|
62
|
+
|
63
|
+
specify do
|
64
|
+
is_expected.to have_received(:call)
|
65
|
+
.with(repository: repo, application: 'blog', environment: 'production')
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'success' do
|
69
|
+
subject { -> { described_instance.deploy('blog', 'production') } }
|
70
|
+
|
71
|
+
let(:success) { "Deployed blog on production!" }
|
72
|
+
let(:result) { spy(success?: true) }
|
73
|
+
|
74
|
+
it { is_expected.to output(/#{success}/).to_stdout }
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'failure' do
|
78
|
+
subject { -> { described_instance.deploy('blog', 'production') } }
|
79
|
+
|
80
|
+
let(:result) { spy(success?: false) }
|
81
|
+
|
82
|
+
it { is_expected.to output(fail_text).to_stdout }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context 'when using PULSAR_CONF_REPO' do
|
87
|
+
before do
|
88
|
+
allow(described_instance).to receive(:options).and_return({})
|
89
|
+
ENV['PULSAR_CONF_REPO'] = repo
|
90
|
+
described_instance.deploy('blog', 'production')
|
91
|
+
end
|
92
|
+
|
93
|
+
specify do
|
94
|
+
is_expected.to have_received(:call)
|
95
|
+
.with(repository: repo, application: 'blog', environment: 'production')
|
96
|
+
end
|
97
|
+
|
98
|
+
context 'success' do
|
99
|
+
subject { -> { described_instance.deploy('blog', 'production') } }
|
100
|
+
|
101
|
+
let(:success) { "Deployed blog on production!" }
|
102
|
+
let(:result) { spy(success?: true) }
|
103
|
+
|
104
|
+
it { is_expected.to output(/#{success}/).to_stdout }
|
105
|
+
end
|
106
|
+
|
107
|
+
context 'failure' do
|
108
|
+
subject { -> { described_instance.deploy('blog', 'production') } }
|
109
|
+
|
110
|
+
let(:result) { spy(success?: false) }
|
111
|
+
|
112
|
+
it { is_expected.to output(fail_text).to_stdout }
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Pulsar::CLI do
|
4
|
+
subject { Pulsar::Install }
|
5
|
+
|
6
|
+
let(:described_instance) { described_class.new }
|
7
|
+
|
8
|
+
context '#install' do
|
9
|
+
let(:result) { spy }
|
10
|
+
|
11
|
+
before do
|
12
|
+
allow(Pulsar::Install).to receive(:call).and_return(result)
|
13
|
+
allow($stdout).to receive(:puts)
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'calls Pulsar::Install with ./pulsar-conf by default' do
|
17
|
+
before { described_instance.install }
|
18
|
+
|
19
|
+
it { is_expected.to have_received(:call).with(directory: './pulsar-conf') }
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'calls Pulsar::Install with an argument' do
|
23
|
+
before { described_instance.install('./a-dir') }
|
24
|
+
|
25
|
+
it { is_expected.to have_received(:call).with(directory: './a-dir') }
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'success' do
|
29
|
+
subject { -> { described_instance.install } }
|
30
|
+
|
31
|
+
let(:result) { spy(success?: true) }
|
32
|
+
|
33
|
+
it { is_expected.to output(/Successfully created intial repo!/).to_stdout }
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'failure' do
|
37
|
+
subject { -> { described_instance.install } }
|
38
|
+
|
39
|
+
let(:result) { spy(success?: false) }
|
40
|
+
|
41
|
+
it { is_expected.to output(/Failed to create intial repo./).to_stdout }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|