<commit_before>require File.join(File.dirname(__FILE__), "helpers")
require "sensu/settings/rules"

describe "Sensu::Settings::Rules" do
  include Helpers
  include Sensu::Settings::Rules

  it "can provide validation rules" do
    expect(must_be_a_hash({})).to be(true)
    expect(must_be_a_hash("")).to be(false)
    expect(must_be_a_hash_if_set({})).to be(true)
    expect(must_be_a_hash_if_set(nil)).to be(true)
    expect(must_be_a_hash_if_set("")).to be(false)
    expect(must_be_an_array([])).to be(true)
    expect(must_be_an_array("")).to be(false)
    expect(must_be_an_array_if_set([])).to be(true)
    expect(must_be_an_array_if_set(nil)).to be(true)
    expect(must_be_an_array_if_set("")).to be(false)
    expect(must_be_a_string("")).to be(true)
    expect(must_be_a_string(1)).to be(false)
    expect(must_be_a_string_if_set("")).to be(true)
    expect(must_be_a_string_if_set(nil)).to be(true)
    expect(must_be_a_string_if_set(1)).to be(false)
    expect(must_be_an_integer(1)).to be(true)
    expect(must_be_an_integer("")).to be(false)
    expect(must_be_a_numeric(1.5)).to be(true)
    expect(must_be_a_numeric("")).to be(false)
    expect(must_match_regex(/^foo$/, "foo")).to be(true)
    expect(must_match_regex(/^foo$/, "bar")).to be(false)
    expect(must_match_regex(/^\w$/, "baz$")).to be(false)
    expect(must_be_boolean_if_set(true)).to be(true)
    expect(must_be_boolean_if_set(false)).to be(true)<commit_msg>made further must_match_regex spec improvements<commit_after>require File.join(File.dirname(__FILE__), "helpers")
require "sensu/settings/rules"

describe "Sensu::Settings::Rules" do
  include Helpers
  include Sensu::Settings::Rules

  it "can provide validation rules" do
    expect(must_be_a_hash({})).to be(true)
    expect(must_be_a_hash("")).to be(false)
    expect(must_be_a_hash_if_set({})).to be(true)
    expect(must_be_a_hash_if_set(nil)).to be(true)
    expect(must_be_a_hash_if_set("")).to be(false)
    expect(must_be_an_array([])).to be(true)
    expect(must_be_an_array("")).to be(false)
    expect(must_be_an_array_if_set([])).to be(true)
    expect(must_be_an_array_if_set(nil)).to be(true)
    expect(must_be_an_array_if_set("")).to be(false)
    expect(must_be_a_string("")).to be(true)
    expect(must_be_a_string(1)).to be(false)
    expect(must_be_a_string_if_set("")).to be(true)
    expect(must_be_a_string_if_set(nil)).to be(true)
    expect(must_be_a_string_if_set(1)).to be(false)
    expect(must_be_an_integer(1)).to be(true)
    expect(must_be_an_integer("")).to be(false)
    expect(must_be_a_numeric(1.5)).to be(true)
    expect(must_be_a_numeric("")).to be(false)
    expect(must_match_regex(/^foo$/, "foo")).to be(true)
    expect(must_match_regex(/^foo$/, "bar")).to be(false)
    expect(must_match_regex(/^\w+$/, "baz$")).to be(false)
    expect(must_be_boolean_if_set(true)).to be(true)
    expect(must_be_boolean_if_set(false)).to be(true)
{'fraction_non_alphanumeric': 0.16752312435765673, 'fraction_numerical': 0.0034258307639602604, 'mean_word_length': 5.935866983372922, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '6467352', 'n_tokens_mistral': 1178, 'n_tokens_neox': 1173, 'n_words': 141}