rspec-puppet-augeas 0.2.3 → 0.3.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8f06061bfcf98a5fcbc5c74c34f24bbf6c6d0351
4
+ data.tar.gz: 4e3dbe939a0d3df172a1a830cb389e60e30af92e
5
+ SHA512:
6
+ metadata.gz: 18c6661cab9a5458a711935a9245566c4441a1c73d2de328bc130a911f91f43aaaa9a481970389f92d0b309f31bcb41833a6e2f7d08b82612e882a4aa291fa2a
7
+ data.tar.gz: efd749b3d0333d63770aa8b0f09aa5bc2477ff59da6db9923d1f5f6628a226f08b3cb8b5767d961506b03e4ef0b167c594943d9eee9fab749c0688ba062a5ee0
data/.gitignore CHANGED
@@ -1,4 +1,7 @@
1
1
  coverage/
2
2
  pkg/
3
3
  *.gem
4
+ Gemfile.local
4
5
  Gemfile.lock
6
+ .ruby-*
7
+ .project
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gem 'puppetlabs_spec_helper'
4
- gem 'rspec-puppet'
4
+ gem 'rspec-puppet', '< 1.0.0'
5
5
  gem 'ruby-augeas'
6
6
 
7
7
  group :test do
@@ -9,3 +9,5 @@ group :test do
9
9
  gem 'rake'
10
10
  gem 'simplecov'
11
11
  end
12
+
13
+ self.instance_eval(Bundler.read_file('Gemfile.local')) if File.exist? 'Gemfile.local'
data/README.md CHANGED
@@ -13,6 +13,8 @@ Augeas-based tools to help verify the modification was made.
13
13
  Install the gem first:
14
14
 
15
15
  gem install rspec-puppet-augeas
16
+
17
+ **Note:** The `ruby-augeas` gem and the augeas tools and development libraries are also required.
16
18
 
17
19
  Extend your usual rspec-puppet class test, e.g. for the 'sshd' class:
18
20
 
@@ -55,6 +57,16 @@ fixtures directory.
55
57
  c.augeas_fixtures = File.join(File.dirname(File.expand_path(__FILE__)), 'fixtures', 'augeas')
56
58
  end
57
59
 
60
+ If you have custom lenses in your module dir, puppetlabs_spec_helper will deal with the
61
+ augeas libdir. You will however have to let the rspec-puppet-augeas module know they
62
+ are not in your default augeas lens dir. You can do so by using configuring the augeas_lensdir.
63
+
64
+ require 'rspec-puppet-augeas'
65
+ RSpec.configure do |c|
66
+ c.augeas_fixtures = File.join(File.dirname(File.expand_path(__FILE__)), 'fixtures', 'augeas')
67
+ c.augeas_lensdir = File.join(File.dirname(File.expand_path(__FILE__)), '..', 'lib/augeas/lenses')
68
+ end
69
+
58
70
  ## Usage
59
71
 
60
72
  Read the spec file(s) at `spec/classes/*.rb` to see various real-life examples
@@ -97,7 +109,7 @@ The `execute` matcher is used to check how a resource has run, e.g.
97
109
  It has methods to add to the checks it performs:
98
110
 
99
111
  * `with_change` ensures the resource was "applied" and didn't no-op
100
- * `idempotently` runs the resource again to ensure it only applies once
112
+ * `idempotently` runs the resource again to ensure it applies a maximum of once
101
113
 
102
114
  ### Test utilities
103
115
 
@@ -135,6 +147,43 @@ New RSpec configuration options:
135
147
  * `augeas_fixtures` is the path to the root of the fixtures directory
136
148
  containing source files
137
149
 
150
+ ## Travis configuration
151
+
152
+ It is possible to add `rspec-puppet-augeas` to your [Travis](https://travis-ci.org) configuration. This requires the following additions to your Travis configuration files:
153
+
154
+ ### Changes to `.travis.yml`
155
+
156
+ The augeas packages need to be installed in the `before_install` block:
157
+
158
+ ```yml
159
+ before_install:
160
+ - sudo apt-get install -qq augeas-tools augeas-lenses libaugeas-dev
161
+ ```
162
+
163
+ ### Changes to `Gemfile`
164
+
165
+ The `rspec-puppet-augeas` and `ruby-augeas` gems need to be added into the development and test group:
166
+
167
+ ```ruby
168
+ group :development, :test do
169
+ gem 'puppetlabs_spec_helper', :require => false
170
+ gem 'ruby-augeas', :require => false
171
+ gem 'rspec-puppet-augeas', :require => false
172
+ end
173
+ ```
174
+
175
+ ### Changes to `spec/spec_helper.rb`
176
+
177
+ These changes bring the fixtures required for `rspec-puppet-augeas` to work:
178
+
179
+ ```ruby
180
+ require 'puppetlabs_spec_helper/module_spec_helper'
181
+ require 'rspec-puppet-augeas'
182
+ RSpec.configure do |c|
183
+ c.augeas_fixtures = File.join(File.dirname(File.expand_path(__FILE__)), 'fixtures', 'augeas')
184
+ end
185
+ ```
186
+
138
187
  ## Background reading
139
188
 
140
189
  This module inherited code from the tests used in [augeasproviders](http://augeasproviders.com).
@@ -11,5 +11,6 @@ require 'rspec-puppet-augeas/test_utils'
11
11
 
12
12
  RSpec.configure do |c|
13
13
  c.add_setting :augeas_fixtures, :default => nil
14
+ c.add_setting :augeas_lensdir, :default => nil
14
15
  c.include RSpec::Puppet::Augeas::TestUtils, :type => :augeas
15
16
  end
@@ -25,20 +25,21 @@ module RSpec::Puppet::Augeas::Matchers
25
25
  self
26
26
  end
27
27
 
28
- # verifies the resource only applies once
28
+ # verifies the resource only applies never or once at max
29
29
  def idempotently
30
- @change = true
31
30
  @idempotent = true
32
31
  self
33
32
  end
34
33
 
35
34
  def description
36
- if idempotent
37
- "should change once only (idempotently)"
35
+ if idempotent && change
36
+ "change once only (idempotently)"
37
+ elsif idempotent
38
+ "change at most once (idempotently)"
38
39
  elsif change
39
- "should change successfully at least once"
40
+ "change successfully at least once"
40
41
  else
41
- "should execute without failure"
42
+ "execute without failure"
42
43
  end
43
44
  end
44
45
 
@@ -31,8 +31,9 @@ module RSpec::Puppet::Augeas
31
31
  lens = opts[:lens] || self.lens or raise ArgumentError, ":lens must be supplied"
32
32
  lens = "#{lens}.lns" unless lens.include? '.'
33
33
  root = opts[:root] || self.output_root
34
+ lensdir = RSpec.configuration.augeas_lensdir || nil
34
35
 
35
- aug = Augeas.open(root, nil, Augeas::NO_MODL_AUTOLOAD)
36
+ aug = Augeas.open(root, lensdir, Augeas::NO_MODL_AUTOLOAD)
36
37
  begin
37
38
  aug.transform(
38
39
  :lens => lens,
@@ -86,7 +87,7 @@ module Test_Rspec_Puppet_Augeas =
86
87
  eos
87
88
  end
88
89
 
89
- output = %x(augparse #{testaug} 2>&1)
90
+ output = %x(augparse --notypecheck #{testaug} 2>&1)
90
91
  raise RSpec::Puppet::Augeas::Error, "augparse failed:\n#{output}" unless $? == 0 && output.empty?
91
92
  end
92
93
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'rspec-puppet-augeas'
3
- s.version = '0.2.3'
3
+ s.version = '0.3.0'
4
4
  s.homepage = 'https://github.com/domcleal/rspec-puppet-augeas/'
5
5
  s.summary = 'RSpec tests for Augeas resources in Puppet manifests'
6
6
  s.description = 'RSpec tests for Augeas resources in Puppet manifests'
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
28
28
  'spec/spec_helper.rb'
29
29
  ]
30
30
 
31
- s.add_dependency 'rspec-puppet'
31
+ s.add_dependency 'rspec-puppet', '< 1.0.0'
32
32
  s.add_dependency 'puppetlabs_spec_helper'
33
33
 
34
34
  s.authors = ['Dominic Cleal']
@@ -111,7 +111,7 @@ describe 'sshd' do
111
111
  # Verify the matcher message contains logs
112
112
  e = execute
113
113
  e.matches? subject
114
- e.description.should =~ /should execute/
114
+ e.description.should =~ /execute/
115
115
  e.failure_message_for_should.should =~ /^err:.*false/
116
116
  e.failure_message_for_should_not.should =~ /^err:.*false/
117
117
  # Check for debug logs
@@ -129,7 +129,22 @@ describe 'sshd' do
129
129
  # Verify the matcher message contains logs
130
130
  e = execute
131
131
  e.with_change.matches? subject
132
- e.description.should =~ /should change successfully/
132
+ e.description.should =~ /change successfully/
133
+ e.failure_message_for_should.should =~ /doesn't change/
134
+ e.failure_message_for_should_not.should =~ /changes/
135
+ end
136
+
137
+ it 'should be considered idempotent' do
138
+ should execute.idempotently
139
+ end
140
+
141
+ it 'should fail with both with_change and idempotently' do
142
+ should_not execute.with_change.idempotently
143
+
144
+ # Verify the matcher message contains logs
145
+ e = execute
146
+ e.with_change.idempotently.matches? subject
147
+ e.description.should =~ /change once only/
133
148
  e.failure_message_for_should.should =~ /doesn't change/
134
149
  e.failure_message_for_should_not.should =~ /changes/
135
150
  end
@@ -145,7 +160,7 @@ describe 'sshd' do
145
160
  # Verify the matcher message contains logs
146
161
  e = execute
147
162
  e.idempotently.matches? subject
148
- e.description.should =~ /should change once only/
163
+ e.description.should =~ /change at most once/
149
164
  e.failure_message_for_should.should =~ /^notice:.*success/
150
165
  e.failure_message_for_should_not.should =~ /^notice:.*success/
151
166
  end
metadata CHANGED
@@ -1,46 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-puppet-augeas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
5
- prerelease:
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Dominic Cleal
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-21 00:00:00.000000000 Z
11
+ date: 2013-12-29 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec-puppet
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - <
20
18
  - !ruby/object:Gem::Version
21
- version: '0'
19
+ version: 1.0.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - <
28
25
  - !ruby/object:Gem::Version
29
- version: '0'
26
+ version: 1.0.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: puppetlabs_spec_helper
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  description: RSpec tests for Augeas resources in Puppet manifests
@@ -71,26 +66,25 @@ files:
71
66
  - spec/spec_helper.rb
72
67
  homepage: https://github.com/domcleal/rspec-puppet-augeas/
73
68
  licenses: []
69
+ metadata: {}
74
70
  post_install_message:
75
71
  rdoc_options: []
76
72
  require_paths:
77
73
  - lib
78
74
  required_ruby_version: !ruby/object:Gem::Requirement
79
- none: false
80
75
  requirements:
81
- - - ! '>='
76
+ - - '>='
82
77
  - !ruby/object:Gem::Version
83
78
  version: '0'
84
79
  required_rubygems_version: !ruby/object:Gem::Requirement
85
- none: false
86
80
  requirements:
87
- - - ! '>='
81
+ - - '>='
88
82
  - !ruby/object:Gem::Version
89
83
  version: '0'
90
84
  requirements: []
91
85
  rubyforge_project:
92
- rubygems_version: 1.8.25
86
+ rubygems_version: 2.0.6
93
87
  signing_key:
94
- specification_version: 3
88
+ specification_version: 4
95
89
  summary: RSpec tests for Augeas resources in Puppet manifests
96
90
  test_files: []