Sha256: 8465c8a589758b7b6b7418d92802d1ef3bd5a1bd88ef34ae2a6eead4be38113a

Contents?: true

Size: 790 Bytes

Versions: 3

Compression:

Stored size: 790 Bytes

Contents

require 'matchers/events/matcher'

module StateMachineRspec
  module Matchers
    def reject_events(value, *values)
      RejectEventMatcher.new(values.unshift(value))
    end
    alias_method :reject_event, :reject_events

    class RejectEventMatcher < StateMachineRspec::Matchers::Events::Matcher
      def matches_events?(events)
        !valid_events?
      end

      private

      def valid_events?
        valid_events = @introspector.valid_events(@events)
        unless valid_events.empty?
          @failure_message = "Did not expect to be able to handle events: " +
                              "#{valid_events.join(', ')} in state: " +
                              "#{@introspector.current_state_value}"
        end

        !valid_events.empty?
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
state_machine_rspec-0.1.2 lib/matchers/events/reject_event.rb
state_machine_rspec-0.1.1 lib/matchers/events/reject_event.rb
state_machine_rspec-0.1.0 lib/matchers/events/reject_event.rb