Sha256: 3c626830203b3346fb811262923a0b9858072e7e4eacc95c9a27e9e4e79a064c

Contents?: true

Size: 782 Bytes

Versions: 28

Compression:

Stored size: 782 Bytes

Contents

begin
  require 'rspec/matchers'
rescue LoadError
  
end

if defined? RSpec::Matchers
  RSpec::Matchers.define :have_categories do |*expected|

    match do |results|
      extract_categories(actual) == expected
    end

    failure_message_for_should do |results|
      "expected categories #{extract_categories(results)} to be named and ordered as #{expected}"
    end

    failure_message_for_should_not do |results|
      "expected categories #{extract_categories(results)} not to be named and ordered as #{expected}"
    end

    description do
      "be categories named and ordered as #{expected}"
    end

    def extract_categories results
      results.allocations.map do |allocation|
        allocation[3].map { |combination| combination[0] }
      end
    end

  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
picky-client-4.31.3 lib/picky-client/spec/support/matchers/have_categories.rb
picky-client-4.31.2 lib/picky-client/spec/support/matchers/have_categories.rb
picky-client-4.31.1 lib/picky-client/spec/support/matchers/have_categories.rb
picky-client-4.31.0 lib/picky-client/spec/support/matchers/have_categories.rb
picky-client-4.30.0 lib/picky-client/spec/support/matchers/have_categories.rb
picky-client-4.29.0 lib/picky-client/spec/support/matchers/have_categories.rb
picky-client-4.28.1 lib/picky-client/spec/support/matchers/have_categories.rb
picky-client-4.27.1 lib/picky-client/spec/support/matchers/have_categories.rb
picky-client-4.27.0 lib/picky-client/spec/support/matchers/have_categories.rb
picky-client-4.26.2 lib/picky-client/spec/support/matchers/have_categories.rb
picky-client-4.26.1 lib/picky-client/spec/support/matchers/have_categories.rb
picky-client-4.26.0 lib/picky-client/spec/support/matchers/have_categories.rb
picky-client-4.25.3 lib/picky-client/spec/support/matchers/have_categories.rb
picky-client-4.25.2 lib/picky-client/spec/support/matchers/have_categories.rb
picky-client-4.25.1 lib/picky-client/spec/support/matchers/have_categories.rb
picky-client-4.25.0 lib/picky-client/spec/support/matchers/have_categories.rb
picky-client-4.24.0 lib/picky-client/spec/support/matchers/have_categories.rb
picky-client-4.23.2 lib/picky-client/spec/support/matchers/have_categories.rb
picky-client-4.23.1 lib/picky-client/spec/support/matchers/have_categories.rb
picky-client-4.23.0 lib/picky-client/spec/support/matchers/have_categories.rb