Sha256: 1e2dcb14afe807412ac0c7a9349aeef2d8b6e711065cf694dfdab13f490c962e
Contents?: true
Size: 1.11 KB
Versions: 4
Compression:
Stored size: 1.11 KB
Contents
module ElabsMatchers module Matchers module OnlyInclude rspec class OnlyIncludeMatcher < Struct.new(:elements) attr_reader :actual def matches?(actual) @actual = actual elements.uniq.length == elements.length and actual.length == elements.length and elements.all? { |element| actual.include?(element) } end def failure_message_for_should "Expected #{actual.inspect} to only include #{elements.inspect}." end def failure_message_for_should_not "Expected #{actual.inspect} to not only include #{elements.inspect}, but it did." end end ## # # Asserts if the array contains exactly the supplied elements. # The order of the element do not have to match. # # @param [*Array] elements Comma seperated list of arguments # # Example: # ["foo", "bar"].should only_include("bar", "foo") # ["foo", "bar"].should_not only_include("foo") def only_include(*elements) OnlyIncludeMatcher.new(elements) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems