Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matcher : be_in #2018

Closed
rx294 opened this issue Jul 18, 2017 · 2 comments
Closed

Matcher : be_in #2018

rx294 opened this issue Jul 18, 2017 · 2 comments
Labels
Type: Enhancement Improves an existing feature

Comments

@rx294
Copy link
Contributor

rx294 commented Jul 18, 2017

Description

It will be very very useful to have a matcher that serves the following use case

describe nginx do
its('user') { should be_in AUTHORIZED_USER_LIST }
end

describe nginx do
its('module') { should_not be_in VULNURABLE_MODULE_LIST }
end

describe nginx do
its('user') { should_not be_in UNAUTHORIZED_USER_LIST }
end

Possible Solutions

The following code in matches.rb does the job

RSpec::Matchers.define :be_in do |list|
match do |item|
list.include?(item)
end

failure_message do |item|
"expected that #{item} to be in #{list}"
end
end

rx294 added a commit to aaronlippold/inspec that referenced this issue Jul 18, 2017
Fixes inspec#2018

Signed-off-by: Rony Xavier <rx294@nyu.edu>
@arlimus
Copy link
Contributor

arlimus commented Jul 20, 2017

Love the direction of this @rx294 !! :)

@arlimus arlimus added the Type: Enhancement Improves an existing feature label Jul 20, 2017
@rx294
Copy link
Contributor Author

rx294 commented Jul 20, 2017

Thank you @arlimus, hope you guys can decide on the matcher's name soon...unless it can remain 'be_in' :)

rx294 added a commit to aaronlippold/inspec that referenced this issue Jul 20, 2017
describe nginx do
   its(module_list) { should be_in AUTHORIZED_MODULE_LIST }
end
Fixes inspec#2018

Signed-off-by: Rony Xavier <rx294@nyu.edu>
rx294 added a commit to aaronlippold/inspec that referenced this issue Jul 22, 2017
Fixes inspec#2018

Signed-off-by: Rony Xavier <rx294@nyu.edu>
chris-rock pushed a commit that referenced this issue Aug 7, 2017
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Improves an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants