+ float? comparison can raise a TypeError
+ octal? comparison was allowing non-octal values (which cast to 0)
+ symbol comparison was casting to a string, but then doing an == check instead of casecmp.
The latter seems optional, but consistent with the intent of cmp.
Signed-off-by: Ryan Davis <zenspider@chef.io>
obj.method(name).call(*args) == obj.send(name, *args)
```
Calculating -------------------------------------
method+call 2.561M (± 2.2%) i/s - 12.816M in 5.006835s
send 6.299M (± 2.4%) i/s - 31.501M in 5.004045s
Comparison:
send: 6299002.5 i/s
method+call: 2560909.2 i/s - 2.46x slower
```
There aren't any direct tests for this? But I forcefully failed 2
functionals and then verified they passed after my change.
Not sure how (or if) to write tests against rspec matchers in a
meaningful way, even tho all I really want to test is a plain ole
method in it. I'll poke to see if it is possible / practical.
Signed-off-by: Ryan Davis <zenspider@chef.io>
This converts all current deprecation warnings/TODOs to use the
`Inspec.deprecate()` deprecation facility.
This also modifies `Inspec.deprecate()` to only require 1 argument.
Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
This modifies the output of failed test when using the `cmp` matcher by
calling `.inspect` on the actual value passed.
This makes it easier to diagnose failed matches due to characters such
as `\n` not being visible.
Current behavior:
```
inspec> describe command('echo demo') do
inspec> its('stdout') { should cmp 'demo' }
inspec> end
Profile: inspec-shell
Version: (not specified)
Command: `echo demo`
× stdout should cmp == "demo"
expected: "demo"
got: demo
(compared using `cmp` matcher)
Test Summary: 0 successful, 1 failure, 0 skipped
```
New behavior:
```
inspec> describe command('echo demo') do
inspec> its('stdout') { should cmp 'demo' }
inspec> end
Profile: inspec-shell
Version: (not specified)
Command: `echo demo`
× stdout should cmp == "demo"
expected: "demo"
got: "demo\n"
(compared using `cmp` matcher)
Test Summary: 0 successful, 1 failure, 0 skipped
```
Many thanks to @jazaval for discovering this!
Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
* Bump Rubocop to 0.49.1
This change bumps Rubocop to 0.49.1. There have been a lot of changes
since 0.39.0 and this PR is hopefully a nice compromise of turning off
certain cops and updating our codebase to take advantage of new Ruby
2.3 methods and operators.
Signed-off-by: Adam Leff <adam@leff.co>
* Set end-of-line format to line-feed only, avoid Windows-related CRLF issues
Signed-off-by: Adam Leff <adam@leff.co>
* Enhance cmp matcher to work with symbols
The `cmp` matcher will now stringify symbol actual values if the
expected value was passed in as a string. This will help with the file
resource `type` method where Train returns the file type as a symbol.
Signed-off-by: Adam Leff <adam@leff.co>
* Fix documentation for file type character_device
Signed-off-by: Adam Leff <adam@leff.co>
* Fix docs for block_device
Signed-off-by: Adam Leff <adam@leff.co>
* Fix file mtime docs
Signed-off-by: Adam Leff <adam@leff.co>
* New matcher 'be_in'
Fixes#2018
Signed-off-by: Rony Xavier <rx294@nyu.edu>
* small fixes to wording.
Signed-off-by: Aaron Lippold <lippold@gmail.com>
* Added code to use be_in for with the following use case:
describe nginx do
its(module_list) { should be_in AUTHORIZED_MODULE_LIST }
end
Fixes#2018
Signed-off-by: Rony Xavier <rx294@nyu.edu>
* Updates to the matcher
Fixes#2018
Signed-off-by: Rony Xavier <rx294@nyu.edu>
* Added tests for the be_in matcher
Signed-off-by: Rony Xavier <rx294@nyu.edu>
* Requested updates completed
Signed-off-by: Rony Xavier <rx294@nyu.edu>
* Remove any "All Rights Reserved" references
InSpec is licensed and released under the Apache 2.0 license. This
change removes all reference to legacy code files that still had
any Copyright or License lines referring to "All Rights Reserved".
Signed-off-by: Adam Leff <adam@leff.co>
* fix functional tests
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>