Collectors (all matches that argue against strings, hashes, and arrays) were abstracted into a separate gem, rspec-collection_matchers .
To use these mappings, add this to your Gemfile :
gem 'rspec-collection_matchers'
Or your .gemspec if you are working on a gem:
spec.add_development_dependency 'rspec-collection_matchers'
Then add this to your spec_helper.rb :
require 'rspec/collection_matchers'
And then you can use the assemblers in your specification:
require spec_helper describe 'array' do subject { [1,2,3] } it { is_expected.to have(3).items } it { is_expected.to_not have(2).items } it { is_expected.to_not have(4).items } it { is_expected.to have_exactly(3).items } it { is_expected.to_not have_exactly(2).items } it { is_expected.to_not have_exactly(4).items } it { is_expected.to have_at_least(2).items } it { is_expected.to have_at_most(4).items } # deliberate failures it { is_expected.to_not have(3).items } it { is_expected.to have(2).items } it { is_expected.to have(4).items } it { is_expected.to_not have_exactly(3).items } it { is_expected.to have_exactly(2).items } it { is_expected.to have_exactly(4).items } it { is_expected.to have_at_least(4).items } it { is_expected.to have_at_most(2).items } end
Note that you can use items and characters interchangeably, it's just sugar syntax, and the have match and its variants can be used on arrays, hashes, and your string.
Jaytarka
source share