Sha256: b4799961ee285653e20f454cc43947fbb96dddeae889047efeb702f88b1c8158
Contents?: true
Size: 1.09 KB
Versions: 26
Compression:
Stored size: 1.09 KB
Contents
module RR module TimesCalledMatchers class TimesCalledMatcher #:nodoc: class << self def create(value) return value if value.is_a?(TimesCalledMatcher) return IntegerMatcher.new(value) if value.is_a?(Integer) return RangeMatcher.new(value) if value.is_a?(Range ) return ProcMatcher.new(value) if value.is_a?(Proc) raise ArgumentError, "There is no TimesCalledMatcher for #{value.inspect}." end end attr_reader :times def initialize(times) @times = times end def matches?(times_called) end def attempt?(times_called) end def error_message(times_called) "Called #{times_called.inspect} #{pluralized_time(times_called)}.\n#{expected_message_part}" end def ==(other) self.class == other.class && self.times == other.times end protected def expected_message_part "Expected #{@times.inspect} times." end def pluralized_time(times_called) (times_called == 1) ? "time" : "times" end end end end
Version data entries
26 entries across 26 versions & 2 rubygems