<commit_before>require 'spec_helper'

describe Whois::Record do

  subject { described_class.new(server, parts) }

  let(:server) {
    Whois::Server.factory(:tld, ".foo", "whois.example.test")
  }
  let(:parts) {[
    Whois::Record::Part.new(body: "This is a record from foo.", host: "foo.example.test"),
    Whois::Record::Part.new(body: "This is a record from bar.", host: "bar.example.test")
  ]}


  describe "#respond_to?" do
    before(:all) do
      @_properties  = Whois::Parser::PROPERTIES.dup
      @_methods     = Whois::Parser::METHODS.dup
    end

    after(:all) do
      Whois::Parser::PROPERTIES.clear
      Whois::Parser::PROPERTIES.push(*@_properties)
      Whois::Parser::METHODS.clear
      Whois::Parser::METHODS.push(*@_methods)
    end

    it "returns true if method is in self" do
      expect(subject.respond_to?(:to_s)).to be_truthy
    end

    it "returns true if method is in hierarchy" do
      expect(subject.respond_to?(:nil?)).to be_truthy
    end

    it "returns true if method is a property" do
      Whois::Parser::PROPERTIES << :test_property
      expect(subject.respond_to?(:test_property)).to be_truthy
    end

    it "returns true if method is a property?" do
      Whois::Parser::PROPERTIES << :test_property
      expect(subject.respond_to?(:test_property?)).to be_truthy
    end

    it "returns true if method is a method" do
      Whois::Parser::METHODS << :test_method
      expect(subject.respond_to?(:test_method)).to be_truthy
    end

    it "returns true if method is a method" do
      Whois::Parser::METHODS << :test_method
      expect(subject.respond_to?(:test_method?)).to be_truthy
    end
  end


  describe "#parser" do
    it "returns a Parser" do
      expect(subject.parser).to be_a(Whois::Parser)
    end

    it "initializes the parser with self" do
      expect(subject.parser.record).to be(subject)
    end

    it "memoizes the value" do
      expect(subject.instance_eval { @parser }).to be_nil
      parser = subject.parser<commit_msg>Insure tests are not influenced by previous ones.<commit_after>require 'spec_helper'

describe Whois::Record do

  subject { described_class.new(server, parts) }

  let(:server) {
    Whois::Server.factory(:tld, ".foo", "whois.example.test")
  }
  let(:parts) {[
    Whois::Record::Part.new(body: "This is a record from foo.", host: "foo.example.test"),
    Whois::Record::Part.new(body: "This is a record from bar.", host: "bar.example.test")
  ]}


  describe "#respond_to?" do
    before(:all) do
      @_properties  = Whois::Parser::PROPERTIES.dup
      @_methods     = Whois::Parser::METHODS.dup
    end

    after(:all) do
      Whois::Parser::PROPERTIES.clear
      Whois::Parser::PROPERTIES.push(*@_properties)
      Whois::Parser::METHODS.clear
      Whois::Parser::METHODS.push(*@_methods)
    end

    it "returns true if method is in self" do
      expect(subject.respond_to?(:to_s)).to be_truthy
    end

    it "returns true if method is in hierarchy" do
      expect(subject.respond_to?(:nil?)).to be_truthy
    end

    it "returns true if method is a property" do
      Whois::Parser::PROPERTIES << :test_property
      expect(subject.respond_to?(:test_property)).to be_truthy
    end

    it "returns true if method is a property?" do
      Whois::Parser::PROPERTIES << :test_property_b
      expect(subject.respond_to?(:test_property_b?)).to be_truthy
    end

    it "returns true if method is a method" do
      Whois::Parser::METHODS << :test_method
      expect(subject.respond_to?(:test_method)).to be_truthy
    end

    it "returns true if method is a method?" do
      Whois::Parser::METHODS << :test_method_b
      expect(subject.respond_to?(:test_method_b?)).to be_truthy
    end
  end


  describe "#parser" do
    it "returns a Parser" do
      expect(subject.parser).to be_a(Whois::Parser)
    end

    it "initializes the parser with self" do
      expect(subject.parser.record).to be(subject)
    end

    it "memoizes the value" do
      expect(subject.instance_eval { @parser }).to be_nil
      parser = subject.parser
{'fraction_non_alphanumeric': 0.12453851833620477, 'fraction_numerical': 0.0, 'mean_word_length': 3.3188097768331564, 'pattern_counts': {'":': 0, '<': 19, '<?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': '5926254', 'n_tokens_mistral': 1343, 'n_tokens_neox': 1308, 'n_words': 328}