Sha256: 6b95188af0d69322c5d640f8dda76e1b75ab59b1c73d5ca689858792539d0a03

Contents?: true

Size: 895 Bytes

Versions: 8

Compression:

Stored size: 895 Bytes

Contents

require "govuk_schemas/validator"

module GovukSchemas
  module AssertMatchers
    def assert_valid_against_publisher_schema(payload, schema_name)
      assert_valid_against_schema(payload, schema_name, "publisher")
    end

    def assert_valid_against_links_schema(payload, schema_name)
      assert_valid_against_schema(payload, schema_name, "links")
    end

    def assert_valid_against_frontend_schema(payload, schema_name)
      assert_valid_against_schema(payload, schema_name, "frontend")
    end

    def assert_valid_against_notification_schema(payload, schema_name)
      assert_valid_against_schema(payload, schema_name, "notification")
    end

  private

    def assert_valid_against_schema(payload, schema_name, schema_type)
      validator = GovukSchemas::Validator.new(schema_name, schema_type, payload)
      assert validator.valid?, validator.error_message
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
govuk_schemas-5.0.4 lib/govuk_schemas/assert_matchers.rb
govuk_schemas-5.0.3 lib/govuk_schemas/assert_matchers.rb
govuk_schemas-5.0.0 lib/govuk_schemas/assert_matchers.rb
govuk_schemas-4.7.0 lib/govuk_schemas/assert_matchers.rb
govuk_schemas-4.6.0 lib/govuk_schemas/assert_matchers.rb
govuk_schemas-4.5.0 lib/govuk_schemas/assert_matchers.rb
govuk_schemas-4.4.1 lib/govuk_schemas/assert_matchers.rb
govuk_schemas-4.4.0 lib/govuk_schemas/assert_matchers.rb