Sha256: eb9de6292e3a902346bc9893785208065039401b8ab6723120a6a55173bc84d3

Contents?: true

Size: 1.1 KB

Versions: 22

Compression:

Stored size: 1.1 KB

Contents

module RR
  module TimesCalledMatchers
    class TimesCalledMatcher #:nodoc:
      extend(Module.new do
        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

22 entries across 18 versions & 5 rubygems

Version Path
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.3/vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/lib/rr/times_called_matchers/times_called_matcher.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.3/vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/lib/rr/times_called_matchers/times_called_matcher.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/lib/rr/times_called_matchers/times_called_matcher.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/lib/rr/times_called_matchers/times_called_matcher.rb
bitclust-core-0.5.2 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/lib/rr/times_called_matchers/times_called_matcher.rb
bitclust-core-0.5.2 vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/lib/rr/times_called_matchers/times_called_matcher.rb
bitclust-core-0.5.1 vendor/bundle/ruby/1.9.1/gems/rr-1.0.4/lib/rr/times_called_matchers/times_called_matcher.rb
mcmire-rr-1.0.5.rc1 lib/rr/times_called_matchers/times_called_matcher.rb
messagebus_ruby_api-0.4.7 spec/ruby/1.9.1/gems/rr-1.0.2/lib/rr/times_called_matchers/times_called_matcher.rb
messagebus_ruby_api-0.4.4 spec/ruby/1.9.1/gems/rr-1.0.2/lib/rr/times_called_matchers/times_called_matcher.rb
rr-1.0.4 lib/rr/times_called_matchers/times_called_matcher.rb
rr-1.0.3 lib/rr/times_called_matchers/times_called_matcher.rb
vim-jar-0.1.2.0001 bundler/ruby/1.8/gems/rr-1.0.2/lib/rr/times_called_matchers/times_called_matcher.rb
vim-jar-0.1.2 bundler/ruby/1.8/gems/rr-1.0.2/lib/rr/times_called_matchers/times_called_matcher.rb
vim-jar-0.1.1 bundler/ruby/1.8/gems/rr-1.0.2/lib/rr/times_called_matchers/times_called_matcher.rb
vim-jar-0.1.0 bundler/ruby/1.8/gems/rr-1.0.2/lib/rr/times_called_matchers/times_called_matcher.rb
vim-jar-0.0.3 bundler/ruby/1.8/gems/rr-1.0.2/lib/rr/times_called_matchers/times_called_matcher.rb
vim-jar-0.0.2 bundler/ruby/1.8/gems/rr-1.0.2/lib/rr/times_called_matchers/times_called_matcher.rb
vim-jar-0.0.1 bundler/ruby/1.8/gems/rr-1.0.2/lib/rr/times_called_matchers/times_called_matcher.rb
rr-1.0.2 lib/rr/times_called_matchers/times_called_matcher.rb