Sha256: 232cce64ff12b87cbc35995f6786034bd3c53c8e29cc9da0d2cd7d046cd3645c

Contents?: true

Size: 860 Bytes

Versions: 1

Compression:

Stored size: 860 Bytes

Contents

# frozen_string_literal: true

module RSpec
  module Grape
    module Entity
      module Matchers
        module HaveRootMatcher
          extend RSpec::Matchers::DSL

          matcher :have_root do |plural|
            include MatcherHelpers

            match do |actual|
              actual_plural = actual.root_element :collection_root
              actual_singular = actual.root_element :root

              values_match?(plural, actual_plural) &&
                values_match?(singular, actual_singular)
            end

            description { "have the formatting #{expected}" }

            failure_message do |actual|
              "expect that \"#{actual}\" would have the root collection \"#{plural}\" and root \"#{singular}\""
            end

            chain :with_singular, :singular
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-grape-entity-0.1.0 lib/rspec_grape_entity/matchers/have_root_matcher.rb