bebox 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rspec +1 -0
  4. data/Gemfile.lock +11 -1
  5. data/README.md +1 -0
  6. data/bebox.gemspec +2 -0
  7. data/lib/bebox/node.rb +1 -1
  8. data/lib/bebox/provision.rb +0 -32
  9. data/lib/bebox/vagrant_helper.rb +6 -4
  10. data/lib/bebox/version.rb +1 -1
  11. data/lib/bebox/wizards/environment_wizard.rb +4 -2
  12. data/lib/bebox/wizards/node_wizard.rb +9 -4
  13. data/lib/bebox/wizards/profile_wizard.rb +4 -2
  14. data/lib/bebox/wizards/project_wizard.rb +4 -3
  15. data/lib/bebox/wizards/provision_wizard.rb +6 -2
  16. data/lib/bebox/wizards/role_wizard.rb +14 -9
  17. data/lib/bebox/wizards/wizards_helper.rb +1 -0
  18. data/spec/environment_spec.rb +35 -18
  19. data/spec/factories/environment.rb +0 -12
  20. data/spec/factories/node.rb +0 -6
  21. data/spec/factories/project.rb +1 -7
  22. data/spec/fixtures/dot_bebox.test.erb +1 -1
  23. data/spec/node0.server1.test/prepare_phase_spec.rb +1 -1
  24. data/spec/node0.server1.test/provision_step_0_spec.rb +1 -1
  25. data/spec/node0.server1.test/provision_step_1_spec.rb +1 -1
  26. data/spec/node0.server1.test/provision_step_2_spec.rb +1 -1
  27. data/spec/node0.server1.test/provision_step_3_spec.rb +1 -1
  28. data/spec/node_role_spec.rb +7 -1
  29. data/spec/node_spec.rb +55 -17
  30. data/spec/ordered_phases_spec.rb +7 -3
  31. data/spec/pre_prepare_spec.rb +12 -9
  32. data/spec/pre_provision_steps_spec.rb +1 -1
  33. data/spec/profile_spec.rb +21 -8
  34. data/spec/project_spec.rb +54 -48
  35. data/spec/role_profiles_spec.rb +1 -1
  36. data/spec/role_spec.rb +40 -7
  37. data/spec/spec_helper.rb +20 -2
  38. data/spec/wizards/environment_wizard_spec.rb +33 -0
  39. data/spec/wizards/node_wizard_spec.rb +110 -0
  40. data/spec/wizards/profile_wizard_spec.rb +45 -0
  41. data/spec/wizards/project_wizard_spec.rb +90 -0
  42. data/spec/wizards/provision_wizard_spec.rb +45 -0
  43. data/spec/wizards/role_wizard_spec.rb +97 -0
  44. metadata +37 -4
  45. data/spec/node_wizard_spec.rb +0 -22
  46. data/spec/project_wizard_spec.rb +0 -51
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 69912bd5c8001b5268585d2e588209842de9714b
4
- data.tar.gz: 8361cf2dc44a3e28bbc6c93991d1cffe68d662d6
3
+ metadata.gz: bb82ff2a6726fcc8b3d4ccd7a64fe23c593c71b7
4
+ data.tar.gz: a46d4bde8d6db798ff9b2d8b0011bb4008221b4d
5
5
  SHA512:
6
- metadata.gz: 3dad9691f0bff82bf147b9cd09f28bdcbcb143019ce960b99b325ad619393d71c6aca7ab5968cd6c4acf867e28194f2159bad044dd564e5ddaba241801823e0d
7
- data.tar.gz: 4865599e35c7ed4b6b8028d73b080bfa5a120ec62167434a580fc0a706d7ad9c3be5a58cadf075e0a2d3f6dd24a00fcf65994af99a989c65ec93753d7e0cee4d
6
+ metadata.gz: ac94dff23adf6866b9739d96891ec41d42b6d36423c26836101dca0b5e7ba41f350fca81dc8c08f680c71bb59d052e6eb4e413096d2a0e7c7308aeba27cc4b3b
7
+ data.tar.gz: 33ba1cfcb5f89871b01b6e54f7937113f50f1a73cab8b6ab01d5028aea191906b60ef00e88e4e93415d181459bd7b326fc1453d6e6e8564ce9e405e79dc1aaec
data/.gitignore CHANGED
@@ -71,6 +71,7 @@ pkg/
71
71
 
72
72
  # Spec tests
73
73
  spec/support/config_specs.yaml
74
+ coverage/
74
75
 
75
76
  # Local
76
77
  TODO
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bebox (0.1.0)
4
+ bebox (0.1.1)
5
5
  colorize (= 0.6.0)
6
6
  gli (= 2.10.0)
7
7
  highline (= 1.6.21)
@@ -36,6 +36,8 @@ GEM
36
36
  builder (3.2.2)
37
37
  childprocess (0.5.3)
38
38
  ffi (~> 1.0, >= 1.0.11)
39
+ codeclimate-test-reporter (0.4.0)
40
+ simplecov (>= 0.7.1, < 1.0.0)
39
41
  coderay (1.1.0)
40
42
  colorize (0.6.0)
41
43
  columnize (0.8.9)
@@ -55,6 +57,7 @@ GEM
55
57
  debugger-ruby_core_source (1.3.2)
56
58
  diff-lcs (1.2.5)
57
59
  diffy (3.0.4)
60
+ docile (1.1.5)
58
61
  erubis (2.7.0)
59
62
  factory_girl (4.3.0)
60
63
  activesupport (>= 3.0.0)
@@ -134,6 +137,11 @@ GEM
134
137
  net-ssh
135
138
  rspec (~> 2.13)
136
139
  specinfra (~> 1.11)
140
+ simplecov (0.9.0)
141
+ docile (~> 1.1.0)
142
+ multi_json
143
+ simplecov-html (~> 0.8.0)
144
+ simplecov-html (0.8.0)
137
145
  slop (3.5.0)
138
146
  specinfra (1.12.0)
139
147
  thor (0.19.1)
@@ -149,8 +157,10 @@ PLATFORMS
149
157
  DEPENDENCIES
150
158
  aruba (= 0.5.4)
151
159
  bebox!
160
+ codeclimate-test-reporter (= 0.4.0)
152
161
  factory_girl (= 4.3.0)
153
162
  jazz_hands (= 0.5.2)
154
163
  rake (= 10.3.1)
155
164
  rspec (= 2.14.1)
156
165
  serverspec (= 1.6.0)
166
+ simplecov (= 0.9.0)
data/README.md CHANGED
@@ -2,6 +2,7 @@ Bebox
2
2
  =====
3
3
 
4
4
  [![Code Climate](https://codeclimate.com/github/codescrum/bebox/badges/gpa.svg)](https://codeclimate.com/github/codescrum/bebox)
5
+ [![Test Coverage](https://codeclimate.com/github/codescrum/bebox/badges/coverage.svg)](https://codeclimate.com/github/codescrum/bebox)
5
6
 
6
7
  Introduction
7
8
  ------------
data/bebox.gemspec CHANGED
@@ -31,6 +31,8 @@ spec = Gem::Specification.new do |s|
31
31
  s.add_development_dependency('jazz_hands', '0.5.2')
32
32
  s.add_development_dependency('serverspec', '1.6.0')
33
33
  s.add_development_dependency('factory_girl', '4.3.0')
34
+ s.add_development_dependency('codeclimate-test-reporter', '0.4.0')
35
+ s.add_development_dependency('simplecov', '0.9.0')
34
36
  s.add_runtime_dependency('gli','2.10.0')
35
37
  s.add_runtime_dependency('tilt', '2.0.1')
36
38
  s.add_runtime_dependency('highline', '1.6.21')
data/lib/bebox/node.rb CHANGED
@@ -170,7 +170,7 @@ module Bebox
170
170
  end
171
171
  end
172
172
 
173
- # Obtain the node creation_at of finished_at parameter of a node
173
+ # Obtain the node creation_at parameter for a node
174
174
  def self.node_creation_date(project_root, environment, node_type, node)
175
175
  node_config = YAML.load_file("#{project_root}/.checkpoints/environments/#{environment}/#{node_type}/#{node}.yml")
176
176
  (node_type == 'nodes') ? node_config['created_at'] : node_config['finished_at']
@@ -42,27 +42,6 @@ module Bebox
42
42
  `cp -R #{Bebox::FilesHelper::templates_path}/puppet/#{self.step}/modules/* #{self.project_root}/puppet/steps/#{step_name}/modules/`
43
43
  end
44
44
 
45
- # Generate the hiera data for step from the template
46
- def generate_hiera
47
- generate_hiera_yaml
48
- generate_hiera_data_common
49
- end
50
-
51
- def generate_hiera_yaml
52
- generate_file_from_template("#{Bebox::FilesHelper::templates_path}/puppet/#{self.step}/hiera/hiera.yaml.erb", "#{self.project_root}/puppet/steps/#{step_name}/hiera/hiera.yaml", {step_dir: step_name})
53
- end
54
-
55
- def generate_hiera_data_common
56
- ssh_key = Bebox::Project.public_ssh_key_from_file(self.project_root, self.environment)
57
- project_name = Bebox::Project.shortname_from_file(self.project_root)
58
- generate_file_from_template("#{Bebox::FilesHelper::templates_path}/puppet/#{self.step}/hiera/data/common_apply.yaml.erb", "#{self.project_root}/puppet/steps/#{step_name}/hiera/data/common.yaml", {ssh_key: ssh_key, project_name: project_name})
59
- end
60
-
61
- # Generate the site.pp manifests file for step
62
- def self.generate_manifests(project_root, step, nodes)
63
- generate_file_from_template("#{Bebox::FilesHelper::templates_path}/puppet/#{step}/manifests/site_apply.pp.erb", "#{project_root}/puppet/steps/#{Bebox::Provision.step_name(step)}/manifests/site.pp", {nodes: nodes})
64
- end
65
-
66
45
  # Generate the hiera templates for each step
67
46
  def self.generate_hiera_for_steps(project_root, template_file, filename, options)
68
47
  Bebox::PROVISION_STEPS.each do |step|
@@ -123,12 +102,6 @@ module Bebox
123
102
 
124
103
  # Set a role for a node in the step-2 manifests file
125
104
  def self.associate_node_role(project_root, environment, node_name, role_name)
126
- # Create the manifests site.pp file for step-2 if not exist
127
- unless Bebox::Provision.manifests_exists?(project_root, 'step-2')
128
- nodes = Bebox::Node.nodes_in_environment(project_root, environment, 'nodes')
129
- Bebox::Provision.generate_manifests(project_root, self.step, nodes)
130
- end
131
- # Set the role for a node
132
105
  Bebox::Provision.remove_role(project_root, node_name, 'step-2')
133
106
  Bebox::Provision.add_role(project_root, node_name, role_name)
134
107
  end
@@ -190,11 +163,6 @@ module Bebox
190
163
  File.open(manifest_path, 'wb') { |file| file.write(content) }
191
164
  end
192
165
 
193
- # Check if a manifests for a step exist
194
- def self.manifests_exists?(project_root, step)
195
- File.exist?("#{project_root}/puppet/steps/#{Bebox::Provision.step_name(step)}/manifests/site.pp")
196
- end
197
-
198
166
  # Apply step via capistrano in the machine
199
167
  def apply_step
200
168
  # Create deploy directories
@@ -43,8 +43,8 @@ module Bebox
43
43
 
44
44
  # Add the vagrant hosts to the local hosts file
45
45
  def add_to_local_hosts(node)
46
- host_command = `echo '#{node.ip} #{node.hostname} # Added by bebox' >> #{local_hosts_path}/hosts`
47
- host_command if (file_content_trimmed("#{local_hosts_path}/hosts") =~ /#{node.ip}\s+#{node.hostname}/)
46
+ host_command = "sudo echo '#{node.ip} #{node.hostname} # Added by bebox' >> #{local_hosts_path}/hosts"
47
+ `#{host_command}` unless (file_content_trimmed("#{local_hosts_path}/hosts") =~ /#{node.ip}\s+#{node.hostname}/)
48
48
  end
49
49
 
50
50
  # Obtain the local hosts file for the OS
@@ -64,13 +64,15 @@ module Bebox
64
64
  def add_vagrant_node(project_name, vagrant_box_base, node)
65
65
  already_installed_boxes = installed_vagrant_box_names(node)
66
66
  box_name = "#{project_name}-#{node.hostname}"
67
- info "Adding server to vagrant: #{node.hostname}..."
67
+ info "Adding server to vagrant: #{node.hostname}"
68
+ info "Please enter the network interface number if asked, and wait until the machine is up."
68
69
  `cd #{node.project_root} && vagrant box add #{box_name} #{vagrant_box_base}` unless already_installed_boxes.include? box_name
69
70
  end
70
71
 
71
72
  # Up the vagrant boxes in Vagrantfile
72
73
  def self.up_vagrant_nodes(project_root)
73
- `cd #{project_root} && vagrant up --provision`
74
+ pid = fork {exec("cd #{project_root} && vagrant up --provision")}
75
+ Process.wait(pid)
74
76
  end
75
77
 
76
78
  # Halt the vagrant boxes running
data/lib/bebox/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bebox
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -10,8 +10,9 @@ module Bebox
10
10
  return error("The '#{environment_name}' environment already exist!.") if Bebox::Environment.environment_exists?(project_root, environment_name)
11
11
  # Environment creation
12
12
  environment = Bebox::Environment.new(environment_name, project_root)
13
- environment.create
13
+ output = environment.create
14
14
  ok 'Environment created!.'
15
+ return output
15
16
  end
16
17
 
17
18
  # Removes an existing environment
@@ -22,8 +23,9 @@ module Bebox
22
23
  return warn('No changes were made.') unless confirm_action?('Are you sure that you want to delete the environment?')
23
24
  # Environment deletion
24
25
  environment = Bebox::Environment.new(environment_name, project_root)
25
- environment.remove
26
+ output = environment.remove
26
27
  ok 'Environment removed!.'
28
+ return output
27
29
  end
28
30
  end
29
31
  end
@@ -13,8 +13,9 @@ module Bebox
13
13
  ip = ask_ip(environment)
14
14
  # Node creation
15
15
  node = Bebox::Node.new(environment, project_root, hostname, ip)
16
- node.create
16
+ output = node.create
17
17
  ok 'Node created!.'
18
+ return output
18
19
  end
19
20
 
20
21
  # Removes an existing node
@@ -24,14 +25,16 @@ module Bebox
24
25
  if nodes.count > 0
25
26
  hostname = choose_option(nodes, 'Choose the node to remove:')
26
27
  else
27
- return error "There are no nodes in the '#{environment}' environment to remove. No changes were made."
28
+ error "There are no nodes in the '#{environment}' environment to remove. No changes were made."
29
+ return true
28
30
  end
29
31
  # Ask for deletion confirmation
30
32
  return warn('No changes were made.') unless confirm_action?('Are you sure that you want to delete the node?')
31
33
  # Node deletion
32
34
  node = Bebox::Node.new(environment, project_root, hostname, nil)
33
- node.remove
35
+ output = node.remove
34
36
  ok 'Node removed!.'
37
+ return output
35
38
  end
36
39
 
37
40
  # Associate a role with a node in a environment
@@ -40,8 +43,9 @@ module Bebox
40
43
  nodes = Bebox::Node.list(project_root, environment, 'nodes')
41
44
  node = choose_option(nodes, 'Choose an existing node:')
42
45
  role = choose_option(roles, 'Choose an existing role:')
43
- Bebox::Provision.associate_node_role(project_root, environment, node, role)
46
+ output = Bebox::Provision.associate_node_role(project_root, environment, node, role)
44
47
  ok 'Role associated to node!.'
48
+ return output
45
49
  end
46
50
 
47
51
  # Prepare the nodes in a environment
@@ -69,6 +73,7 @@ module Bebox
69
73
  else
70
74
  warn 'There are no nodes to prepare. No changes were made.'
71
75
  end
76
+ return true
72
77
  end
73
78
 
74
79
  # Check the nodes already prepared and ask confirmation to re-do-it
@@ -31,8 +31,9 @@ module Bebox
31
31
  return error("The profile '#{profile_path}' already exist. No changes were made.") if profile_exists?(project_root, profile_path)
32
32
  # Profile creation
33
33
  profile = Bebox::Profile.new(profile_name, project_root, profile_base_path)
34
- profile.create
34
+ output = profile.create
35
35
  ok "Profile '#{profile_path}' created!."
36
+ return output
36
37
  end
37
38
 
38
39
  # Removes an existing profile
@@ -51,8 +52,9 @@ module Bebox
51
52
  profile_name = profile.split('/').last
52
53
  profile_base_path = profile.split('/')[0...-1].join('/')
53
54
  profile = Bebox::Profile.new(profile_name, project_root, profile_base_path)
54
- profile.remove
55
+ output = profile.remove
55
56
  ok 'Profile removed!.'
57
+ return output
56
58
  end
57
59
 
58
60
  # Lists existing profiles
@@ -21,13 +21,14 @@ module Bebox
21
21
  default_environments = %w{vagrant staging production}
22
22
  # Project creation
23
23
  project = Bebox::Project.new(project_name, vagrant_box_base, Dir.pwd, vagrant_box_provider, default_environments)
24
- project.create
24
+ output = project.create
25
25
  ok "Project '#{project_name}' created!.\nMake: cd #{project_name}\nNow you can add new environments or new nodes to your project.\nSee bebox help."
26
+ return output
26
27
  end
27
28
 
28
29
  # If choose to download/select new box get a valid uri
29
30
  def get_valid_box_uri(current_box)
30
- return (valid_box_uri = current_box) unless current_box.nil?
31
+ return current_box unless current_box.nil?
31
32
  # Keep asking for valid uri or overwriting until confirmation
32
33
  confirm = false
33
34
  begin
@@ -64,7 +65,7 @@ module Bebox
64
65
  def set_box(box_uri)
65
66
  require 'uri'
66
67
  uri = URI.parse(box_uri)
67
- if uri.scheme == ('http' || 'https')
68
+ if %w{http https}.include?(uri.scheme)
68
69
  info 'Downloading box ...'
69
70
  download_box(uri)
70
71
  else
@@ -13,10 +13,12 @@ module Bebox
13
13
  nodes_for_provisioning(nodes_to_step, step)
14
14
  # Apply the nodes provisioning for step-N
15
15
  in_step_nodes = Bebox::Node.list(project_root, environment, "steps/#{step}")
16
+ outputs = []
16
17
  nodes_to_step.each do |node|
17
18
  next unless check_node_to_step(node, in_step_nodes, step)
18
- provision_step_in_node(project_root, environment, step, in_step_nodes, node)
19
+ outputs << provision_step_in_node(project_root, environment, step, in_step_nodes, node)
19
20
  end
21
+ return outputs
20
22
  end
21
23
 
22
24
  def provision_step_in_node(project_root, environment, step, in_step_nodes, node)
@@ -28,7 +30,9 @@ module Bebox
28
30
  # Before apply generate the roles and profiles modules structure for puppet step
29
31
  Bebox::Provision.generate_roles_and_profiles(project_root, step, role, profiles)
30
32
  provision = Bebox::Provision.new(project_root, environment, node, step)
31
- provision.apply.success? ? (ok "Node '#{node.hostname}' provisioned to #{step}.") : (error "An error ocurred in the provision of #{step} for node '#{node.hostname}'")
33
+ output = provision.apply.success?
34
+ output ? (ok "Node '#{node.hostname}' provisioned to #{step}.") : (error "An error ocurred in the provision of #{step} for node '#{node.hostname}'")
35
+ return output
32
36
  end
33
37
 
34
38
  def check_node_to_step(node, in_step_nodes, step)
@@ -18,8 +18,9 @@ module Bebox
18
18
  return error("The '#{role_name}' role already exist. No changes were made.") if role_exists?(project_root, role_name)
19
19
  # Role creation
20
20
  role = Bebox::Role.new(role_name, project_root)
21
- role.create
21
+ output = role.create
22
22
  ok 'Role created!.'
23
+ return output
23
24
  end
24
25
 
25
26
  # Removes an existing role
@@ -36,8 +37,9 @@ module Bebox
36
37
  return warn('No changes were made.') unless confirm_action?('Are you sure that you want to delete the role?')
37
38
  # Role deletion
38
39
  role = Bebox::Role.new(role_name, project_root)
39
- role.remove
40
+ output = role.remove
40
41
  ok 'Role removed!.'
42
+ return output
41
43
  end
42
44
 
43
45
  # Add a profile to a role
@@ -47,11 +49,13 @@ module Bebox
47
49
  role = choose_option(roles, 'Choose an existing role:')
48
50
  profile = choose_option(profiles, 'Choose the profile to add:')
49
51
  if Bebox::Role.profile_in_role?(project_root, role, profile)
50
- return warn("Profile '#{profile}' already in the Role '#{role}'. No changes were made.")
52
+ warn "Profile '#{profile}' already in the Role '#{role}'. No changes were made."
53
+ output = false
51
54
  else
52
- Bebox::Role.add_profile(project_root, role, profile)
53
- return ok("Profile '#{profile}' added to Role '#{role}'.")
55
+ output = Bebox::Role.add_profile(project_root, role, profile)
56
+ ok "Profile '#{profile}' added to Role '#{role}'."
54
57
  end
58
+ return output
55
59
  end
56
60
 
57
61
  # Remove a profile in a role
@@ -61,12 +65,13 @@ module Bebox
61
65
  role = choose_option(roles, 'Choose an existing role:')
62
66
  profile = choose_option(profiles, 'Choose the profile to remove:')
63
67
  if Bebox::Role.profile_in_role?(project_root, role, profile)
64
- Bebox::Role.remove_profile(project_root, role, profile)
65
- return ok("Profile '#{profile}' removed from Role '#{role}'.")
68
+ output = Bebox::Role.remove_profile(project_root, role, profile)
69
+ ok "Profile '#{profile}' removed from Role '#{role}'."
66
70
  else
67
- return warn("Profile '#{profile}' is not in the Role '#{role}'. No changes were made.")
71
+ warn "Profile '#{profile}' is not in the Role '#{role}'. No changes were made."
72
+ output = false
68
73
  end
69
-
74
+ return output
70
75
  end
71
76
 
72
77
  # Check if there's an existing role in the project
@@ -1,5 +1,6 @@
1
1
  module Bebox
2
2
  module WizardsHelper
3
+
3
4
  # Ask for confirmation of any action
4
5
  def confirm_action?(message)
5
6
  require 'highline/import'
@@ -1,24 +1,33 @@
1
1
  require 'spec_helper'
2
2
  require_relative '../spec/factories/environment.rb'
3
3
 
4
- describe 'Test 02: Bebox::Environment' do
4
+ describe 'Test 07: Bebox::Environment' do
5
5
 
6
6
  describe 'Environment management' do
7
7
 
8
8
  subject { build(:environment) }
9
9
 
10
- it 'should list the current environments' do
10
+ it 'list the current environments' do
11
11
  current_environments = %w{vagrant staging production}
12
12
  environments = Bebox::Environment.list(subject.project_root)
13
13
  expect(environments).to include(*current_environments)
14
14
  end
15
15
 
16
16
  context 'environment creation' do
17
+ before :all do
18
+ subject.create
19
+ end
17
20
 
18
- it 'should create checkpoints' do
21
+ it 'generates SSH keys for a given environment' do
22
+ subject.generate_puppet_user_keys(subject.name)
23
+ %w{id_rsa id_rsa.pub}.each do |key|
24
+ expect(File.exist?("#{subject.project_root}/config/keys/environments/#{subject.name}/#{key}")).to be (true)
25
+ end
26
+ end
27
+
28
+ it 'creates checkpoints' do
19
29
  expected_directories = [subject.name, 'nodes', 'prepared_nodes',
20
30
  'steps', 'step-0', 'step-1', 'step-2', 'step-3']
21
- subject.create_checkpoints
22
31
  directories = []
23
32
  directories << Dir["#{subject.project_root}/.checkpoints/environments/#{subject.name}/"].map { |f| File.basename(f) }
24
33
  directories << Dir["#{subject.project_root}/.checkpoints/environments/#{subject.name}/*/"].map { |f| File.basename(f) }
@@ -26,20 +35,17 @@ describe 'Test 02: Bebox::Environment' do
26
35
  expect(directories.flatten).to include(*expected_directories)
27
36
  end
28
37
 
29
- it 'should generate capistrano base' do
30
- subject.create_capistrano_base
38
+ it 'generates a capistrano base' do
31
39
  expect(Dir.exist?("#{subject.project_root}/config/keys/environments/#{subject.name}")).to be (true)
32
40
  end
33
41
 
34
- it 'should generate deploy file' do
35
- subject.generate_deploy_file
42
+ it 'generates a deploy file' do
36
43
  deploy_content = File.read("#{subject.project_root}/config/deploy/#{subject.name}.rb").gsub(/\s+/, ' ').strip
37
44
  deploy_output_content = File.read("spec/fixtures/config/deploy/environment.test").gsub(/\s+/, ' ').strip
38
45
  expect(deploy_content).to eq(deploy_output_content)
39
46
  end
40
47
 
41
- it 'should generate hiera data file' do
42
- subject.generate_hiera_template
48
+ it 'generates a hiera data file' do
43
49
  Bebox::PROVISION_STEPS.each do |step|
44
50
  content = File.read("spec/fixtures/puppet/steps/#{step}/hiera/data/#{subject.name}.yaml.test")
45
51
  output = File.read("#{subject.project_root}/puppet/steps/#{Bebox::Provision.step_name(step)}/hiera/data/#{subject.name}.yaml")
@@ -49,11 +55,13 @@ describe 'Test 02: Bebox::Environment' do
49
55
  end
50
56
 
51
57
  context 'environment deletion' do
58
+ before :all do
59
+ subject.remove
60
+ end
52
61
 
53
- it 'should remove checkpoints' do
62
+ it 'removes checkpoints' do
54
63
  environment_directories = [subject.name, 'nodes', 'prepared_nodes',
55
64
  'steps', 'step-0', 'step-1', 'step-2', 'step-3']
56
- subject.remove_checkpoints
57
65
  directories = []
58
66
  directories << Dir["#{subject.project_root}/.checkpoints/environments/#{subject.name}/"].map { |f| File.basename(f) }
59
67
  directories << Dir["#{subject.project_root}/.checkpoints/environments/#{subject.name}/*/"].map { |f| File.basename(f) }
@@ -61,22 +69,31 @@ describe 'Test 02: Bebox::Environment' do
61
69
  expect(directories.flatten).to_not include(*environment_directories)
62
70
  end
63
71
 
64
- it 'should remove capistrano base' do
65
- subject.remove_capistrano_base
72
+ it 'removes the capistrano base' do
66
73
  expect(Dir.exist?("#{subject.project_root}/config/keys/environments/#{subject.name}")).to be (false)
67
74
  end
68
75
 
69
- it 'should remove deploy file' do
70
- subject.remove_deploy_file
76
+ it 'removes the deploy file' do
71
77
  expect(File.exist?("#{subject.project_root}/config/deploy/#{subject.name}.rb")).to be (false)
72
78
  end
73
79
 
74
- it 'should remove deploy file' do
75
- subject.remove_hiera_template
80
+ it 'removes the hiera node files' do
76
81
  Bebox::PROVISION_STEPS.each do |step|
77
82
  expect(File.exist?("#{subject.project_root}/puppet/steps/#{Bebox::Provision.step_name(step)}/hiera/data/#{subject.name}.yaml")).to be (false)
78
83
  end
79
84
  end
80
85
  end
86
+
87
+ context 'self methods' do
88
+ it 'checks for environment access keys' do
89
+ access = Bebox::Environment.check_environment_access(subject.project_root, 'vagrant')
90
+ expect(access).to eq(true)
91
+ end
92
+
93
+ it 'obtains a vagrant box base' do
94
+ environment_existence = Bebox::Environment.environment_exists?(subject.project_root, 'vagrant')
95
+ expect(environment_existence).to eq(true)
96
+ end
97
+ end
81
98
  end
82
99
  end