Sha256: bb4bc6fb815dd8133016311ef13a59b261741684ace3e173bcdfd5cd7338212b

Contents?: true

Size: 737 Bytes

Versions: 458

Compression:

Stored size: 737 Bytes

Contents

module Matchers; module Include
  extend RSpec::Matchers::DSL

  matcher :include_in_any_order do |*matchers|
    match do |enumerable|
      @not_matched = []
      expected_as_array.each do |matcher|
        if enumerable.empty?
          break
        end

        if found = enumerable.find { |elem| matcher.matches?(elem) }
          enumerable = enumerable.reject { |elem| elem == found }
        else
          @not_matched << matcher
        end
      end


      @not_matched.empty? && enumerable.empty?
    end

    failure_message do |enumerable|
      "did not match #{@not_matched.collect(&:description).join(', ')} in #{enumerable.inspect}: <#{@not_matched.collect(&:failure_message).join('>, <')}>"
    end
  end
end; end

Version data entries

458 entries across 458 versions & 1 rubygems

Version Path
puppet-7.4.1 spec/lib/matchers/include.rb
puppet-7.4.1-x86-mingw32 spec/lib/matchers/include.rb
puppet-7.4.1-x64-mingw32 spec/lib/matchers/include.rb
puppet-7.4.1-universal-darwin spec/lib/matchers/include.rb
puppet-6.21.1 spec/lib/matchers/include.rb
puppet-6.21.1-x86-mingw32 spec/lib/matchers/include.rb
puppet-6.21.1-x64-mingw32 spec/lib/matchers/include.rb
puppet-6.21.1-universal-darwin spec/lib/matchers/include.rb
puppet-7.4.0 spec/lib/matchers/include.rb
puppet-7.4.0-x86-mingw32 spec/lib/matchers/include.rb
puppet-7.4.0-x64-mingw32 spec/lib/matchers/include.rb
puppet-7.4.0-universal-darwin spec/lib/matchers/include.rb
puppet-6.21.0 spec/lib/matchers/include.rb
puppet-6.21.0-x86-mingw32 spec/lib/matchers/include.rb
puppet-6.21.0-x64-mingw32 spec/lib/matchers/include.rb
puppet-6.21.0-universal-darwin spec/lib/matchers/include.rb
puppet-7.3.0 spec/lib/matchers/include.rb
puppet-7.3.0-x86-mingw32 spec/lib/matchers/include.rb
puppet-7.3.0-x64-mingw32 spec/lib/matchers/include.rb
puppet-7.3.0-universal-darwin spec/lib/matchers/include.rb