<commit_before># frozen_string_literal: true

require "test_helper"

describe Committee::SchemaValidator::OpenAPI3::ResponseValidator do
  before do
    @status = 200
    @headers = {
      "Content-Type" => "application/json"
    }
    @data = {"string" => "Honoka.Kousaka"}

    @path = '/validate'
    @method = 'post'
    @validator_option = Committee::SchemaValidator::Option.new({}, open_api_3_schema, :open_api_3)
  end

  it "passes through a valid response" do
    call_response_validator
  end

  it "passes through a valid response with Content-Type options" do
    @headers = { "Content-Type" => "application/json; charset=utf-8" }
    call_response_validator
  end

  it "passes through a valid response with no registered Content-Type with strict = false" do
    @headers = { "Content-Type" => "application/xml" }
    call_response_validator
  end

  it "passes through a valid response with no registered Content-Type with strict = true" do
    @headers = { "Content-Type" => "application/xml" }
    assert_raises(Committee::InvalidResponse) {
      call_response_validator(true)
    }
  end

  it "passes through a valid response with no Content-Type" do
    @headers = {}
    call_response_validator
  end

  it "passes through a valid response with no Content-Type with strict option" do
    @headers = {}
    assert_raises(Committee::InvalidResponse) {<commit_msg>docs(test): fix some test suite names<commit_after># frozen_string_literal: true

require "test_helper"

describe Committee::SchemaValidator::OpenAPI3::ResponseValidator do
  before do
    @status = 200
    @headers = {
      "Content-Type" => "application/json"
    }
    @data = {"string" => "Honoka.Kousaka"}

    @path = '/validate'
    @method = 'post'
    @validator_option = Committee::SchemaValidator::Option.new({}, open_api_3_schema, :open_api_3)
  end

  it "passes through a valid response" do
    call_response_validator
  end

  it "passes through a valid response with Content-Type options" do
    @headers = { "Content-Type" => "application/json; charset=utf-8" }
    call_response_validator
  end

  it "passes through a valid response with no registered Content-Type with strict = false" do
    @headers = { "Content-Type" => "application/xml" }
    call_response_validator
  end

  it "raises InvalidResponse when a valid response with no registered body with strict option" do
    @headers = { "Content-Type" => "application/xml" }
    assert_raises(Committee::InvalidResponse) {
      call_response_validator(true)
    }
  end

  it "passes through a valid response with no Content-Type" do
    @headers = {}
    call_response_validator
  end

  it "raises InvalidResponse when a valid response with no Content-Type headers with strict option" do
    @headers = {}
    assert_raises(Committee::InvalidResponse) {
{'fraction_non_alphanumeric': 0.09978693181818182, 'fraction_numerical': 0.004971590909090909, 'mean_word_length': 3.8153846153846156, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6718436', 'n_tokens_mistral': 847, 'n_tokens_neox': 832, 'n_words': 246}