Sha256: 81c8d793899a89928fb4ac66b7db26aff1cabb14212fd5867951ecfa5c77ce3a

Contents?: true

Size: 614 Bytes

Versions: 4

Compression:

Stored size: 614 Bytes

Contents

module Counter
  module RSpecMatchers
    def increment_counter_for(...)
      IncrementCounterFor.new(...)
    end

    def decrement_counter_for(...)
      DecrementCounterFor.new(...)
    end

    class Base < RSpec::Matchers::BuiltIn::Change
      def initialize(counter_class, parent)
        super { parent.counters.find_or_create_counter!(counter_class).value }
      end
    end

    class IncrementCounterFor < Base
      def matches?(...)
        by(1).matches?(...)
      end
    end

    class DecrementCounterFor < Base
      def matches?(...)
        by(-1).matches?(...)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
counterwise-0.1.5 lib/counter/rspec/matchers.rb
counterwise-0.1.4 lib/counter/rspec/matchers.rb
counterwise-0.1.3 lib/counter/rspec/matchers.rb
counterwise-0.1.2 lib/counter/rspec/matchers.rb