puppetlabs_spec_helper 5.0.0 → 6.0.0

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.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PuppetlabsSpecHelper
4
- VERSION = '5.0.0'
4
+ VERSION = '6.0.0'
5
5
  end
@@ -9,6 +9,6 @@ RSpec.describe 'rake' do
9
9
  Open3.capture2e('rake', '--rakefile', 'spec/acceptance/fixtures/Rakefile', '-T')
10
10
  end
11
11
 
12
- it { expect(output[0]).to match %r{spec_prep} }
12
+ it { expect(output[0]).to match(/spec_prep/) }
13
13
  it { expect(output[1]).to be_success }
14
14
  end
data/spec/spec_helper.rb CHANGED
@@ -8,7 +8,7 @@ if ENV['COVERAGE'] == 'yes'
8
8
  SimpleCov.formatters = [
9
9
  SimpleCov::Formatter::HTMLFormatter,
10
10
  SimpleCov::Formatter::Console,
11
- SimpleCov::Formatter::Codecov,
11
+ SimpleCov::Formatter::Codecov
12
12
  ]
13
13
  SimpleCov.start do
14
14
  track_files 'lib/**/*.rb'
@@ -40,7 +40,7 @@ RSpec.shared_context 'with a rake task', type: :task do
40
40
 
41
41
  include FakeFS::SpecHelpers
42
42
 
43
- let(:task_name) { self.class.top_level_description.sub(%r{\Arake }, '') }
43
+ let(:task_name) { self.class.top_level_description.delete_prefix('rake ') }
44
44
  end
45
45
 
46
46
  # configure RSpec after including all the code
@@ -3,7 +3,7 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe 'rake check:symlinks', type: :task do
6
- before(:each) do
6
+ before do
7
7
  test_files.each do |f|
8
8
  FileUtils.mkdir_p(File.dirname(f))
9
9
  FileUtils.touch(f)
@@ -31,7 +31,7 @@ describe 'rake check:symlinks', type: :task do
31
31
  let(:test_files) do
32
32
  [
33
33
  File.join(Dir.pwd, 'files', 'a_file.pp'),
34
- File.join(Dir.pwd, 'files', 'another_file.pp'),
34
+ File.join(Dir.pwd, 'files', 'another_file.pp')
35
35
  ]
36
36
  end
37
37
 
@@ -43,19 +43,19 @@ describe 'rake check:symlinks', type: :task do
43
43
  context 'when there is a symlink present' do
44
44
  let(:test_files) do
45
45
  [
46
- File.join(Dir.pwd, 'files', 'a_file.pp'),
46
+ File.join(Dir.pwd, 'files', 'a_file.pp')
47
47
  ]
48
48
  end
49
49
 
50
50
  let(:symlinks) do
51
51
  {
52
- File.join(Dir.pwd, 'files', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp'),
52
+ File.join(Dir.pwd, 'files', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp')
53
53
  }
54
54
  end
55
55
 
56
56
  it 'raises an error' do
57
57
  expect { task.execute }
58
- .to raise_error(%r{symlink\(s\) exist}i)
58
+ .to raise_error(/symlink\(s\) exist/i)
59
59
  .and output(a_string_including(expected_output)).to_stdout
60
60
  end
61
61
  end
@@ -63,13 +63,13 @@ describe 'rake check:symlinks', type: :task do
63
63
  context 'when there are symlinks under .git/' do
64
64
  let(:test_files) do
65
65
  [
66
- File.join(Dir.pwd, 'files', 'a_file.pp'),
66
+ File.join(Dir.pwd, 'files', 'a_file.pp')
67
67
  ]
68
68
  end
69
69
 
70
70
  let(:symlinks) do
71
71
  {
72
- File.join(Dir.pwd, '.git', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp'),
72
+ File.join(Dir.pwd, '.git', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp')
73
73
  }
74
74
  end
75
75
 
@@ -81,13 +81,13 @@ describe 'rake check:symlinks', type: :task do
81
81
  context 'when there are symlinks under .bundle/' do
82
82
  let(:test_files) do
83
83
  [
84
- File.join(Dir.pwd, 'files', 'a_file.pp'),
84
+ File.join(Dir.pwd, 'files', 'a_file.pp')
85
85
  ]
86
86
  end
87
87
 
88
88
  let(:symlinks) do
89
89
  {
90
- File.join(Dir.pwd, '.bundle', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp'),
90
+ File.join(Dir.pwd, '.bundle', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp')
91
91
  }
92
92
  end
93
93
 
@@ -99,13 +99,13 @@ describe 'rake check:symlinks', type: :task do
99
99
  context 'when there are symlinks under vendor/' do
100
100
  let(:test_files) do
101
101
  [
102
- File.join(Dir.pwd, 'files', 'a_file.pp'),
102
+ File.join(Dir.pwd, 'files', 'a_file.pp')
103
103
  ]
104
104
  end
105
105
 
106
106
  let(:symlinks) do
107
107
  {
108
- File.join(Dir.pwd, 'vendor', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp'),
108
+ File.join(Dir.pwd, 'vendor', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp')
109
109
  }
110
110
  end
111
111
 
@@ -115,19 +115,19 @@ describe 'rake check:symlinks', type: :task do
115
115
  end
116
116
 
117
117
  context 'when there are symlinks under a directory listed in .gitignore' do
118
- before(:each) do
118
+ before do
119
119
  File.write(File.join(Dir.pwd, '.gitignore'), "a_directory/\n")
120
120
  end
121
121
 
122
122
  let(:test_files) do
123
123
  [
124
- File.join(Dir.pwd, 'files', 'a_file.pp'),
124
+ File.join(Dir.pwd, 'files', 'a_file.pp')
125
125
  ]
126
126
  end
127
127
 
128
128
  let(:symlinks) do
129
129
  {
130
- File.join(Dir.pwd, 'a_directory', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp'),
130
+ File.join(Dir.pwd, 'a_directory', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp')
131
131
  }
132
132
  end
133
133
 
@@ -137,7 +137,7 @@ describe 'rake check:symlinks', type: :task do
137
137
  end
138
138
 
139
139
  context 'when there are symlinks under a directory listed in .pdkignore' do
140
- before(:each) do
140
+ before do
141
141
  File.open(File.join(Dir.pwd, '.pdkignore'), 'w') do |f|
142
142
  f.puts '/another_directory/'
143
143
  end
@@ -145,13 +145,13 @@ describe 'rake check:symlinks', type: :task do
145
145
 
146
146
  let(:test_files) do
147
147
  [
148
- File.join(Dir.pwd, 'files', 'a_file.pp'),
148
+ File.join(Dir.pwd, 'files', 'a_file.pp')
149
149
  ]
150
150
  end
151
151
 
152
152
  let(:symlinks) do
153
153
  {
154
- File.join(Dir.pwd, 'another_directory', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp'),
154
+ File.join(Dir.pwd, 'another_directory', 'a_symlink.pp') => File.join(Dir.pwd, 'files', 'a_file.pp')
155
155
  }
156
156
  end
157
157
 
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  describe 'rake check:test_file', type: :task do
6
6
  context 'when there are .pp files under tests/' do
7
- before(:each) do
7
+ before do
8
8
  test_files.each do |f|
9
9
  FileUtils.mkdir_p(File.dirname(f))
10
10
  FileUtils.touch(f)
@@ -14,7 +14,7 @@ describe 'rake check:test_file', type: :task do
14
14
  let(:test_files) do
15
15
  [
16
16
  File.join(Dir.pwd, 'tests', 'an_example.pp'),
17
- File.join(Dir.pwd, 'tests', 'deep', 'directory', 'structure', 'another_example.pp'),
17
+ File.join(Dir.pwd, 'tests', 'deep', 'directory', 'structure', 'another_example.pp')
18
18
  ]
19
19
  end
20
20
 
@@ -22,13 +22,13 @@ describe 'rake check:test_file', type: :task do
22
22
  expected_output = test_files.join("\n")
23
23
 
24
24
  expect { task.execute }
25
- .to raise_error(%r{pp files present in tests folder})
25
+ .to raise_error(/pp files present in tests folder/)
26
26
  .and output(a_string_including(expected_output)).to_stdout
27
27
  end
28
28
  end
29
29
 
30
30
  context 'when there are no .pp files under tests/' do
31
- before(:each) do
31
+ before do
32
32
  FileUtils.mkdir('tests')
33
33
  end
34
34
 
@@ -7,7 +7,7 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
7
7
  describe '.module_name' do
8
8
  subject(:module_name) { described_class.module_name }
9
9
 
10
- before(:each) do
10
+ before do
11
11
  allow(Dir).to receive(:pwd).and_return(File.join('path', 'to', 'my-awsome-module_from_pwd'))
12
12
  end
13
13
 
@@ -24,7 +24,7 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
24
24
  end
25
25
 
26
26
  context 'when metadata.json does not exist' do
27
- before(:each) do
27
+ before do
28
28
  allow(File).to receive(:file?).with('metadata.json').and_return(false)
29
29
  end
30
30
 
@@ -32,49 +32,49 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
32
32
  end
33
33
 
34
34
  context 'when metadata.json does exist' do
35
- before(:each) do
35
+ before do
36
36
  allow(File).to receive(:file?).with('metadata.json').and_return(true)
37
37
  end
38
38
 
39
- context 'but it is not readable' do
40
- before(:each) do
39
+ context 'when it is not readable' do
40
+ before do
41
41
  allow(File).to receive(:readable?).with('metadata.json').and_return(false)
42
42
  end
43
43
 
44
44
  it_behaves_like 'module name from working directory'
45
45
  end
46
46
 
47
- context 'and it is readable' do
48
- before(:each) do
47
+ context 'when it is readable' do
48
+ before do
49
49
  allow(File).to receive(:readable?).with('metadata.json').and_return(true)
50
50
  allow(File).to receive(:read).with('metadata.json').and_return(metadata_content)
51
51
  end
52
52
 
53
- context 'but it contains invalid JSON' do
53
+ context 'when it contains invalid JSON' do
54
54
  let(:metadata_content) { '{ "name": "my-awesome-module_from_metadata", }' }
55
55
 
56
56
  it_behaves_like 'module name from working directory'
57
57
  end
58
58
 
59
- context 'and it contains a name value' do
59
+ context 'when it contains a name value' do
60
60
  let(:metadata_content) { '{ "name": "my-awesome-module_from_metadata" }' }
61
61
 
62
62
  it_behaves_like 'module name from metadata'
63
63
  end
64
64
 
65
- context 'but it does not contain a name value' do
65
+ context 'when it does not contain a name value' do
66
66
  let(:metadata_content) { '{}' }
67
67
 
68
68
  it_behaves_like 'module name from working directory'
69
69
  end
70
70
 
71
- context 'but the name has a null value' do
71
+ context 'when the name has a null value' do
72
72
  let(:metadata_content) { '{ "name": null }' }
73
73
 
74
74
  it_behaves_like 'module name from working directory'
75
75
  end
76
76
 
77
- context 'but the name is blank' do
77
+ context 'when the name is blank' do
78
78
  let(:metadata_content) { '{ "name": "" }' }
79
79
 
80
80
  it_behaves_like 'module name from working directory'
@@ -86,7 +86,7 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
86
86
  describe '.fixtures' do
87
87
  subject(:helper) { described_class }
88
88
 
89
- before :each do
89
+ before do
90
90
  # Unstub the fixtures "helpers"
91
91
  PuppetlabsSpec::Fixtures.instance_methods.each do |m|
92
92
  PuppetlabsSpec::Fixtures.send(:undef_method, m)
@@ -118,7 +118,7 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
118
118
  it 'raises an error' do
119
119
  expect(File).to receive(:exist?).with('.fixtures.yml').and_return true
120
120
  expect(YAML).to receive(:load_file).with('.fixtures.yml').and_raise(Psych::SyntaxError.new('/file', '123', '0', '0', 'spec message', 'spec context'))
121
- expect { helper.fixtures('forge_modules') }.to raise_error(RuntimeError, %r{malformed YAML})
121
+ expect { helper.fixtures('forge_modules') }.to raise_error(RuntimeError, /malformed YAML/)
122
122
  end
123
123
  end
124
124
 
@@ -126,7 +126,7 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
126
126
  it 'raises an error' do
127
127
  allow(File).to receive(:exist?).with('.fixtures.yml').and_return true
128
128
  allow(YAML).to receive(:load_file).with('.fixtures.yml').and_return('some' => 'key')
129
- expect { helper.fixtures('forge_modules') }.to raise_error(RuntimeError, %r{No 'fixtures'})
129
+ expect { helper.fixtures('forge_modules') }.to raise_error(RuntimeError, /No 'fixtures'/)
130
130
  end
131
131
  end
132
132
 
@@ -141,7 +141,7 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
141
141
  'branch' => nil,
142
142
  'scm' => nil,
143
143
  'flags' => nil,
144
- 'subdir' => nil,
144
+ 'subdir' => nil
145
145
  },
146
146
  )
147
147
  end
@@ -159,18 +159,18 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
159
159
  'branch' => nil,
160
160
  'scm' => nil,
161
161
  'flags' => '--module_repository=https://myforge.example.com/',
162
- 'subdir' => nil,
162
+ 'subdir' => nil
163
163
  },
164
164
  )
165
165
  end
166
166
  end
167
167
 
168
168
  context 'when file specifies repository fixtures' do
169
- before(:each) do
169
+ before do
170
170
  allow(File).to receive(:exist?).with('.fixtures.yml').and_return true
171
171
  allow(YAML).to receive(:load_file).with('.fixtures.yml').and_return(
172
172
  'fixtures' => {
173
- 'repositories' => { 'stdlib' => 'https://github.com/puppetlabs/puppetlabs-stdlib.git' },
173
+ 'repositories' => { 'stdlib' => 'https://github.com/puppetlabs/puppetlabs-stdlib.git' }
174
174
  },
175
175
  )
176
176
  end
@@ -183,14 +183,14 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
183
183
  'branch' => nil,
184
184
  'scm' => nil,
185
185
  'flags' => nil,
186
- 'subdir' => nil,
186
+ 'subdir' => nil
187
187
  },
188
188
  )
189
189
  end
190
190
  end
191
191
 
192
192
  context 'when file specifies repository fixtures with an invalid git ref' do
193
- before(:each) do
193
+ before do
194
194
  allow(File).to receive(:exist?).with('.fixtures.yml').and_return true
195
195
  allow(YAML).to receive(:load_file).with('.fixtures.yml').and_return(
196
196
  'fixtures' => {
@@ -198,9 +198,9 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
198
198
  'stdlib' => {
199
199
  'scm' => 'git',
200
200
  'repo' => 'https://github.com/puppetlabs/puppetlabs-stdlib.git',
201
- 'ref' => 'this/is/a/branch',
202
- },
203
- },
201
+ 'ref' => 'this/is/a/branch'
202
+ }
203
+ }
204
204
  },
205
205
  )
206
206
  end
@@ -222,9 +222,9 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
222
222
  'forge_modules' => {
223
223
  'stdlib' => {
224
224
  'repo' => 'puppetlabs-stdlib',
225
- 'puppet_version' => Puppet::PUPPETVERSION,
226
- },
227
- },
225
+ 'puppet_version' => Puppet::PUPPETVERSION
226
+ }
227
+ }
228
228
  },
229
229
  )
230
230
  expect(helper.fixtures('forge_modules')).to include('puppetlabs-stdlib')
@@ -236,9 +236,9 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
236
236
  'forge_modules' => {
237
237
  'stdlib' => {
238
238
  'repo' => 'puppetlabs-stdlib',
239
- 'puppet_version' => '>= 999.9.9',
240
- },
241
- },
239
+ 'puppet_version' => '>= 999.9.9'
240
+ }
241
+ }
242
242
  },
243
243
  )
244
244
  expect(helper.fixtures('forge_modules')).to eq({})
@@ -250,9 +250,9 @@ describe PuppetlabsSpecHelper::Tasks::FixtureHelpers do
250
250
  'forge_modules' => {
251
251
  'stdlib' => {
252
252
  'repo' => 'puppetlabs-stdlib',
253
- 'puppet_version' => Puppet::PUPPETVERSION,
254
- },
255
- },
253
+ 'puppet_version' => Puppet::PUPPETVERSION
254
+ }
255
+ }
256
256
  },
257
257
  )
258
258
  expect(helper.fixtures('forge_modules')).to include('puppetlabs-stdlib')
data/spec/watchr.rb CHANGED
@@ -10,8 +10,8 @@ def growl(message)
10
10
  growlnotify = `which growlnotify`.chomp
11
11
  title = 'Watchr Test Results'
12
12
  image = case message
13
- when %r{(\d+)\s+?(failure|error)}i
14
- (Regexp.last_match(1).to_i == 0) ? '~/.watchr_images/passed.png' : '~/.watchr_images/failed.png'
13
+ when /(\d+)\s+?(failure|error)/i
14
+ Regexp.last_match(1).to_i == 0 ? '~/.watchr_images/passed.png' : '~/.watchr_images/failed.png'
15
15
  else
16
16
  '~/.watchr_images/unknown.png'
17
17
  end
@@ -35,9 +35,7 @@ def run_spec_test(file)
35
35
  end
36
36
 
37
37
  def filter_rspec(data)
38
- data.split("\n").select { |l|
39
- l =~ %r{^(\d+)\s+exampl\w+.*?(\d+).*?failur\w+.*?(\d+).*?pending}
40
- }.join("\n")
38
+ data.split("\n").grep(/^(\d+)\s+exampl\w+.*?(\d+).*?failur\w+.*?(\d+).*?pending/).join("\n")
41
39
  end
42
40
 
43
41
  def run_all_tests
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppetlabs_spec_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet, Inc.
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-01-23 00:00:00.000000000 Z
12
+ date: 2023-04-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mocha
@@ -29,30 +29,42 @@ dependencies:
29
29
  name: pathspec
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - "~>"
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: '1.0'
34
+ version: '0.2'
35
+ - - "<"
36
+ - !ruby/object:Gem::Version
37
+ version: 2.0.0
35
38
  type: :runtime
36
39
  prerelease: false
37
40
  version_requirements: !ruby/object:Gem::Requirement
38
41
  requirements:
39
- - - "~>"
42
+ - - ">="
40
43
  - !ruby/object:Gem::Version
41
- version: '1.0'
44
+ version: '0.2'
45
+ - - "<"
46
+ - !ruby/object:Gem::Version
47
+ version: 2.0.0
42
48
  - !ruby/object:Gem::Dependency
43
49
  name: puppet-lint
44
50
  requirement: !ruby/object:Gem::Requirement
45
51
  requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 3.0.0
46
55
  - - "~>"
47
56
  - !ruby/object:Gem::Version
48
- version: '3.0'
57
+ version: 4.0.0.rc
49
58
  type: :runtime
50
59
  prerelease: false
51
60
  version_requirements: !ruby/object:Gem::Requirement
52
61
  requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 3.0.0
53
65
  - - "~>"
54
66
  - !ruby/object:Gem::Version
55
- version: '3.0'
67
+ version: 4.0.0.rc
56
68
  - !ruby/object:Gem::Dependency
57
69
  name: puppet-syntax
58
70
  requirement: !ruby/object:Gem::Requirement
@@ -85,16 +97,22 @@ dependencies:
85
97
  name: rspec-puppet
86
98
  requirement: !ruby/object:Gem::Requirement
87
99
  requirements:
88
- - - "~>"
100
+ - - ">="
89
101
  - !ruby/object:Gem::Version
90
102
  version: '2.0'
103
+ - - "~>"
104
+ - !ruby/object:Gem::Version
105
+ version: 3.0.0.rc
91
106
  type: :runtime
92
107
  prerelease: false
93
108
  version_requirements: !ruby/object:Gem::Requirement
94
109
  requirements:
95
- - - "~>"
110
+ - - ">="
96
111
  - !ruby/object:Gem::Version
97
112
  version: '2.0'
113
+ - - "~>"
114
+ - !ruby/object:Gem::Version
115
+ version: 3.0.0.rc
98
116
  description: Contains rake tasks and a standard spec_helper for running spec tests
99
117
  on puppet modules.
100
118
  email:
@@ -123,7 +141,7 @@ files:
123
141
  - spec/unit/puppetlabs_spec_helper/puppetlabs_spec/puppet_internals_spec.rb
124
142
  - spec/unit/puppetlabs_spec_helper/tasks/check_symlinks_spec.rb
125
143
  - spec/unit/puppetlabs_spec_helper/tasks/check_test_file_spec.rb
126
- - spec/unit/puppetlabs_spec_helper/tasks/fixtures_spec.rb
144
+ - spec/unit/puppetlabs_spec_helper/tasks/fixture_helpers_spec.rb
127
145
  - spec/watchr.rb
128
146
  homepage: http://github.com/puppetlabs/puppetlabs_spec_helper
129
147
  licenses:
@@ -144,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
162
  - !ruby/object:Gem::Version
145
163
  version: '0'
146
164
  requirements:
147
- - puppet, >= 6.0.0
165
+ - puppet, >= 7.0.0
148
166
  rubygems_version: 3.1.6
149
167
  signing_key:
150
168
  specification_version: 4