0.02
No release in over 3 years
Low commit activity in last 3 years
HTML equivalence RSpec matcher
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 10.0
~> 3.0
~> 0.68.1
~> 1.32.0
= 0.9.19

Runtime

 Project 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:

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.

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')
end

it '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 Contributor Covenant code of conduct.

Bug reports and pull requests are welcome on GitHub.

License