bebox 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,97 @@
1
+ require 'spec_helper'
2
+
3
+ require_relative '../factories/role.rb'
4
+ require_relative '../factories/profile.rb'
5
+
6
+ describe 'Test 03: Bebox::RoleWizard' do
7
+
8
+ subject { Bebox::RoleWizard.new }
9
+
10
+ let(:role) { build(:role) }
11
+ let(:profile) { build(:profile) }
12
+
13
+ before :each do
14
+ $stdout.stub(:write)
15
+ end
16
+
17
+ it 'checks if a role exists' do
18
+ output = subject.role_exists?(role.project_root, role.name)
19
+ expect(output).to eq(false)
20
+ end
21
+
22
+ context '00: role not exist' do
23
+
24
+ before :each do
25
+ subject.stub(:role_exists?) { false }
26
+ end
27
+
28
+ it 'creates a new role with wizard' do
29
+ Bebox::Role.any_instance.stub(:create) { true }
30
+ output = subject.create_new_role(role.project_root, role.name)
31
+ expect(output).to eq(true)
32
+ end
33
+
34
+ it 'can not removes a role if not exist any role' do
35
+ Bebox::Role.stub(:list) {[]}
36
+ output = subject.remove_role(role.project_root)
37
+ expect(output).to eq(nil)
38
+ end
39
+ end
40
+
41
+ context '01: role exist' do
42
+
43
+ before :each do
44
+ subject.stub(:role_exists?) { true }
45
+ end
46
+
47
+ it 'removes a role with wizard' do
48
+ Bebox::Role.stub(:list) {[role.name]}
49
+ Bebox::Role.any_instance.stub(:remove) { true }
50
+ $stdin.stub(:gets).and_return('1', 'y')
51
+ output = subject.remove_role(role.project_root)
52
+ expect(output).to eq(true)
53
+ end
54
+ end
55
+
56
+ context '02: role and profile exist' do
57
+
58
+ before :each do
59
+ subject.stub(:role_exists?) { true }
60
+ Bebox::Profile.stub(:list) {[profile.relative_path]}
61
+ Bebox::Role.stub(:list) {[role.name]}
62
+ end
63
+
64
+ it 'adds a profile to a role with wizard' do
65
+ Bebox::Role.stub(:profile_in_role?) { false }
66
+ Bebox::Role.stub(:add_profile) { true }
67
+ $stdin.stub(:gets).and_return(role.name, profile.relative_path)
68
+ output = subject.add_profile(role.project_root)
69
+ expect(output).to eq(true)
70
+ end
71
+
72
+ context '03: profile included in a role' do
73
+
74
+ it 'adds a profile to a role with wizard' do
75
+ Bebox::Role.stub(:profile_in_role?) { true }
76
+ $stdin.stub(:gets).and_return(role.name, profile.relative_path)
77
+ output = subject.add_profile(role.project_root)
78
+ expect(output).to eq(false)
79
+ end
80
+
81
+ it 'can not remove a profile that not exist in a role with wizard' do
82
+ Bebox::Role.stub(:profile_in_role?) { false }
83
+ $stdin.stub(:gets).and_return(role.name, profile.relative_path)
84
+ output = subject.remove_profile(role.project_root)
85
+ expect(output).to eq(false)
86
+ end
87
+
88
+ it 'removes a profile from a role with wizard' do
89
+ Bebox::Role.stub(:profile_in_role?) { true }
90
+ Bebox::Role.stub(:remove_profile) { true }
91
+ $stdin.stub(:gets).and_return(role.name, profile.relative_path)
92
+ output = subject.remove_profile(role.project_root)
93
+ expect(output).to eq(true)
94
+ end
95
+ end
96
+ end
97
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bebox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Codescrum
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-01 00:00:00.000000000 Z
11
+ date: 2014-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -94,6 +94,34 @@ dependencies:
94
94
  - - '='
95
95
  - !ruby/object:Gem::Version
96
96
  version: 4.3.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: codeclimate-test-reporter
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 0.4.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 0.4.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 0.9.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 0.9.0
97
125
  - !ruby/object:Gem::Dependency
98
126
  name: gli
99
127
  requirement: !ruby/object:Gem::Requirement
@@ -179,6 +207,7 @@ extensions: []
179
207
  extra_rdoc_files: []
180
208
  files:
181
209
  - ".gitignore"
210
+ - ".rspec"
182
211
  - Gemfile
183
212
  - Gemfile.lock
184
213
  - LICENSE
@@ -384,19 +413,23 @@ files:
384
413
  - spec/node0.server1.test/provision_step_3_spec.rb
385
414
  - spec/node_role_spec.rb
386
415
  - spec/node_spec.rb
387
- - spec/node_wizard_spec.rb
388
416
  - spec/ordered_phases_spec.rb
389
417
  - spec/pre_prepare_spec.rb
390
418
  - spec/pre_provision_steps_spec.rb
391
419
  - spec/profile_spec.rb
392
420
  - spec/project_spec.rb
393
- - spec/project_wizard_spec.rb
394
421
  - spec/puppet_spec_helper.rb
395
422
  - spec/role_profiles_spec.rb
396
423
  - spec/role_spec.rb
397
424
  - spec/spec_helper.rb
398
425
  - spec/support/config_specs.yaml.example
399
426
  - spec/vagrant_spec_helper.rb
427
+ - spec/wizards/environment_wizard_spec.rb
428
+ - spec/wizards/node_wizard_spec.rb
429
+ - spec/wizards/profile_wizard_spec.rb
430
+ - spec/wizards/project_wizard_spec.rb
431
+ - spec/wizards/provision_wizard_spec.rb
432
+ - spec/wizards/role_wizard_spec.rb
400
433
  homepage: http://www.codescrum.com
401
434
  licenses:
402
435
  - MIT
@@ -1,22 +0,0 @@
1
- require 'spec_helper'
2
-
3
- require_relative '../spec/factories/node.rb'
4
-
5
- describe 'Test 03: Manage nodes with the wizard' do
6
-
7
- subject { Bebox::NodeWizard.new }
8
-
9
- let(:project_root) { "#{Dir.pwd}/tmp/bebox-pname" }
10
- let(:environment) { "vagrant" }
11
- let(:node_hostname) { "node_0.server1.test" }
12
- let(:node_ip) { YAML.load_file('spec/support/config_specs.yaml')['test_ip'] }
13
-
14
- it 'should check node existence' do
15
- output = subject.node_exists?(project_root, environment, node_hostname)
16
- expect(output).to eq(false)
17
- end
18
-
19
- it 'the ip should be free' do
20
- expect(subject.free_ip?(node_ip)).to eq(true)
21
- end
22
- end
@@ -1,51 +0,0 @@
1
- require 'spec_helper'
2
- # require 'vcr'
3
-
4
- require_relative '../spec/factories/project.rb'
5
-
6
- describe 'Test 00: Create a new project with the wizard' 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
- it 'should check project existence' do
19
- output = subject.project_exists?(parent_path, project_name)
20
- expect(output).to eq(false)
21
- end
22
-
23
- it 'should setup the bebox boxes directory' do
24
- subject.bebox_boxes_setup
25
- expect(Dir.exist?("#{bebox_boxes_path}/tmp")).to eq(true)
26
- expect(Dir["#{bebox_boxes_path}/tmp/*"].count).to eq(0)
27
- end
28
-
29
- it 'should validate an http box uri' do
30
- output = subject.uri_valid?(http_box_uri)
31
- expect(output).to eq(true)
32
- end
33
-
34
- it 'should validate a local-file box uri' do
35
- output = subject.uri_valid?(local_box_uri)
36
- expect(output).to eq(true)
37
- end
38
-
39
- # it 'should download an http box' do
40
- # VCR.use_cassette('box_download') do
41
- # subject.set_box(http_box_uri)
42
- # end
43
- # expect(File.exist?("#{bebox_boxes_path}/ubuntu-server-12042-x64-vbox4210-nocm.box")).to eq(true)
44
- # end
45
-
46
- it 'should link a local file box' do
47
- subject.set_box(local_box_uri)
48
- expect(File.symlink?("#{bebox_boxes_path}/test_box.box")).to eq(true)
49
- end
50
- end
51
- end