Sha256: 4dbf337de4efce5eb4f82de32f2b5208f9713d75112a879e7b3e10ec68ebc0c7

Contents?: true

Size: 1.09 KB

Versions: 19

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)}.\nExpected #{expected_times_message}."
      end

      def ==(other)
        self.class == other.class && self.times == other.times
      end

      def expected_times_message
        "#{@times.inspect} times"
      end

      protected
      def pluralized_time(times_called)
        (times_called == 1) ? "time" : "times"
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 4 rubygems

Version Path
jferris-rr-0.7.1.0.1239654108 lib/rr/times_called_matchers/times_called_matcher.rb
redinger-redinger-rr-0.10.3 lib/rr/times_called_matchers/times_called_matcher.rb
redinger-rr-0.10.4 lib/rr/times_called_matchers/times_called_matcher.rb
rr-0.10.11 lib/rr/times_called_matchers/times_called_matcher.rb
rr-0.10.10 lib/rr/times_called_matchers/times_called_matcher.rb
rr-0.10.9 lib/rr/times_called_matchers/times_called_matcher.rb
rr-0.10.8 lib/rr/times_called_matchers/times_called_matcher.rb
rr-0.10.7 lib/rr/times_called_matchers/times_called_matcher.rb
rr-0.10.6 lib/rr/times_called_matchers/times_called_matcher.rb
rr-0.10.5 lib/rr/times_called_matchers/times_called_matcher.rb
rr-0.10.4 lib/rr/times_called_matchers/times_called_matcher.rb
rr-0.10.2 lib/rr/times_called_matchers/times_called_matcher.rb
redinger-rr-0.10.3 lib/rr/times_called_matchers/times_called_matcher.rb
rr-0.10.0 lib/rr/times_called_matchers/times_called_matcher.rb
rr-0.8.0 lib/rr/times_called_matchers/times_called_matcher.rb
rr-0.8.1 lib/rr/times_called_matchers/times_called_matcher.rb
rr-0.7.1 lib/rr/times_called_matchers/times_called_matcher.rb
rr-0.9.0 lib/rr/times_called_matchers/times_called_matcher.rb
rr-0.7.0 lib/rr/times_called_matchers/times_called_matcher.rb