jimdo-rspec-puppet-helpers 0.0.4 → 0.0.5
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.
- checksums.yaml +7 -0
- data/Gemfile.lock +3 -1
- data/jimdo-rspec-puppet-helpers.gemspec +3 -12
- data/lib/jimdo-rspec-puppet-helpers.rb +15 -12
- data/spec/puppet_file_contains_spec.rb +40 -34
- data/spec/spec_helper.rb +1 -1
- metadata +49 -57
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3c9f90c3d60269cd07cc30c1c63f7ae7a9deffc3
|
4
|
+
data.tar.gz: 6ce67672a8837410988cf904aa45e63bb5166ae2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7020f05144f2daefd5efa4dec34f858c5bd65684738dcca800b9498b6cf6678d0573e207681462a054194fa0548f217edf95076f9aea4e8af59cce9c9032065b
|
7
|
+
data.tar.gz: 1b10a836a49703ceb8e3e5c9f411dc77c1493135fb9068cff1872d99b3183ee840db0b6f2fa9f42730e892337987f38c252fb68c5de10407b51083e948719cf0
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
jimdo-rspec-puppet-helpers (0.0.
|
4
|
+
jimdo-rspec-puppet-helpers (0.0.5)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -10,6 +10,7 @@ GEM
|
|
10
10
|
facter (1.7.3)
|
11
11
|
puppet (2.7.23)
|
12
12
|
facter (~> 1.5)
|
13
|
+
rake (10.3.2)
|
13
14
|
rspec (2.14.1)
|
14
15
|
rspec-core (~> 2.14.0)
|
15
16
|
rspec-expectations (~> 2.14.0)
|
@@ -25,4 +26,5 @@ PLATFORMS
|
|
25
26
|
DEPENDENCIES
|
26
27
|
jimdo-rspec-puppet-helpers!
|
27
28
|
puppet (~> 2.7)
|
29
|
+
rake
|
28
30
|
rspec
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{jimdo-rspec-puppet-helpers}
|
5
|
-
s.version = "0.0.
|
5
|
+
s.version = "0.0.5"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Daniel Bonkowski", "Ingo Oeser", "Soenke Ruempler", "Ilya Margolin"]
|
@@ -16,15 +16,6 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.summary = %q{rspec-puppet helpers}
|
17
17
|
s.test_files = ["spec/puppet_file_contains_spec.rb", "spec/spec_helper.rb"]
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
23
|
-
s.add_development_dependency(%q<rspec>, [">= 0"])
|
24
|
-
else
|
25
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
26
|
-
end
|
27
|
-
else
|
28
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
29
|
-
end
|
19
|
+
s.add_development_dependency "rake"
|
20
|
+
s.add_development_dependency "rspec"
|
30
21
|
end
|
@@ -1,7 +1,17 @@
|
|
1
1
|
require 'rspec'
|
2
2
|
require 'puppet'
|
3
|
-
|
4
|
-
|
3
|
+
|
4
|
+
def find_puppet_file(sources)
|
5
|
+
Array(sources).each do |source|
|
6
|
+
next unless source.start_with?("puppet:///modules")
|
7
|
+
elems = source.split("/")
|
8
|
+
Puppet[:modulepath].split(":").each do |modulepath|
|
9
|
+
filepath = File.join(modulepath, elems[4], "files", *elems[5..-1])
|
10
|
+
return filepath if File.exist?(filepath)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
nil
|
14
|
+
end
|
5
15
|
|
6
16
|
RSpec::Matchers.define :puppet_file_contains do |file, expected|
|
7
17
|
match do |actual|
|
@@ -17,19 +27,12 @@ RSpec::Matchers.define :puppet_file_contains do |file, expected|
|
|
17
27
|
next
|
18
28
|
end
|
19
29
|
|
20
|
-
|
21
|
-
|
22
|
-
file_data = Puppet::FileServing::Metadata.indirection.find(source)
|
23
|
-
break if file_data
|
24
|
-
end
|
25
|
-
|
26
|
-
if !file_data then
|
30
|
+
found_file = find_puppet_file(source_attr)
|
31
|
+
if found_file.nil? then
|
27
32
|
@message = "no files specified in 'source' exist"
|
28
33
|
next
|
29
34
|
else
|
30
|
-
|
31
|
-
|
32
|
-
@message = "expected that #{file}(source=#{found_file}) matches #{expected}"
|
35
|
+
@message = "expected that #{file} (source=#{found_file}) matches #{expected}"
|
33
36
|
expected.match(IO.read(found_file)) != nil
|
34
37
|
end
|
35
38
|
end
|
@@ -1,10 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'puppet_file_contains' do
|
4
|
+
before do
|
5
|
+
Puppet[:modulepath] = "spec/fixtures"
|
6
|
+
end
|
7
|
+
|
4
8
|
context "resource not found" do
|
5
9
|
subject {
|
6
|
-
catalog = double
|
7
|
-
resource = double
|
10
|
+
catalog = double
|
11
|
+
resource = double
|
8
12
|
catalog.stub(:resource) { nil }
|
9
13
|
catalog
|
10
14
|
}
|
@@ -17,8 +21,8 @@ describe 'puppet_file_contains' do
|
|
17
21
|
|
18
22
|
context "resource does not contain 'source' key" do
|
19
23
|
subject {
|
20
|
-
catalog = double
|
21
|
-
resource = double
|
24
|
+
catalog = double
|
25
|
+
resource = double
|
22
26
|
catalog.stub(:resource) { resource }
|
23
27
|
resource.stub(:to_hash) { { :some_attribute => 1, :some_other_attribute => 2} }
|
24
28
|
catalog
|
@@ -30,47 +34,49 @@ describe 'puppet_file_contains' do
|
|
30
34
|
end
|
31
35
|
end
|
32
36
|
|
33
|
-
context "resource is found,
|
37
|
+
context "resource is found, file does not exist" do
|
34
38
|
subject {
|
35
|
-
catalog = double
|
36
|
-
resource = double
|
39
|
+
catalog = double
|
40
|
+
resource = double
|
37
41
|
catalog.stub(:resource) { resource }
|
38
42
|
resource.stub(:to_hash) { { :source => ['puppet:///modules/modulex/path1', 'puppet:///modules/modulex/path2'] } }
|
39
43
|
catalog
|
40
44
|
}
|
41
45
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
}
|
47
|
-
expect {
|
48
|
-
should puppet_file_contains('/path/file', %r'regex')
|
49
|
-
}.to raise_error(RSpec::Expectations::ExpectationNotMetError, /no files specified in 'source' exist/)
|
50
|
-
end
|
46
|
+
it "will raise ExpectationNotMetError with 'no files exist'" do
|
47
|
+
expect {
|
48
|
+
should puppet_file_contains('/path/file', %r'regex')
|
49
|
+
}.to raise_error(RSpec::Expectations::ExpectationNotMetError, /no files specified in 'source' exist/)
|
51
50
|
end
|
51
|
+
end
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
}.to raise_error(RSpec::Expectations::ExpectationNotMetError, /^#{Regexp.quote("expected that /path/file(source=/some/path/to/file) matches")}/)
|
62
|
-
end
|
63
|
-
end
|
53
|
+
context "some file is found, but does not match regex" do
|
54
|
+
subject {
|
55
|
+
catalog = double
|
56
|
+
resource = double
|
57
|
+
catalog.stub(:resource) { resource }
|
58
|
+
resource.stub(:to_hash) { { :source => ['puppet:///modules/modulex/path1', 'puppet:///modules/modulex/somefile.txt'] } }
|
59
|
+
catalog
|
60
|
+
}
|
64
61
|
|
65
|
-
|
66
|
-
|
67
|
-
Puppet::FileServing::Metadata.indirection.stub(:find) {
|
68
|
-
double(:path => '/some/path/to/file')
|
69
|
-
}
|
70
|
-
IO.stub(:read).with('/some/path/to/file') { 'I do match a regex' }
|
62
|
+
it "will raise ExpectationNotMetError with 'expected source attribute'" do
|
63
|
+
expect {
|
71
64
|
should puppet_file_contains('/path/file', %r'regex')
|
72
|
-
|
65
|
+
}.to raise_error(RSpec::Expectations::ExpectationNotMetError, /^#{Regexp.quote("expected that /path/file (source=#{Puppet[:modulepath]}/modulex/files/somefile.txt) matches")}/)
|
73
66
|
end
|
74
67
|
end
|
75
68
|
|
69
|
+
context "some file is found and matches regex" do
|
70
|
+
subject {
|
71
|
+
catalog = double
|
72
|
+
resource = double
|
73
|
+
catalog.stub(:resource) { resource }
|
74
|
+
resource.stub(:to_hash) { { :source => ['puppet:///modules/modulex/path1', 'puppet:///modules/modulex/anotherfile.txt'] } }
|
75
|
+
catalog
|
76
|
+
}
|
77
|
+
|
78
|
+
it "will raise no exception" do
|
79
|
+
should puppet_file_contains('/path/file', %r'some content')
|
80
|
+
end
|
81
|
+
end
|
76
82
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require '
|
1
|
+
require 'jimdo-rspec-puppet-helpers'
|
metadata
CHANGED
@@ -1,15 +1,9 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: jimdo-rspec-puppet-helpers
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 4
|
10
|
-
version: 0.0.4
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Daniel Bonkowski
|
14
8
|
- Ingo Oeser
|
15
9
|
- Soenke Ruempler
|
@@ -17,36 +11,45 @@ authors:
|
|
17
11
|
autorequire:
|
18
12
|
bindir: bin
|
19
13
|
cert_chain: []
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
14
|
+
date: 2014-04-03 00:00:00.000000000 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rake
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :development
|
26
24
|
prerelease: false
|
27
|
-
|
28
|
-
|
29
|
-
requirements:
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
30
27
|
- - ">="
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
36
37
|
type: :development
|
37
|
-
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
38
44
|
description: rspec-puppet helpers
|
39
|
-
email:
|
45
|
+
email:
|
40
46
|
- infrateam@jimdo.com
|
41
47
|
executables: []
|
42
|
-
|
43
48
|
extensions: []
|
44
|
-
|
45
49
|
extra_rdoc_files: []
|
46
|
-
|
47
|
-
|
48
|
-
- .
|
49
|
-
- .rspec
|
50
|
+
files:
|
51
|
+
- ".gitignore"
|
52
|
+
- ".rspec"
|
50
53
|
- Gemfile
|
51
54
|
- Gemfile.lock
|
52
55
|
- LICENSE
|
@@ -56,40 +59,29 @@ files:
|
|
56
59
|
- lib/jimdo-rspec-puppet-helpers.rb
|
57
60
|
- spec/puppet_file_contains_spec.rb
|
58
61
|
- spec/spec_helper.rb
|
59
|
-
|
60
|
-
homepage: ""
|
62
|
+
homepage: ''
|
61
63
|
licenses: []
|
62
|
-
|
64
|
+
metadata: {}
|
63
65
|
post_install_message:
|
64
66
|
rdoc_options: []
|
65
|
-
|
66
|
-
require_paths:
|
67
|
+
require_paths:
|
67
68
|
- lib
|
68
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
-
|
70
|
-
requirements:
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
71
|
- - ">="
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
version: "0"
|
77
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
-
none: false
|
79
|
-
requirements:
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
80
76
|
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
|
83
|
-
segments:
|
84
|
-
- 0
|
85
|
-
version: "0"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
86
79
|
requirements: []
|
87
|
-
|
88
80
|
rubyforge_project:
|
89
|
-
rubygems_version:
|
81
|
+
rubygems_version: 2.2.2
|
90
82
|
signing_key:
|
91
|
-
specification_version:
|
83
|
+
specification_version: 4
|
92
84
|
summary: rspec-puppet helpers
|
93
|
-
test_files:
|
85
|
+
test_files:
|
94
86
|
- spec/puppet_file_contains_spec.rb
|
95
87
|
- spec/spec_helper.rb
|