Sha256: 6c0bbb0674ec6a99ba9d6a9336a33f6204c057cbf894042b07ef843c809992c4
Contents?: true
Size: 1.49 KB
Versions: 1
Compression:
Stored size: 1.49 KB
Contents
module ElabsMatchers module Matchers module OnlyInclude rspec class OnlyIncludeMatcher < Struct.new(:elements) attr_reader :actual def matches?(actual) deprecated @actual = actual elements.uniq.length == elements.length and actual.length == elements.length and elements.all? { |element| actual.include?(element) } end def failure_message "Expected #{actual.inspect} to only include #{elements.inspect}." end alias_method :failure_message_for_should, :failure_message def failure_message_when_negated "Expected #{actual.inspect} to not only include #{elements.inspect}, but it did." end alias_method :failure_message_for_should_not, :failure_message_when_negated private def deprecated warn %Q{ [DEPRECATION] `only_include` is deprecated. Please use rspec's `contain_exactly` instead. Called from #{Kernel.caller.first} } 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
elabs_matchers-2.0.1 | lib/elabs_matchers/matchers/only_include.rb |