bebox 0.1.0 → 0.1.1
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/Gemfile.lock +11 -1
- data/README.md +1 -0
- data/bebox.gemspec +2 -0
- data/lib/bebox/node.rb +1 -1
- data/lib/bebox/provision.rb +0 -32
- data/lib/bebox/vagrant_helper.rb +6 -4
- data/lib/bebox/version.rb +1 -1
- data/lib/bebox/wizards/environment_wizard.rb +4 -2
- data/lib/bebox/wizards/node_wizard.rb +9 -4
- data/lib/bebox/wizards/profile_wizard.rb +4 -2
- data/lib/bebox/wizards/project_wizard.rb +4 -3
- data/lib/bebox/wizards/provision_wizard.rb +6 -2
- data/lib/bebox/wizards/role_wizard.rb +14 -9
- data/lib/bebox/wizards/wizards_helper.rb +1 -0
- data/spec/environment_spec.rb +35 -18
- data/spec/factories/environment.rb +0 -12
- data/spec/factories/node.rb +0 -6
- data/spec/factories/project.rb +1 -7
- data/spec/fixtures/dot_bebox.test.erb +1 -1
- data/spec/node0.server1.test/prepare_phase_spec.rb +1 -1
- data/spec/node0.server1.test/provision_step_0_spec.rb +1 -1
- data/spec/node0.server1.test/provision_step_1_spec.rb +1 -1
- data/spec/node0.server1.test/provision_step_2_spec.rb +1 -1
- data/spec/node0.server1.test/provision_step_3_spec.rb +1 -1
- data/spec/node_role_spec.rb +7 -1
- data/spec/node_spec.rb +55 -17
- data/spec/ordered_phases_spec.rb +7 -3
- data/spec/pre_prepare_spec.rb +12 -9
- data/spec/pre_provision_steps_spec.rb +1 -1
- data/spec/profile_spec.rb +21 -8
- data/spec/project_spec.rb +54 -48
- data/spec/role_profiles_spec.rb +1 -1
- data/spec/role_spec.rb +40 -7
- data/spec/spec_helper.rb +20 -2
- data/spec/wizards/environment_wizard_spec.rb +33 -0
- data/spec/wizards/node_wizard_spec.rb +110 -0
- data/spec/wizards/profile_wizard_spec.rb +45 -0
- data/spec/wizards/project_wizard_spec.rb +90 -0
- data/spec/wizards/provision_wizard_spec.rb +45 -0
- data/spec/wizards/role_wizard_spec.rb +97 -0
- metadata +37 -4
- data/spec/node_wizard_spec.rb +0 -22
- data/spec/project_wizard_spec.rb +0 -51
data/spec/role_profiles_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
require_relative '../spec/factories/role.rb'
|
3
3
|
require_relative '../spec/factories/profile.rb'
|
4
4
|
|
5
|
-
describe 'Test
|
5
|
+
describe 'Test 13: Associate roles and profiles' do
|
6
6
|
|
7
7
|
let(:role) { build(:role) }
|
8
8
|
let(:profile) { build(:profile) }
|
data/spec/role_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
require_relative '../spec/factories/role.rb'
|
3
3
|
require_relative '../lib/bebox/wizards/wizards_helper'
|
4
4
|
|
5
|
-
describe 'Test
|
5
|
+
describe 'Test 11: Bebox::Role' do
|
6
6
|
|
7
7
|
# include Wizard helper methods
|
8
8
|
include Bebox::WizardsHelper
|
@@ -10,6 +10,7 @@ describe 'Test 07: Bebox::Role' do
|
|
10
10
|
describe 'Manage roles' do
|
11
11
|
|
12
12
|
subject { build(:role) }
|
13
|
+
let(:temporary_role_profile) {Bebox::Profile.list(subject.project_root).first}
|
13
14
|
|
14
15
|
before :all do
|
15
16
|
subject.create
|
@@ -17,7 +18,7 @@ describe 'Test 07: Bebox::Role' do
|
|
17
18
|
|
18
19
|
context '00: role creation' do
|
19
20
|
|
20
|
-
it '
|
21
|
+
it 'validates the role name' do
|
21
22
|
# Test not valid reserved words
|
22
23
|
Bebox::RESERVED_WORDS.each{|reserved_word| expect(valid_puppet_class_name?(reserved_word)).to be (false)}
|
23
24
|
# Test not valid start by undescore
|
@@ -30,12 +31,12 @@ describe 'Test 07: Bebox::Role' do
|
|
30
31
|
expect(valid_puppet_class_name?(subject.name)).to be (true)
|
31
32
|
end
|
32
33
|
|
33
|
-
it '
|
34
|
+
it 'creates the role directories' do
|
34
35
|
expect(Dir.exist?("#{subject.path}")).to be (true)
|
35
36
|
expect(Dir.exist?("#{subject.path}/manifests")).to be (true)
|
36
37
|
end
|
37
38
|
|
38
|
-
it '
|
39
|
+
it 'generates the manifests file' do
|
39
40
|
output_file = File.read("#{subject.path}/manifests/init.pp").strip
|
40
41
|
expected_content = File.read('spec/fixtures/puppet/roles/manifests/init.pp.test').strip
|
41
42
|
expect(output_file).to eq(expected_content)
|
@@ -43,15 +44,47 @@ describe 'Test 07: Bebox::Role' do
|
|
43
44
|
end
|
44
45
|
|
45
46
|
context '01: role list' do
|
46
|
-
it '
|
47
|
+
it 'list the roles' do
|
47
48
|
current_roles = [subject.name]
|
48
49
|
roles = Bebox::Role.list(subject.project_root)
|
49
50
|
expect(roles).to include(*current_roles)
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
53
|
-
context '02:
|
54
|
-
it '
|
54
|
+
context '02: self methods' do
|
55
|
+
it 'counts the number of roles in the project' do
|
56
|
+
roles_count = Bebox::Role.roles_count(subject.project_root)
|
57
|
+
expect(roles_count).to eq(4)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'adds a profile to a role' do
|
61
|
+
profile_include = "include profiles::#{temporary_role_profile.gsub('/','::')}"
|
62
|
+
Bebox::Role.add_profile(subject.project_root, subject.name, temporary_role_profile)
|
63
|
+
role_content = File.read("#{subject.path}/manifests/init.pp").strip
|
64
|
+
expect(role_content).to include(profile_include)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'list the profiles in a role' do
|
68
|
+
expected_profiles = [temporary_role_profile]
|
69
|
+
profiles = Bebox::Role.list_profiles(subject.project_root, subject.name)
|
70
|
+
expect(profiles).to eq(expected_profiles)
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'checks if a role contains a given profile' do
|
74
|
+
profile_in_role = Bebox::Role.profile_in_role?(subject.project_root, subject.name, temporary_role_profile)
|
75
|
+
expect(profile_in_role).to eq(true)
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'removes a profile from a role' do
|
79
|
+
profile_include = "include profiles::#{temporary_role_profile.gsub('/','::')}"
|
80
|
+
Bebox::Role.remove_profile(subject.project_root, subject.name, temporary_role_profile)
|
81
|
+
role_content = File.read("#{subject.path}/manifests/init.pp").strip
|
82
|
+
expect(role_content).to_not include(profile_include)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
context '03: role deletion' do
|
87
|
+
it 'deletes the role directory' do
|
55
88
|
subject.remove
|
56
89
|
expect(Dir.exist?("#{subject.path}")).to be (false)
|
57
90
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
# Add coverage with simple_cov and codeclimate
|
2
|
+
# These must be the first lines in the file
|
3
|
+
require 'codeclimate-test-reporter'
|
4
|
+
require 'simplecov'
|
5
|
+
|
6
|
+
formatters = [SimpleCov::Formatter::HTMLFormatter]
|
7
|
+
formatters << CodeClimate::TestReporter::Formatter if ENV['CODECLIMATE_REPO_TOKEN']
|
8
|
+
|
9
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[*formatters]
|
10
|
+
SimpleCov.start do
|
11
|
+
add_filter '/spec/'
|
12
|
+
end
|
13
|
+
|
1
14
|
require 'rubygems'
|
2
15
|
require 'awesome_print'
|
3
16
|
require 'jazz_hands'
|
@@ -6,6 +19,7 @@ require 'factory_girl'
|
|
6
19
|
require 'serverspec'
|
7
20
|
require 'pathname'
|
8
21
|
require 'net/ssh'
|
22
|
+
require 'colorize'
|
9
23
|
|
10
24
|
include Serverspec::Helper::Ssh
|
11
25
|
include Serverspec::Helper::Debian
|
@@ -14,13 +28,17 @@ require_relative '../lib/bebox/logger'
|
|
14
28
|
require_relative '../lib/bebox/files_helper'
|
15
29
|
require_relative '../lib/bebox/wizards/wizards_helper'
|
16
30
|
require_relative '../lib/bebox/vagrant_helper'
|
17
|
-
require_relative '../lib/bebox/project'
|
18
31
|
require_relative '../lib/bebox/wizards/project_wizard'
|
32
|
+
require_relative '../lib/bebox/project'
|
33
|
+
require_relative '../lib/bebox/wizards/environment_wizard'
|
19
34
|
require_relative '../lib/bebox/environment'
|
20
|
-
require_relative '../lib/bebox/node'
|
21
35
|
require_relative '../lib/bebox/wizards/node_wizard'
|
36
|
+
require_relative '../lib/bebox/node'
|
37
|
+
require_relative '../lib/bebox/wizards/provision_wizard'
|
22
38
|
require_relative '../lib/bebox/provision'
|
39
|
+
require_relative '../lib/bebox/wizards/role_wizard'
|
23
40
|
require_relative '../lib/bebox/role'
|
41
|
+
require_relative '../lib/bebox/wizards/profile_wizard'
|
24
42
|
require_relative '../lib/bebox/profile'
|
25
43
|
require_relative '../lib/bebox/vagrant_helper'
|
26
44
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require_relative '../factories/environment.rb'
|
4
|
+
|
5
|
+
describe 'Test 01: Bebox::EnvironmentWizard' do
|
6
|
+
|
7
|
+
subject { Bebox::EnvironmentWizard.new }
|
8
|
+
|
9
|
+
let(:environment) { build(:environment) }
|
10
|
+
|
11
|
+
before :each do
|
12
|
+
$stdout.stub(:write)
|
13
|
+
end
|
14
|
+
|
15
|
+
context '00: environment not exist' do
|
16
|
+
it 'creates a new environment with wizard' do
|
17
|
+
Bebox::Environment.stub(:environment_exists?) { false }
|
18
|
+
Bebox::Environment.any_instance.stub(:create) { true }
|
19
|
+
output = subject.create_new_environment(environment.project_root, environment.name)
|
20
|
+
expect(output).to eq(true)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context '01: environment exist' do
|
25
|
+
it 'removes an environment with wizard' do
|
26
|
+
Bebox::Environment.stub(:environment_exists?) { true }
|
27
|
+
Bebox::Environment.any_instance.stub(:remove) { true }
|
28
|
+
$stdin.stub(:gets).and_return('y')
|
29
|
+
output = subject.remove_environment(environment.project_root, environment.name)
|
30
|
+
expect(output).to eq(true)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require_relative '../factories/node.rb'
|
4
|
+
|
5
|
+
describe 'Test 02: Bebox::NodeWizard' do
|
6
|
+
|
7
|
+
subject { Bebox::NodeWizard.new }
|
8
|
+
|
9
|
+
let(:node) { build(:node) }
|
10
|
+
|
11
|
+
before :each do
|
12
|
+
$stdout.stub(:write)
|
13
|
+
end
|
14
|
+
|
15
|
+
context '00: node not exist' do
|
16
|
+
|
17
|
+
before :each do
|
18
|
+
subject.stub(:node_exists?) { false }
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'creates a node with wizard' do
|
22
|
+
Bebox::Node.any_instance.stub(:create) { true }
|
23
|
+
# First try with a non-free IP (127.0.0.1) and then the free
|
24
|
+
$stdin.stub(:gets).and_return(node.hostname, '127.0.0.1', node.ip)
|
25
|
+
output = subject.create_new_node(node.project_root, node.environment)
|
26
|
+
expect(output).to eq(true)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'can not remove a node if not exist any' do
|
30
|
+
Bebox::Node.stub(:list) { [] }
|
31
|
+
output = subject.remove_node(node.project_root, node.environment, node.hostname)
|
32
|
+
expect(output).to eq(true)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'can not prepare a node if not exist any' do
|
36
|
+
subject.stub(:check_nodes_to_prepare) { [] }
|
37
|
+
output = subject.prepare(node.project_root, node.environment)
|
38
|
+
expect(output).to eq(true)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context '01: node exist' do
|
43
|
+
|
44
|
+
before :each do
|
45
|
+
subject.stub(:node_exists?) { true }
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'removes a node with wizard' do
|
49
|
+
Bebox::Node.stub(:list) { [node.hostname] }
|
50
|
+
Bebox::Node.any_instance.stub(:remove) { true }
|
51
|
+
$stdin.stub(:gets).and_return('1', 'y')
|
52
|
+
output = subject.remove_node(node.project_root, node.environment, node.hostname)
|
53
|
+
expect(output).to eq(true)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'prepares a node with wizard' do
|
57
|
+
Bebox::Node.any_instance.stub(:prepare) { true }
|
58
|
+
subject.stub(:check_nodes_to_prepare) { [node] }
|
59
|
+
Bebox::Node.stub(:regenerate_deploy_file) { true }
|
60
|
+
Bebox::VagrantHelper.stub(:generate_vagrantfile) { true }
|
61
|
+
Bebox::VagrantHelper.stub(:up_vagrant_nodes) { true }
|
62
|
+
subject.stub(:prepare_vagrant) { true }
|
63
|
+
output = subject.prepare(node.project_root, node.environment)
|
64
|
+
expect(output).to eq(true)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'creates a node with wizard' do
|
68
|
+
Bebox::Node.any_instance.stub(:create) { true }
|
69
|
+
# First try with an existing hostname and then an inexisting
|
70
|
+
$stdin.stub(:gets).and_return(node.hostname, 'localhost', node.ip)
|
71
|
+
output = subject.create_new_node(node.project_root, node.environment)
|
72
|
+
expect(output).to eq(true)
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'sets the role for a node' do
|
76
|
+
Bebox::Role.stub(:list) {['a']}
|
77
|
+
Bebox::Node.stub(:list) {[node]}
|
78
|
+
Bebox::Provision.stub(:associate_node_role) { true }
|
79
|
+
$stdin.stub(:gets).and_return('1', '1')
|
80
|
+
output = subject.set_role(node.project_root, node.environment)
|
81
|
+
expect(output).to eq(true)
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'checks for a no prepared_node with wizard' do
|
85
|
+
Bebox::Node.stub(:nodes_in_environment) { [node] }
|
86
|
+
Bebox::Node.stub(:list) { [] }
|
87
|
+
Bebox::Node.any_instance.stub(:checkpoint_parameter_from_file) { '' }
|
88
|
+
output = subject.check_nodes_to_prepare(node.project_root, node.environment)
|
89
|
+
expect(output).to eq([node])
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'checks for an already prepared_node with wizard' do
|
93
|
+
Bebox::Node.stub(:nodes_in_environment) { [node] }
|
94
|
+
Bebox::Node.stub(:list) { [node.hostname] }
|
95
|
+
Bebox::Node.any_instance.stub(:checkpoint_parameter_from_file) { '' }
|
96
|
+
$stdin.stub(:gets).and_return('n')
|
97
|
+
output = subject.check_nodes_to_prepare(node.project_root, node.environment)
|
98
|
+
expect(output).to eq([])
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'checks for node existence' do
|
103
|
+
output = subject.node_exists?(node.project_root, node.environment, node.hostname)
|
104
|
+
expect(output).to eq(false)
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'checks for free IP' do
|
108
|
+
expect(subject.free_ip?(node.ip)).to eq(true)
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require_relative '../factories/profile.rb'
|
4
|
+
|
5
|
+
describe 'Test 04: Bebox::ProfileWizard' do
|
6
|
+
|
7
|
+
subject { Bebox::ProfileWizard.new }
|
8
|
+
|
9
|
+
let(:profile) { build(:profile) }
|
10
|
+
|
11
|
+
before :each do
|
12
|
+
$stdout.stub(:write)
|
13
|
+
end
|
14
|
+
|
15
|
+
context '00: profile not exist' do
|
16
|
+
it 'creates a new profile with wizard' do
|
17
|
+
Bebox::Profile.any_instance.stub(:create) { true }
|
18
|
+
output = subject.create_new_profile(profile.project_root, profile.name, profile.path)
|
19
|
+
expect(output).to eq(true)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'list profiles with wizard' do
|
23
|
+
Bebox::Profile.stub(:list) {[]}
|
24
|
+
output = subject.list_profiles(profile.project_root)
|
25
|
+
expect(output).to eq([])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context '01: profile not exist' do
|
30
|
+
|
31
|
+
it 'removes a profile with wizard' do
|
32
|
+
Bebox::Profile.stub(:list) { [profile.relative_path] }
|
33
|
+
Bebox::Profile.any_instance.stub(:remove) { true }
|
34
|
+
$stdin.stub(:gets).and_return(profile.relative_path, 'y')
|
35
|
+
output = subject.remove_profile(profile.project_root)
|
36
|
+
expect(output).to eq(true)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'can not remove a profile if not exist any profile with wizard' do
|
41
|
+
Bebox::Profile.stub(:list) {[]}
|
42
|
+
output = subject.remove_profile(profile.project_root)
|
43
|
+
expect(output).to eq(nil)
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'progressbar'
|
3
|
+
|
4
|
+
require_relative '../factories/project.rb'
|
5
|
+
|
6
|
+
describe 'Test 00: Bebox::ProjectWizard' do
|
7
|
+
|
8
|
+
describe 'Project data provision' do
|
9
|
+
|
10
|
+
subject { Bebox::ProjectWizard.new }
|
11
|
+
|
12
|
+
let(:project_name) { 'bebox-pname' }
|
13
|
+
let(:parent_path) { "#{Dir.pwd}/tmp" }
|
14
|
+
let(:http_box_uri) {'http://puppet-vagrant-boxes.puppetlabs.com/ubuntu-server-12042-x64-vbox4210-nocm.box'}
|
15
|
+
let(:local_box_uri) {"#{Dir.pwd}/spec/fixtures/test_box.box"}
|
16
|
+
let(:bebox_boxes_path) {File.expand_path(Bebox::ProjectWizard::BEBOX_BOXES_PATH)}
|
17
|
+
|
18
|
+
before :all do
|
19
|
+
`mkdir -p #{bebox_boxes_path}/tmp`
|
20
|
+
`rm -rf #{Dir.pwd}/tmp/bebox-pname`
|
21
|
+
end
|
22
|
+
|
23
|
+
before :each do
|
24
|
+
$stdout.stub(:write)
|
25
|
+
end
|
26
|
+
|
27
|
+
after :all do
|
28
|
+
`rm #{bebox_boxes_path}/test_box.box`
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'creates a project with wizard' do
|
32
|
+
Bebox::Project.any_instance.stub(:create) { true }
|
33
|
+
subject.stub(:bebox_boxes_setup)
|
34
|
+
subject.stub(:choose_box) { 'test_box.box' }
|
35
|
+
$stdin.stub(:gets).and_return('1')
|
36
|
+
output = subject.create_new_project(project_name)
|
37
|
+
expect(output).to eq(true)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'chooses a box from a menu' do
|
41
|
+
$stdin.stub(:gets).and_return('1')
|
42
|
+
output = subject.choose_box(['test_box.box'])
|
43
|
+
expect(output).to eq('test_box.box')
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'gets a valid box uri from user' do
|
47
|
+
$stdin.stub(:gets).and_return(local_box_uri, 'y')
|
48
|
+
subject.get_valid_box_uri(nil)
|
49
|
+
expect(File.symlink?("#{bebox_boxes_path}/test_box.box")).to eq(true)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'checks for project existence' do
|
53
|
+
output = subject.project_exists?(parent_path, project_name)
|
54
|
+
expect(output).to eq(Dir.exists?("#{Dir.pwd}/tmp/#{project_name}"))
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'setup the bebox boxes directory' do
|
58
|
+
subject.bebox_boxes_setup
|
59
|
+
expect(Dir.exist?("#{bebox_boxes_path}/tmp")).to eq(true)
|
60
|
+
expect(Dir["#{bebox_boxes_path}/tmp/*"].count).to eq(0)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'validates an http box uri' do
|
64
|
+
output = subject.uri_valid?(http_box_uri)
|
65
|
+
expect(output).to eq(true)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'validates a local-file box uri' do
|
69
|
+
output = subject.uri_valid?(local_box_uri)
|
70
|
+
expect(output).to eq(true)
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'links to a local file box' do
|
74
|
+
subject.set_box(local_box_uri)
|
75
|
+
expect(File.symlink?("#{bebox_boxes_path}/test_box.box")).to eq(true)
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'checks for a local file box existence' do
|
79
|
+
expect(subject.box_exists?(local_box_uri)).to eq(true)
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'links to a remote file box' do
|
83
|
+
remote_box_uri = 'https://github.com/codescrum/bebox/blob/master/LICENSE'
|
84
|
+
subject.set_box(remote_box_uri)
|
85
|
+
expect(File.exists?("#{bebox_boxes_path}/LICENSE")).to eq(true)
|
86
|
+
`rm #{bebox_boxes_path}/LICENSE`
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require_relative '../factories/provision.rb'
|
4
|
+
|
5
|
+
describe 'Test 05: Bebox::ProvisionWizard' do
|
6
|
+
|
7
|
+
subject { Bebox::ProvisionWizard.new }
|
8
|
+
|
9
|
+
let(:provision) { build(:provision) }
|
10
|
+
|
11
|
+
before :each do
|
12
|
+
$stdout.stub(:write)
|
13
|
+
Bebox::Environment.stub(:check_environment_access) { true }
|
14
|
+
Bebox::Node.stub(:nodes_in_environment) { [provision.node] }
|
15
|
+
Bebox::Node.any_instance.stub(:checkpoint_parameter_from_file) { '' }
|
16
|
+
Bebox::Provision.stub(:role_from_node) { 'role' }
|
17
|
+
Bebox::Provision.stub(:profiles_from_role) { 'profile' }
|
18
|
+
Bebox::Provision.stub(:generate_puppetfile) {true}
|
19
|
+
Bebox::Provision.stub(:generate_roles_and_profiles) {true}
|
20
|
+
Bebox::Provision.any_instance.stub_chain(:apply, :success?) { true }
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'apply a step with wizard' do
|
24
|
+
Bebox::Node.stub(:list) { [] }
|
25
|
+
outputs = subject.apply_step(provision.project_root, provision.environment, provision.step)
|
26
|
+
expect(outputs).to eq([true])
|
27
|
+
end
|
28
|
+
|
29
|
+
it 're-apply a step with wizard' do
|
30
|
+
Bebox::Node.stub(:list) { [provision.node.hostname] }
|
31
|
+
$stdin.stub(:gets).and_return('y')
|
32
|
+
outputs = subject.apply_step(provision.project_root, provision.environment, provision.step)
|
33
|
+
expect(outputs).to eq([true])
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'obtains the previous checkpoint for a node' do
|
37
|
+
steps = %w{prepared_nodes step-0 step-1 step-2 step-3}
|
38
|
+
expected_checkpoints = ['nodes', 'prepared_nodes', 'steps/step-0', 'steps/step-1', 'steps/step-2']
|
39
|
+
checkpoints = []
|
40
|
+
steps.each do |step|
|
41
|
+
checkpoints << subject.previous_checkpoint(step)
|
42
|
+
end
|
43
|
+
expect(checkpoints).to include(*expected_checkpoints)
|
44
|
+
end
|
45
|
+
end
|