inspec-core 3.7.11 → 3.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -0
  3. data/lib/inspec/reporters/automate.rb +0 -4
  4. data/lib/inspec/reporters/json_automate.rb +7 -1
  5. data/lib/inspec/version.rb +1 -1
  6. metadata +2 -39
  7. data/lib/plugins/inspec-artifact/test/functional/inspec_artifact_test.rb +0 -46
  8. data/lib/plugins/inspec-compliance/test/functional/inspec_compliance_test.rb +0 -43
  9. data/lib/plugins/inspec-compliance/test/integration/default/cli.rb +0 -93
  10. data/lib/plugins/inspec-compliance/test/unit/api/login_test.rb +0 -190
  11. data/lib/plugins/inspec-compliance/test/unit/api_test.rb +0 -385
  12. data/lib/plugins/inspec-compliance/test/unit/target_test.rb +0 -155
  13. data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/Berksfile +0 -2
  14. data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/README.md +0 -3
  15. data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/files/hab_setup.exp +0 -28
  16. data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/metadata.rb +0 -9
  17. data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/recipes/default.rb +0 -61
  18. data/lib/plugins/inspec-habitat/test/functional/inspec_habitat_test.rb +0 -38
  19. data/lib/plugins/inspec-habitat/test/integration/default/inspec_habitat/README.md +0 -3
  20. data/lib/plugins/inspec-habitat/test/integration/default/inspec_habitat/controls/inspec_habitat.rb +0 -40
  21. data/lib/plugins/inspec-habitat/test/integration/default/inspec_habitat/inspec.yml +0 -10
  22. data/lib/plugins/inspec-habitat/test/support/example_profile/README.md +0 -3
  23. data/lib/plugins/inspec-habitat/test/support/example_profile/controls/example.rb +0 -7
  24. data/lib/plugins/inspec-habitat/test/support/example_profile/inspec.yml +0 -10
  25. data/lib/plugins/inspec-habitat/test/unit/profile_test.rb +0 -240
  26. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/fixtures/README.md +0 -24
  27. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/functional/README.md +0 -12
  28. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/functional/inspec_plugin_template_test.rb +0 -110
  29. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/helper.rb +0 -26
  30. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/unit/README.md +0 -17
  31. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/unit/cli_args_test.rb +0 -67
  32. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/unit/plugin_def_test.rb +0 -51
  33. data/lib/plugins/inspec-init/test/functional/inspec_init_plugin_test.rb +0 -173
  34. data/lib/plugins/inspec-init/test/functional/inspec_init_profile_test.rb +0 -100
  35. data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/config_dirs/empty/.gitkeep +0 -0
  36. data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/inspec-egg-white-omelette/lib/inspec-egg-white-omelette.rb +0 -2
  37. data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/inspec-egg-white-omelette/lib/inspec-egg-white-omelette/.gitkeep +0 -0
  38. data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/inspec-wrong-structure/.gitkeep +0 -0
  39. data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/wrong-name/lib/wrong-name.rb +0 -1
  40. data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/wrong-name/lib/wrong-name/.gitkeep +0 -0
  41. data/lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb +0 -713
  42. data/lib/plugins/inspec-plugin-manager-cli/test/unit/cli_args_test.rb +0 -75
  43. data/lib/plugins/inspec-plugin-manager-cli/test/unit/plugin_def_test.rb +0 -20
@@ -1,24 +0,0 @@
1
- # Test Fixtures Area
2
-
3
- In this directory, you would place things that you need during testing. For example, if you were making a plugin that counts the number of controls in a profile, you might have a directory tree like this:
4
-
5
- ```
6
- fixtures/
7
- profiles/
8
- zero-controls/
9
- inspec.yml
10
- controls/
11
- twelve-controls/
12
- inspec.yml
13
- controls/
14
- nine.rb
15
- three.rb
16
- ```
17
-
18
- When writing your functional tests, you can point InSpec at the various test fixture profiles, and know that when it points at the zero-controls profile, it should find no controls; and when pointed at the twelve-controls profile, it should find 12.
19
-
20
- ## Using test fixtures provided with the `inspec` source code
21
-
22
- InSpec itself ships with many test fixtures - not just profiles, but attribute files, configuration directories, and more. Examine them at [the fixtures directory](https://github.com/inspec/inspec/tree/master/test/unit/mock)
23
-
24
- To use them, see the helper.rb file included in the example at test/helper.rb .
@@ -1,12 +0,0 @@
1
- # Functional Testing Area for Plugins
2
-
3
- ## What are functional tests?
4
-
5
- Functional tests are tests that verify that your plugin works _as would be seen by a user_. Functional tests generally do not have inside knowledge about the inner workings of the plugin. However a functional test is very interested in changes that your plugin makes to the outside world: exit codes, command output, changes to files on the filesystem, etc.
6
-
7
- To be picked up by the Rake tasks as tests, each test file should end in `_test.rb`.
8
-
9
- ## Unit vs Functional Tests
10
-
11
- A practical difference between unit tests and functional tests is that unit tests all run within one process, while functional tests might exercise a CLI plugin by shelling out to an `inspec` invocation in a subprocess, and examining the results.
12
-
@@ -1,110 +0,0 @@
1
- # Functional Tests for Example Plugin, Resource Lister
2
-
3
- # Functional tests are used to verify the behavior of the plugin are as expected, to a user.
4
- # Functional tests generally do not have inside knowledge of how the plugin works.
5
-
6
- # Include our test harness
7
- require_relative '../helper'
8
-
9
- # Because InSpec is a Spec-style test suite, we're going to use MiniTest::Spec
10
- # here, for familiar look and feel. However, this isn't InSpec (or RSpec) code.
11
- describe 'inspec list-resources core' do
12
- # Our helper.rb locates this library from the InSpec install that
13
- # Bundler installed for us. If we want its methods, we still must
14
- # import it. Including it here will make it available in all child
15
- # 'describe' blocks.
16
- include CorePluginFunctionalHelper
17
-
18
- # When thinking up scenarios to test, start with the simplest.
19
- # Then think of each major feature, and exercise them.
20
- # Running combinations of features makes sense if it is very likely,
21
- # or a difficult / dangerous case. You can always add more tests
22
- # here as users find subtle problems. In fact, having a user submit
23
- # a PR that creates a failing functional test is a great way to
24
- # capture the reproduction case.
25
- # The simplest case:
26
- describe "when run without an argument" do
27
-
28
- # run_inspec_process_with_this_plugin is a helper provided by
29
- # CoreFunctionalHelper. It makes the InSpec that Bundler installed
30
- # think that this plugin we are currently testing is installed as a
31
- # user plugin, by writing a plugin config file in a temp dir.
32
- # To use it, just provide a command line, minus the word `inspec`.
33
- let (:outcome) { run_inspec_process_with_this_plugin('listresources core') }
34
-
35
- # Some tests through here use minitest Expectations, which attach to all
36
- # Objects, and begin with 'must' (positive) or 'wont' (negative)
37
- # See https://ruby-doc.org/stdlib-2.1.0/libdoc/minitest/rdoc/MiniTest/Expectations.html
38
- it("should exit successfully") { outcome.exit_status.must_equal(0) }
39
- it("should be silent on stderr") { outcome.stderr.must_be_empty }
40
-
41
- # A selection of core resources, just spot checking.
42
- # This is an example of using Ruby to define sets of tests.
43
- ['process', 'service', 'user', 'file'].each do |resource_name|
44
- it "should mention the '#{resource_name}' resource" do
45
- outcome.stdout.must_include(resource_name)
46
- end
47
- end
48
-
49
- # Check for the summary
50
- it "should mention the summary" do
51
- outcome.stdout.must_include('resources total')
52
- end
53
- end
54
-
55
- # Test the search pattern feature, in a couple of ways.
56
- describe "when run with a search pattern that matches things" do
57
- # Notice that the command line is changed here:
58
- # "list all resources that have the word user in them"
59
- let (:outcome) { run_inspec_process_with_this_plugin('listresources core user') }
60
-
61
- # Should be well-behaved...
62
- it("should exit successfully") { outcome.exit_status.must_equal(0) }
63
- it("should be silent on stderr") { outcome.stderr.must_be_empty }
64
-
65
- # Here, we want to know it DID match some things, and NOT some others.
66
- ['user', 'users'].each do |resource_name|
67
- it "should mention the '#{resource_name}' resource" do
68
- outcome.stdout.must_include(resource_name)
69
- end
70
- end
71
- ['process', 'service', 'file'].each do |resource_name|
72
- it "should NOT mention the '#{resource_name}' resource" do
73
- outcome.stdout.wont_include(resource_name)
74
- end
75
- end
76
- end
77
- describe "when run with a search pattern that matches nothing" do
78
- # Unlikely we'll have a resource with the string 'autogyro' in it.
79
- let (:outcome) { run_inspec_process_with_this_plugin('listresources core autogyro') }
80
-
81
- # Should be well-behaved...
82
- it("should exit successfully") { outcome.exit_status.must_equal(0) }
83
- it("should be silent on stderr") { outcome.stderr.must_be_empty }
84
-
85
- # Output lines should be just two, for the summary.
86
- it "should only have two output lines" do
87
- outcome.stdout.split("\n").count.must_equal(2)
88
- end
89
-
90
- # Check for the summary
91
- it "should mention a zero-resource summary" do
92
- outcome.stdout.must_include('0 resources total')
93
- end
94
- end
95
-
96
- # Exercise the summary option, which defaults to 'true'.
97
- describe "when run with the no-summary flag" do
98
- # Alter the command string to include the no-summary option
99
- let(:outcome) { run_inspec_process_with_this_plugin('listresources core --no-summary') }
100
-
101
- # Should be well-behaved...
102
- it("should exit successfully") { outcome.exit_status.must_equal(0) }
103
- it("should be silent on stderr") { outcome.stderr.must_be_empty }
104
-
105
- # Check for the summary
106
- it "should NOT mention summary" do
107
- outcome.stdout.wont_include('0 resources total')
108
- end
109
- end
110
- end
@@ -1,26 +0,0 @@
1
- # Test helper file for non-core plugins
2
-
3
- # This file's job is to collect any libraries needed for testing, as well as provide
4
- # any utilities to make testing a plugin easier.
5
-
6
- # InSpec core provides a number of such libraries and facilities, in the file
7
- # lib/plugins/shared/core_plugin_test_helper.rb . So, one job in this file is
8
- # to locate and load that file.
9
- require 'inspec/../plugins/shared/core_plugin_test_helper'
10
-
11
- # Also load the InSpec plugin system. We need this so we can unit-test the plugin
12
- # classes, which will rely on the plugin system.
13
- require 'inspec/plugin/v2'
14
-
15
- # Caution: loading all of InSpec (i.e. require 'inspec') may cause interference with
16
- # minitest/spec; one symptom would be appearing to have no tests.
17
- # See https://github.com/inspec/inspec/issues/3380
18
-
19
- # You can select from a number of test harnesses. Since InSpec uses Spec-style controls
20
- # in profile code, you will probably want to use something like minitest/spec, which provides
21
- # Spec-style tests.
22
- require 'minitest/spec'
23
- require 'minitest/autorun'
24
-
25
- # You might want to put some debugging tools here. We run tests to find bugs, after all.
26
- require 'byebug'
@@ -1,17 +0,0 @@
1
- # Unit Testing Area for Plugins
2
-
3
- ## What Tests are Provided?
4
-
5
- * plugin_def_test.rb - Would be useful in any plugin. Verifies that the plugin is properly detected and registered.
6
- <% if hooks.key?(:cli_command) %>
7
- * cli_args_test.rb - Tests the CLI options for a CLI Command plugin
8
- <% end %>
9
-
10
- ## What are Unit Tests?
11
-
12
- Unit tests are tests that verify that the individual components of your plugin work as intended. To be picked up by the Rake tasks as tests, each test file should end in `_test.rb`.
13
-
14
- ## Unit vs Functional Tests
15
-
16
- A practical difference between unit tests and functional tests is that unit tests all run within one process, while functional tests might exercise a CLI plugin by shelling out to an inspec command in a subprocess, and examining the results.
17
-
@@ -1,67 +0,0 @@
1
- # This unit test performs some tests to verify that the command line options for
2
- # <%= plugin_name %> are correct.
3
-
4
- # Include our test harness
5
- require_relative '../helper'
6
-
7
- # Load the class under test, the CliCommand definition.
8
- require '<%= plugin_name %>/cli_command'
9
-
10
- # Because InSpec is a Spec-style test suite, we're going to use MiniTest::Spec
11
- # here, for familiar look and feel. However, this isn't InSpec (or RSpec) code.
12
- describe InspecPlugins::<%= module_name %>::CliCommand do
13
-
14
- # When writing tests, you can use `let` to create variables that you
15
- # can reference easily.
16
-
17
- # This is the CLI Command implementation class.
18
- # It is a subclass of Thor, which is a CLI framework.
19
- # This unit test file is mostly about verifying the Thor settings.
20
- let(:cli_class) { InspecPlugins::<%= module_name %>::CliCommand }
21
-
22
- # From this point onwards, this test file assumes you did not rename
23
- # the provided 'do_something' subcommand. As you implement your plugin,
24
- # modify and add to the lines below to test your actual options.
25
-
26
- # This is a Hash of Structs that tells us details of options for the 'do_something' subcommand.
27
- let(:do_something_options) { cli_class.all_commands['do_something'].options }
28
-
29
- # To group tests together, you can nest 'describe' in minitest/spec
30
- describe 'the do-something subcommand' do
31
-
32
- # Some tests through here use minitest Expectations, which attach to all
33
- # Objects, and begin with 'must' (positive) or 'wont' (negative)
34
- # See https://ruby-doc.org/stdlib-2.1.0/libdoc/minitest/rdoc/MiniTest/Expectations.html
35
-
36
- # Option count OK?
37
- it "should take one option" do
38
- do_something_options.count.must_equal(1)
39
- end
40
-
41
- # Summary option
42
- describe "the summary option" do
43
- it "should be present" do
44
- do_something_options.keys.must_include(:summary)
45
- end
46
- it "should have a description" do
47
- do_something_options[:summary].description.wont_be_nil
48
- end
49
- it "should not be required" do
50
- do_something_options[:summary].required.wont_equal(true)
51
- end
52
- it "should have a single-letter alias" do
53
- do_something_options[:summary].aliases.must_include(:s)
54
- end
55
- end
56
-
57
- # Argument count
58
- # The 'do-something' command takes one optional argument. According to the
59
- # metaprogramming rules of Ruby, the do_something() method should thus have an
60
- # arity of -1. See http://ruby-doc.org/core-2.5.1/Method.html#method-i-arity
61
- # for how that number is caclulated.
62
- it "should take one optional argument" do
63
- cli_class.instance_method(:do_something).arity.must_equal(-1)
64
- end
65
-
66
- end
67
- end
@@ -1,51 +0,0 @@
1
- # This unit test performs some tests to verify that
2
- # the inspec-resource-lister plugin is configured correctly.
3
-
4
- # Include our test harness
5
- require_relative '../helper'
6
-
7
- # Load the class under test, the Plugin definition.
8
- require '<%= plugin_name %>/plugin'
9
-
10
- # Because InSpec is a Spec-style test suite, we're going to use MiniTest::Spec
11
- # here, for familiar look and feel. However, this isn't InSpec (or RSpec) code.
12
-
13
- describe InspecPlugins::<%= module_name %>::Plugin do
14
-
15
- # When writing tests, you can use `let` to create variables that you
16
- # can reference easily.
17
-
18
- # Internally, plugins are always known by a Symbol name. Convert here.
19
- let(:plugin_name) { :'<%= plugin_name %>' }
20
-
21
- # The Registry knows about all plugins that ship with InSpec by
22
- # default, as well as any that are installed by the user. When a
23
- # plugin definition is loaded, it will also self-register.
24
- let(:registry) { Inspec::Plugin::V2::Registry.instance }
25
-
26
- # The plugin status record tells us what the Registry knows.
27
- # Note that you can use previously-defined 'let's.
28
- let(:status) { registry[plugin_name] }
29
-
30
- # OK, actual tests!
31
-
32
- # Does the Registry know about us at all?
33
- it "should be registered" do
34
- registry.known_plugin?(plugin_name)
35
- end
36
-
37
- # Some tests through here use minitest Expectations, which attach to all
38
- # Objects, and begin with 'must' (positive) or 'wont' (negative)
39
- # See https://ruby-doc.org/stdlib-2.1.0/libdoc/minitest/rdoc/MiniTest/Expectations.html
40
-
41
- # The plugin system had an undocumented v1 API; this should be a v2 example.
42
- it "should be an api-v2 plugin" do
43
- status.api_generation.must_equal(2)
44
- end
45
-
46
- # Plugins can support several different activator hooks, each of which has a type.
47
- # Since this is (primarily) a CliCommand plugin, we'd expect to see that among our types.
48
- it "should include a cli_command activator hook" do
49
- status.plugin_types.must_include(:cli_command)
50
- end
51
- end
@@ -1,173 +0,0 @@
1
- require_relative '../../../shared/core_plugin_test_helper.rb'
2
-
3
- class InitPluginCli < MiniTest::Test
4
- include CorePluginFunctionalHelper
5
-
6
- def test_generating_inspec_plugin_correct_prefix_required
7
- Dir.mktmpdir do |dir|
8
- plugin = 'wacky-name'
9
- run_result = run_inspec_process("init plugin --no-prompt #{plugin} ", prefix: "cd #{dir} &&")
10
- assert_equal 1, run_result.exit_status
11
- assert_empty run_result.stderr
12
- assert_includes run_result.stdout, 'ERROR'
13
- assert_includes run_result.stdout, 'Plugin names must begin with'
14
- end
15
- end
16
-
17
- def test_generating_inspec_plugin_with_default_options
18
- Dir.mktmpdir do |dir|
19
- plugin = 'inspec-test-generated-plugin'
20
- snake_case = plugin.tr('-', '_')
21
- module_name = plugin.sub(/^inspec\-/, '').split('-').map(&:capitalize).join('')
22
-
23
- run_result = run_inspec_process("init plugin --no-prompt #{plugin}", prefix: "cd #{dir} &&")
24
- assert_empty run_result.stderr
25
-
26
- assert_equal 0, run_result.exit_status
27
- assert_includes run_result.stdout, 'Creating new inspec plugin at'
28
- assert_includes run_result.stdout, plugin
29
-
30
- # Check generated files and contents.
31
- # Each file must exist, and its contents must match each of the regexen given.
32
- {
33
- File.join(plugin, 'README.md') => [
34
- /#{plugin}/
35
- ],
36
- File.join(plugin, 'LICENSE') => [
37
- /(?!opyright)/, # No copyright by default
38
- /Apache License/,
39
- ],
40
- File.join(plugin, 'Gemfile') => [], # No interpolation
41
- File.join(plugin, 'Rakefile') => [], # No interpolation
42
- File.join(plugin, plugin + '.gemspec') => [
43
- /require '#{plugin}\/version'/,
44
- /spec\.name\s+=\s+'#{plugin}'/,
45
- /spec\.version\s+=\s+InspecPlugins::#{module_name}::VERSION/,
46
- /README\.md\s+#{snake_case}\.gemspec\s+Gemfile/,
47
- /spec\.authors\s+=\s+\['Your Name'\]/,
48
- /spec\.email\s+=\s+\['you@example\.com'\]/,
49
- /spec\.summary\s+=\s+'A plugin with a default summary'/,
50
- /spec\.description\s+=\s+''/,
51
- /spec\.homepage\s+=\s+'https:\/\/github.com\/you\/#{plugin}'/,
52
- /spec\.license\s+=\s+'Apache-2\.0'/,
53
- ],
54
- File.join(plugin, 'lib', plugin + '.rb') => [
55
- /require\s'#{plugin}\/plugin'/,
56
- ],
57
- File.join(plugin, 'lib', plugin, 'plugin.rb') => [
58
- /require\s'#{plugin}\/version'/,
59
- /\#\s#{plugin}\s=>\s#{module_name}/,
60
- /module\s#{module_name}/,
61
- /plugin_name\s+:'#{plugin}'/,
62
- # Default assumes one cli hook
63
- /cli_command :my_command/,
64
- /require\s'#{plugin}\/cli_command'/,
65
- /InspecPlugins::#{module_name}::CliCommand/,
66
- ],
67
- File.join(plugin, 'lib', plugin, 'version.rb') => [
68
- /module\s#{module_name}/,
69
- ],
70
- File.join(plugin, 'lib', plugin, 'cli_command.rb') => [
71
- /module\sInspecPlugins::#{module_name}/,
72
- /\#\smakes\s`inspec\smy-command\s\.\.\.`\swork\./,
73
- /subcommand_desc\s'my_command\s\[COMMAND\]'/,
74
- /\#\sas\s`inspec\smy-command\sdo-something/,
75
- /\#\sin\s`inspec\shelp\smy-command`/,
76
- /\#\sruns\s`inspec\smy-command\sdo-something`./,
77
- /Edit\slib\/#{plugin}\/cli_command\.rb\sto\smake\sit\sdo/,
78
- ],
79
- File.join(plugin, 'test', 'helper.rb') => [], # No interpolation
80
- File.join(plugin, 'test', 'functional', 'README.md') => [], # No interpolation
81
- File.join(plugin, 'test', 'functional', snake_case + '_test.rb') => [
82
- # Whatever goes here
83
- ],
84
- File.join(plugin, 'test', 'unit', 'plugin_def_test.rb') => [
85
- /require\s'#{plugin}\/plugin'/,
86
- /describe InspecPlugins::#{module_name}::Plugin\sdo/,
87
- /let\(:plugin_name\) \{ \:'#{plugin}\' \}/,
88
- ],
89
- File.join(plugin, 'test', 'unit', 'cli_args_test.rb') => [
90
- /require '#{plugin}\/cli_command'/,
91
- /describe InspecPlugins::#{module_name}::CliCommand do/,
92
- /let\(\:cli_class\) \{ InspecPlugins::#{module_name}::CliCommand \}/,
93
- ],
94
- File.join(plugin, 'test', 'unit', 'README.md') => [
95
- /cli_args_test\.rb/,
96
- ],
97
- }.each do |path, regexen|
98
- full_path = File.join(dir, path)
99
- assert(File.exist?(full_path), "#{path} should have been generated")
100
- next if regexen.empty?
101
- contents = File.read(full_path)
102
- regexen.each do |re|
103
- assert_match re, contents, "#{path} should match #{re}"
104
- end
105
- end
106
- end
107
- end
108
-
109
- def test_generating_inspec_plugin_with_custom_options
110
- Dir.mktmpdir do |dir|
111
- plugin = 'inspec-test-generated-plugin'
112
- snake_case = plugin.tr('-', '_')
113
- camel_case = plugin.sub(/^inspec\-/, '').split('-').map(&:capitalize).join('')
114
-
115
- opts = ''
116
- opts += ' --author-email bob@example.com '
117
- opts += ' --author-name Bob '
118
- opts += ' --copyright "Copyright © 2018 Bob" '
119
- opts += ' --description "That you will really like" '
120
- opts += ' --license-name BSD-3-Clause '
121
- opts += ' --summary "A fantastic plugin" '
122
-
123
- opts += ' --homepage http://example.com '
124
- opts += ' --module_name FunPlugin'
125
-
126
- run_result = run_inspec_process("init plugin #{plugin} --no-prompt #{opts}", prefix: "cd #{dir} &&")
127
- assert_empty run_result.stderr
128
- assert_equal 0, run_result.exit_status
129
- assert_includes run_result.stdout, 'Creating new inspec plugin at'
130
- assert_includes run_result.stdout, plugin
131
-
132
- # Check generated files and contents.
133
- # Each file must exist, and its contents must match each of the regexen given.
134
- {
135
- File.join(plugin, 'README.md') => [],
136
- File.join(plugin, 'LICENSE') => [
137
- /Copyright © 2018 Bob/,
138
- /used to endorse or promote/,
139
- ],
140
- File.join(plugin, 'Gemfile') => [],
141
- File.join(plugin, 'Rakefile') => [],
142
- File.join(plugin, plugin + '.gemspec') => [
143
- /spec\.version\s+=\s+InspecPlugins::FunPlugin::VERSION/,
144
- /spec\.authors\s+=\s+\['Bob'\]/,
145
- /spec\.email\s+=\s+\['bob@example\.com'\]/,
146
- /spec\.summary\s+=\s+'A fantastic plugin'/,
147
- /spec\.description\s+=\s+'That you will really like'/,
148
- /spec\.homepage\s+=\s+'http:\/\/example.com'/,
149
- /spec\.license\s+=\s+'BSD-3-Clause'/,
150
- ],
151
- File.join(plugin, 'lib', plugin + '.rb') => [],
152
- File.join(plugin, 'lib', plugin, 'plugin.rb') => [],
153
- File.join(plugin, 'lib', plugin, 'version.rb') => [],
154
- File.join(plugin, 'lib', plugin, 'cli_command.rb') => [],
155
- File.join(plugin, 'test', 'helper.rb') => [],
156
- File.join(plugin, 'test', 'functional', snake_case + '_test.rb') => [],
157
- File.join(plugin, 'test', 'unit', 'plugin_def_test.rb') => [],
158
- File.join(plugin, 'test', 'unit', 'cli_args_test.rb') => [],
159
- }.each do |path, regexen|
160
- full_path = File.join(dir, path)
161
- assert(File.exist?(full_path), "#{path} should have been generated")
162
- next if regexen.empty?
163
- contents = File.read(full_path)
164
- regexen.each do |re|
165
- assert_match re, contents, "#{path} should match #{re}"
166
- end
167
- end
168
- end
169
- end
170
-
171
-
172
-
173
- end