Skip to content

Commit

Permalink
Use allow/expect instead of stubs/expects (#30)
Browse files Browse the repository at this point in the history
* Use allow/expect instead of stubs/expects

* Fix unit test

* Lint: block_given? -> block

* Lint: Use safe navigation (&.)

* Lint: empty lines between definitions

* Lint: ignore RSpec/SubjectStub

* Lint: use .match? instead of =~
  • Loading branch information
raphink authored Mar 30, 2021
1 parent 2ec7aa0 commit 637108e
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 117 deletions.
12 changes: 6 additions & 6 deletions lib/puppet/provider/augeasprovider/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def self.default_file(&block)
# @raise [Puppet::Error] if no block has been set when getting
# @api public
def self.lens(resource = nil, &block)
if block_given?
if block
@lens_block = block
else
raise(Puppet::Error, 'Lens is not provided') unless @lens_block
Expand Down Expand Up @@ -445,7 +445,7 @@ def self.path_label(aug, path)
def self.whichquote(value, resource = nil, oldvalue = nil)
oldquote = readquote oldvalue

quote = if resource && resource.parameters.include?(:quoted)
quote = if resource&.parameters&.include?(:quoted)
resource[:quoted]
else
:auto
Expand All @@ -454,7 +454,7 @@ def self.whichquote(value, resource = nil, oldvalue = nil)
if quote == :auto
quote = if oldquote
oldquote
elsif value =~ %r{[|&;()<>\s]}
elsif value.match?(%r{[|&;()<>\s]})
:double
else
:none
Expand Down Expand Up @@ -522,7 +522,7 @@ def self.readquote(value)
# @see #target
# @api public
def self.resource_path(resource = nil, &block)
if block_given?
if block
@resource_path_block = block
elsif @resource_path_block
@resource_path_block.call(resource)
Expand Down Expand Up @@ -691,7 +691,7 @@ def self.augopen_internal(resource = nil, autosave = false, yield_resource = fal
raise(Puppet::Error, "Augeas didn't load #{file} with #{lens}#{from}: #{message}")
end

if block_given?
if block
setvars(aug, resource)
if yield_resource
block.call(aug, resource, *yield_params)
Expand All @@ -705,7 +705,7 @@ def self.augopen_internal(resource = nil, autosave = false, yield_resource = fal
autosave = false
raise
ensure
if aug && block_given? && !supported?(:post_resource_eval)
if aug && block && !supported?(:post_resource_eval)
augsave!(aug) if autosave
augclose!(aug)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/augeas
Submodule augeas updated 428 files
3 changes: 2 additions & 1 deletion spec/lib/augeas_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module AugeasSpec end

class AugeasSpec::Error < StandardError
end

Expand All @@ -12,6 +13,6 @@ class AugeasSpec::Error < StandardError
config.include AugeasSpec::Fixtures

config.before :each do
Puppet::Util::Storage.stubs(:store)
allow(Puppet::Util::Storage).to receive(:store)
end
end
Loading

0 comments on commit 637108e

Please sign in to comment.