Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/toptal/rspec-any_of
any_of/all_of argument matcher for RSpec
https://github.com/toptal/rspec-any_of
rspec rspec-custom-matchers rspec-matchers
Last synced: 25 days ago
JSON representation
any_of/all_of argument matcher for RSpec
- Host: GitHub
- URL: https://github.com/toptal/rspec-any_of
- Owner: toptal
- License: mit
- Created: 2019-05-02T14:22:31.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-22T04:39:23.000Z (over 1 year ago)
- Last Synced: 2024-11-02T05:32:40.331Z (about 1 month ago)
- Topics: rspec, rspec-custom-matchers, rspec-matchers
- Language: Ruby
- Homepage:
- Size: 11.7 KB
- Stars: 5
- Watchers: 139
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
Awesome Lists containing this project
- awesome-rspec - rspec-any_of - Provides `any_of` and `all_of` matchers. (Matchers)
README
= RSpec `any_of`/`all_of` argument matchers
Argument matchers accepting a list of allowed arguments:
- Liberal `any_of` argument inclusion matcher
- Strict `all_of` argument inclusion matcher== Installation
Add `gem 'rspec-any_of'` to `Gemfile` and run `bundle`.
== Usage
Add the following to your `spec/spec_helper.rb`:
[source,ruby]
----
require 'rspec/any_of'RSpec.configure do |config|
# ...
config.include RSpec::AnyOf
end
----Using `rspec-any_of` you can make flexible expectations on method call arguments.
[source,ruby]
----
it 'sends greetings to chat' do
expect(Chat)
.to receive(:message)
.with(all_of('Hello', 'My name is Phil')).twice# The only option normally is to be more verbose.
# This is the most optimistic example, with more arguments it's getting noticeably worse.
expect(Chat)
.to receive(:message).with('Hello')
.and receive(:message).with('My name is Phil')
endit 'greets' do
expect(Greeter)
.to receive(:greet)
.with(any_of('hello', 'good bye'))# Or, normally:
expect(Greeter)
.to receive(:greet)
.with(eq('hello').or(eq('good bye')))
end
----== Development
Check out the repo, run `bundle` to install dependencies.
Make your change, run `rspec`, `rubocop` to check the style, and `yardoc` to make sure documentation is correct.== Contributing
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the https://www.contributor-covenant.org[Contributor Covenant] code of conduct.
Bug reports and pull requests are welcome https://github.com/toptal/rspec-any_of/issues[on GitHub].
== License
https://opensource.org/licenses/MIT[MIT License].