vagrant_spec 0.0.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 (43) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +6 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +2 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +10 -0
  7. data/Gemfile +10 -0
  8. data/LICENSE +13 -0
  9. data/README.md +146 -0
  10. data/Rakefile +26 -0
  11. data/Vagrantfile +27 -0
  12. data/lib/vagrant_spec/ansible_inventory.rb +80 -0
  13. data/lib/vagrant_spec/command/base.rb +74 -0
  14. data/lib/vagrant_spec/command/init.rb +45 -0
  15. data/lib/vagrant_spec/command/test.rb +32 -0
  16. data/lib/vagrant_spec/command.rb +9 -0
  17. data/lib/vagrant_spec/config/base.rb +42 -0
  18. data/lib/vagrant_spec/config.rb +20 -0
  19. data/lib/vagrant_spec/machine_finder.rb +31 -0
  20. data/lib/vagrant_spec/spec_helper.rb +42 -0
  21. data/lib/vagrant_spec/templates/spec_helper.erb +19 -0
  22. data/lib/vagrant_spec/templates/vagrantspec_inventory.erb +12 -0
  23. data/lib/vagrant_spec/test_plan.rb +68 -0
  24. data/lib/vagrant_spec/utils.rb +23 -0
  25. data/lib/vagrant_spec/version.rb +6 -0
  26. data/lib/vagrant_spec.rb +27 -0
  27. data/scripts/poor_mans_smoke_test.sh +17 -0
  28. data/serverspec/fail_spec.rb +7 -0
  29. data/serverspec/ssh_spec.rb +10 -0
  30. data/spec/unit/spec_helper.rb +101 -0
  31. data/spec/unit/vagrant_spec_spec.rb +13 -0
  32. data/spec/unit/vagrant_spec_test/ansible_inventory_spec.rb +143 -0
  33. data/spec/unit/vagrant_spec_test/command_spec/base_spec.rb +105 -0
  34. data/spec/unit/vagrant_spec_test/command_spec/init_spec.rb +87 -0
  35. data/spec/unit/vagrant_spec_test/command_spec/test_spec.rb +45 -0
  36. data/spec/unit/vagrant_spec_test/config_spec/base_spec.rb +34 -0
  37. data/spec/unit/vagrant_spec_test/config_spec.rb +15 -0
  38. data/spec/unit/vagrant_spec_test/machine_finder_spec.rb +27 -0
  39. data/spec/unit/vagrant_spec_test/spec_helper_spec.rb +41 -0
  40. data/spec/unit/vagrant_spec_test/test_plan_spec.rb +104 -0
  41. data/spec/unit/vagrant_spec_test/utils_spec.rb +24 -0
  42. data/vagrant_spec.gemspec +30 -0
  43. metadata +184 -0
@@ -0,0 +1,15 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'spec_helper'
4
+ require 'vagrant_spec/config'
5
+
6
+ describe VagrantSpec::Config do
7
+ include_examples 'unit'
8
+ include_examples 'shared_mocks'
9
+
10
+ it '#self.load should return the config for the working vagrantfile' do
11
+ expect(iso_env).to receive(:vagrantfile) { mock_vf_obj }
12
+ expect(mock_vf_obj).to receive(:config) { mock_config }
13
+ VagrantSpec::Config.load(iso_env)
14
+ end
15
+ end
@@ -0,0 +1,27 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'spec_helper'
4
+ require 'vagrant_spec/machine_finder'
5
+
6
+ describe VagrantSpec::MachineFinder do
7
+ include_context 'unit'
8
+ include_examples 'shared_mocks'
9
+
10
+ before do
11
+ allow(iso_env).to receive(:active_machines) { [['node1', :virtualbox]] }
12
+ allow(mock_node).to receive(:name) { 'node1' }
13
+
14
+ allow(iso_env).to receive(:machine).with('node1', :virtualbox) { mock_node }
15
+ end
16
+
17
+ subject { VagrantSpec::MachineFinder.new(iso_env) }
18
+
19
+ it '#machine returns the node if found' do
20
+ expect(subject.machine('node1')).to eq(mock_node)
21
+ end
22
+
23
+ it '#match_nodes returns an array of found Vagrant::Machine objects' do
24
+ allow(subject).to receive(:machine) { mock_node }
25
+ expect(subject.match_nodes(/node/)).to eq([mock_node])
26
+ end
27
+ end
@@ -0,0 +1,41 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'spec_helper'
4
+ require 'vagrant_spec/spec_helper'
5
+ require 'vagrant_spec/utils'
6
+
7
+ describe VagrantSpec::SpecHelper do
8
+ include_context 'unit'
9
+ include_examples 'shared_mocks'
10
+
11
+ subject { VagrantSpec::SpecHelper.new(iso_env) }
12
+
13
+ context 'when @directory does not exist' do
14
+ it '#create_directory creates the directory' do
15
+ allow(Dir).to receive(:exist?) { false }
16
+ allow(Dir).to receive(:mkdir)
17
+ expect(Dir).to receive(:mkdir)
18
+
19
+ subject.create_directory
20
+ end
21
+ end
22
+
23
+ context 'when @directory does exist' do
24
+ it '#create_directory does not create the directory' do
25
+ allow(Dir).to receive(:exist?) { true }
26
+ allow(Dir).to receive(:mkdir)
27
+ expect(Dir).not_to receive(:mkdir)
28
+
29
+ subject.create_directory
30
+ end
31
+ end
32
+
33
+ it '#spec_helper_path returns serverspec/spec_helper.rb' do
34
+ expect(subject.spec_helper_path).to eq('serverspec/spec_helper.rb')
35
+ end
36
+
37
+ it '#spec_helper_template includes vagrant_spec/templates/spec_helper.erb' do
38
+ result = subject.spec_helper_template
39
+ expect(result).to match(%r{vagrant_spec/templates/spec_helper.erb})
40
+ end
41
+ end
@@ -0,0 +1,104 @@
1
+ # encoding: UTF-8
2
+
3
+ # Local
4
+ require 'spec_helper'
5
+ require 'vagrant_spec/test_plan'
6
+ require 'vagrant_spec/command/test'
7
+ require 'rspec/support/spec/in_sub_process'
8
+ require 'rspec/support/spec/stderr_splitter'
9
+
10
+ describe VagrantSpec::TestPlan do
11
+ include RSpec::Support::InSubProcess
12
+ include_context 'unit'
13
+
14
+ ##############################################################################
15
+ # mocks
16
+
17
+ include_examples 'shared_mocks'
18
+
19
+ let(:mock_plan) do
20
+ [
21
+ {
22
+ 'nodes' => /test1/,
23
+ 'flags' => '--format documentation --color --pattern serverspec/ssh*'
24
+ },
25
+ {
26
+ 'nodes' => %w(test2),
27
+ 'flags' => '--format documentation --color --pattern serverspec/fail*'
28
+ }
29
+ ]
30
+ end
31
+
32
+ let(:mock_ssh_info) do
33
+ {
34
+ host: 'test_host',
35
+ port: '2222',
36
+ private_key_path: ['path_to_key'],
37
+ username: 'vagrant'
38
+ }
39
+ end
40
+
41
+ ##############################################################################
42
+ # Stubs
43
+
44
+ before do
45
+ allow_any_instance_of(VagrantSpec::MachineFinder)
46
+ .to receive(:match_nodes) { [double(Vagrant::Machine)] }
47
+ allow_any_instance_of(VagrantSpec::MachineFinder)
48
+ .to receive(:machine) { double(Vagrant::Machine) }
49
+
50
+ allow(RSpec::Core::Runner).to receive(:run) { 0 }
51
+ allow(iso_env).to receive(:ui)
52
+ allow(mock_node).to receive(:name)
53
+
54
+ allow(iso_env).to receive(:ui) { mock_ui }
55
+ allow(mock_ui).to receive(:info)
56
+ allow(mock_spec).to receive(:test_plan) { mock_plan }
57
+ allow(mock_node).to receive(:ssh_info) { mock_ssh_info }
58
+ end
59
+
60
+ subject { VagrantSpec::TestPlan.new(iso_env) }
61
+
62
+ ##############################################################################
63
+ # Testing #nodes
64
+
65
+ context 'when passing a Regexp object' do
66
+ it '#nodes calls match_nodes on a machine_finder instance' do
67
+ expect(subject.m_finder).to receive(:match_nodes)
68
+ subject.nodes(mock_plan[0])
69
+ end
70
+ end
71
+
72
+ context 'when passing an Array object' do
73
+ it "#nodes calls collect on a the plan's nodes" do
74
+ expect(mock_plan[1]['nodes']).to receive(:collect)
75
+ subject.nodes(mock_plan[1])
76
+ end
77
+
78
+ it '#nodes calls machine on the machine_finder instance' do
79
+ expect(subject.m_finder).to receive(:machine)
80
+ subject.nodes(mock_plan[1])
81
+ end
82
+ end
83
+
84
+ ##############################################################################
85
+ # Testing #execute_plan_tests
86
+ #
87
+ # These tests must be executed in a sub process because execute_plan_tests
88
+ # executes clear_examples. clear_examples modifies global state, so we must
89
+ # contain it.
90
+
91
+ it '#execute_plan_tests runs the RSPec tests' do
92
+ in_sub_process do
93
+ expect(RSpec::Core::Runner).to receive(:run)
94
+ subject.execute_plan_tests(mock_node, mock_plan[0])
95
+ end
96
+ end
97
+
98
+ it '#execute adds the spec.directory to the load path' do
99
+ in_sub_process do
100
+ subject.execute_plan_tests(mock_node, mock_plan[0])
101
+ expect(subject.test_plan[0]['flags']).to include('-I serverspec')
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,24 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'spec_helper'
4
+ require 'vagrant_spec/utils'
5
+
6
+ describe VagrantSpec::Utils do
7
+ let(:klass) do
8
+ Class.new { include VagrantSpec::Utils }.new
9
+ end
10
+
11
+ it '#project_root dirname is vagrant_spec' do
12
+ expect(File.basename(klass.project_root)).to eq('vagrant_spec')
13
+ end
14
+
15
+ it '#lib_root contains vagrant_spec/lib' do
16
+ expect(klass.lib_root).to match(Regexp.new('.*vagrant_spec/lib'))
17
+ end
18
+
19
+ it '#template_dir contains vagrant_spec/lib/vagrant_spec/templates' do
20
+ expect(klass.template_dir).to match(
21
+ Regexp.new('.*vagrant_spec/lib/vagrant_spec/templates')
22
+ )
23
+ end
24
+ end
@@ -0,0 +1,30 @@
1
+ # encoding: UTF-8
2
+
3
+ require File.expand_path('../lib/vagrant_spec/version', __FILE__)
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'vagrant_spec'
7
+ s.version = VagrantSpec::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = %w(Demitri Swan)
10
+ s.email = %w(demitriswan@gmail.com)
11
+ s.homepage = 'http://github.com/miroswan/vagrant_spec'
12
+ s.summary = 'ServerSpec testing with Vagrant for clustered systems'
13
+ s.description = <<-EOF.gsub(/^ {4}/, '')
14
+ This plugin supports ServerSpec testing against clustered systems by
15
+ allowing Vagrant to build and provision all instances before
16
+ running ServerSpec tests.
17
+ EOF
18
+
19
+ s.add_dependency 'serverspec', '~> 2.36.0'
20
+ s.add_dependency 'ruby_dep', '~> 1.3.1'
21
+
22
+ s.add_development_dependency 'bundler'
23
+ s.add_development_dependency 'rubocop'
24
+ s.add_development_dependency 'rake'
25
+ s.add_development_dependency 'coveralls'
26
+
27
+ s.files = `git ls-files`.split("\n")
28
+ s.test_files = s.files.grep(/^(spec)/)
29
+ s.require_path = 'lib'
30
+ end
metadata ADDED
@@ -0,0 +1,184 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant_spec
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Demitri
8
+ - Swan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-08-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: serverspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 2.36.0
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 2.36.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: ruby_dep
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 1.3.1
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 1.3.1
42
+ - !ruby/object:Gem::Dependency
43
+ name: bundler
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rubocop
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rake
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: coveralls
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ description: |
99
+ This plugin supports ServerSpec testing against clustered systems by
100
+ allowing Vagrant to build and provision all instances before
101
+ running ServerSpec tests.
102
+ email:
103
+ - demitriswan@gmail.com
104
+ executables: []
105
+ extensions: []
106
+ extra_rdoc_files: []
107
+ files:
108
+ - ".gitignore"
109
+ - ".rspec"
110
+ - ".rubocop.yml"
111
+ - ".ruby-version"
112
+ - ".travis.yml"
113
+ - Gemfile
114
+ - LICENSE
115
+ - README.md
116
+ - Rakefile
117
+ - Vagrantfile
118
+ - lib/vagrant_spec.rb
119
+ - lib/vagrant_spec/ansible_inventory.rb
120
+ - lib/vagrant_spec/command.rb
121
+ - lib/vagrant_spec/command/base.rb
122
+ - lib/vagrant_spec/command/init.rb
123
+ - lib/vagrant_spec/command/test.rb
124
+ - lib/vagrant_spec/config.rb
125
+ - lib/vagrant_spec/config/base.rb
126
+ - lib/vagrant_spec/machine_finder.rb
127
+ - lib/vagrant_spec/spec_helper.rb
128
+ - lib/vagrant_spec/templates/spec_helper.erb
129
+ - lib/vagrant_spec/templates/vagrantspec_inventory.erb
130
+ - lib/vagrant_spec/test_plan.rb
131
+ - lib/vagrant_spec/utils.rb
132
+ - lib/vagrant_spec/version.rb
133
+ - scripts/poor_mans_smoke_test.sh
134
+ - serverspec/fail_spec.rb
135
+ - serverspec/ssh_spec.rb
136
+ - spec/unit/spec_helper.rb
137
+ - spec/unit/vagrant_spec_spec.rb
138
+ - spec/unit/vagrant_spec_test/ansible_inventory_spec.rb
139
+ - spec/unit/vagrant_spec_test/command_spec/base_spec.rb
140
+ - spec/unit/vagrant_spec_test/command_spec/init_spec.rb
141
+ - spec/unit/vagrant_spec_test/command_spec/test_spec.rb
142
+ - spec/unit/vagrant_spec_test/config_spec.rb
143
+ - spec/unit/vagrant_spec_test/config_spec/base_spec.rb
144
+ - spec/unit/vagrant_spec_test/machine_finder_spec.rb
145
+ - spec/unit/vagrant_spec_test/spec_helper_spec.rb
146
+ - spec/unit/vagrant_spec_test/test_plan_spec.rb
147
+ - spec/unit/vagrant_spec_test/utils_spec.rb
148
+ - vagrant_spec.gemspec
149
+ homepage: http://github.com/miroswan/vagrant_spec
150
+ licenses: []
151
+ metadata: {}
152
+ post_install_message:
153
+ rdoc_options: []
154
+ require_paths:
155
+ - lib
156
+ required_ruby_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ requirements: []
167
+ rubyforge_project:
168
+ rubygems_version: 2.4.5.1
169
+ signing_key:
170
+ specification_version: 4
171
+ summary: ServerSpec testing with Vagrant for clustered systems
172
+ test_files:
173
+ - spec/unit/spec_helper.rb
174
+ - spec/unit/vagrant_spec_spec.rb
175
+ - spec/unit/vagrant_spec_test/ansible_inventory_spec.rb
176
+ - spec/unit/vagrant_spec_test/command_spec/base_spec.rb
177
+ - spec/unit/vagrant_spec_test/command_spec/init_spec.rb
178
+ - spec/unit/vagrant_spec_test/command_spec/test_spec.rb
179
+ - spec/unit/vagrant_spec_test/config_spec.rb
180
+ - spec/unit/vagrant_spec_test/config_spec/base_spec.rb
181
+ - spec/unit/vagrant_spec_test/machine_finder_spec.rb
182
+ - spec/unit/vagrant_spec_test/spec_helper_spec.rb
183
+ - spec/unit/vagrant_spec_test/test_plan_spec.rb
184
+ - spec/unit/vagrant_spec_test/utils_spec.rb