Skip to content

Commit

Permalink
Remove deprecated assert_no_match in favor of refute_match
Browse files Browse the repository at this point in the history
  • Loading branch information
ekohl committed Mar 2, 2023
1 parent 7df9624 commit 6282311
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@

result = run_cron_on default, :list, default['user']

assert_no_match %r{job :1:}, result.stdout
assert_no_match %r{job :2:}, result.stdout
refute_match %r{job :1:}, result.stdout
refute_match %r{job :2:}, result.stdout
assert_match %r{job :3:}, result.stdout
end

Expand Down Expand Up @@ -181,8 +181,8 @@

result = run_cron_on default, :list, default['user']

assert_no_match %r{job :1:}, result.stdout
assert_no_match %r{job :2:}, result.stdout
refute_match %r{job :1:}, result.stdout
refute_match %r{job :2:}, result.stdout
assert_match %r{job :3:}, result.stdout
end

Expand Down
1 change: 0 additions & 1 deletion docs/how_to/the_beaker_dsl.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ To be used for confirming the result of a test is as expected. Beaker include a

* [Minitest assertions](http://docs.seattlerb.org/minitest/Minitest/Assertions.html)
* [assert_output](http://www.rubydoc.info/github/puppetlabs/beaker/Beaker/DSL/Assertions#assert_output-instance_method)
* [assert_no_match](http://www.rubydoc.info/github/puppetlabs/beaker/Beaker/DSL/Assertions#assert_no_match-instance_method)

## Helpers

Expand Down
13 changes: 0 additions & 13 deletions lib/beaker/dsl/assertions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,6 @@ def assert_output(exp_out, msg='Output lines did not match')
assert_equal our_err, (result.nil? ? '' : result.stderr),
'The contents of STDERR did not match expectations'
end

# Assert that the provided string does not match the provided regular expression, can pass optional message
# @deprecated This is placed her for backwards compatability for tests that used Test::Unit::Assertions,
# http://apidock.com/ruby/Test/Unit/Assertions/assert_no_match
#
def assert_no_match(regexp, string, msg=nil)
assert_instance_of(Regexp, regexp, "The first argument to assert_no_match should be a Regexp.")
msg = message(msg) { "<#{mu_pp(regexp)}> expected to not match\n<#{mu_pp(string)}>" }
assert(regexp !~ string, msg)
end

alias_method :assert_not_match, :assert_no_match

end
end
end
2 changes: 1 addition & 1 deletion spec/beaker/dsl/structure_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class ClassMixedWithDSLStructure
it 'passes when a Beaker assertion is raised' do
expect( subject ).to receive( :logger ).and_return( logger )
expect( logger ).to receive( :notify )
block = lambda { assert_no_match('1', '1', '1 and 1 should not match') }
block = lambda { refute_match('1', '1', '1 and 1 should not match') }
expect{ subject.expect_failure 'this is an expected failure', &block }.not_to raise_error
end

Expand Down

0 comments on commit 6282311

Please sign in to comment.