Sha256: bb0bb18670576bb55fe904b6cfd01341bca3e63cc8fc1a95b03aa023c1a6449c

Contents?: true

Size: 692 Bytes

Versions: 2

Compression:

Stored size: 692 Bytes

Contents

module TraceMatcher
  def trace(list)
    list = [list] unless list.is_a?(Array)
    TraceMatcher::Matcher.new(list)
  end
  
  class Matcher
    def initialize(list)
      @expected = list
    end
    
    def matches?(actual)
      @actual = actual
      matches = @expected.map do |e|
        @actual['workitem']['fields']['trace'].include?(e)
      end
      
      !matches.any? { |x| x == false }
    end
    
    def failure_message
      "Expected #{@actual['workitem']['fields']} to execute all of #{@expected}"
    end
    
    def negative_failure_message
      "Expected #{@actual['workitem']['fields']} to not execute any of #{@expected}"
    end
  end
end

RWorld(TraceMatcher)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruote-library-1.1.0 spec/support/trace_matcher.rb
ruote-library-1.0.0 spec/support/trace_matcher.rb