RSpec::ChangeCollection provides the to_include
and to_exclude
methods to the change
for blocks that return a collection.
Installation
Add this line to your application's Gemfile:
gem 'rspec-change_collection'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rspec-change_collection
And require it as:
require 'rspec/change_collection'
Usage
Use the to_include
and to_exclude
methods to make assertions about the effect of an rspec change
block.
Both to_include
and to_exclude
accept objects or blocks. You can pass it a list of objects:
array = []
expect { array << 1 << 2 }.to change { array }.to_include 1, 2
And you can use block to make claims about any of the items before and after the change:
array = [1]
expect { array << 2 }.to change { array }.to_include(&:even?)
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request