<commit_before>require 'spec_helper'
require 'sisimai/rhost'

describe 'Sisimai::Rhost' do
  describe 'Sisimai::Rhost.list() method' do
    v = Sisimai::Rhost.list()
    it 'list() returns a list' do
      expect(v.kind_of?(Array)).to be true
    end
  end

  describe 'Sisimai::Rhost.match() method' do
    it 'match(aspmx.l.google.com) returns True' do
      expect(Sisimai::Rhost.match('aspmx.l.google.com')).to be true
    end
    it 'match(example.jp) returns False' do
      expect(Sisimai::Rhost.match('example.jp')).to be false
    end
  end

  describe 'Sisimai::Rhost.get() method' do
    v = nil
    it 'get(v) returns reason text' do
      pending 'Tests will be added after implementation of Sisimai::Data class'
      expect(Sisimai::Rhost.get(v)).not_to be nil
    end
  end
end
<commit_msg>Improved test code for Sisimai::Rhost.list<commit_after>require 'spec_helper'
require 'sisimai/rhost'

describe Sisimai::Rhost do
  cn = Sisimai::Rhost
  describe '.list' do
    context '()' do
      v = cn.list
      it 'returns Array' do
        expect(v.kind_of?(Array)).to be true
      end
      v.each do |e|
        describe e do
          it('is a String')       { expect(e.kind_of?(String)).to be true }
          it('is valid hostname') { expect(e).to match(/\A[-.a-z0-9]+\z/) }
        end
      end
    end

    describe 'Wrong Number of Arguments' do
      context '(nil)' do
        it('raises ArgumentError') { expect { cn.list(nil) }.to raise_error(ArgumentError) }
      end
      context '(nil,nil)' do
        it('raises ArgumentError') { expect { cn.list(nil, nil) }.to raise_error(ArgumentError) }
      end
    end
  end

  describe '.match' do
    describe 'Valid Argument String' do
      v = ['aspmx.l.google.com']
      v.each do |e|
        context "(#{e})" do
          it('returns true') { expect(cn.match(e)).to be true }
        end
      end
      context 'example.jp' do
        it('returns false') { expect(cn.match('example.jp')).to be false }
      end
    end

    describe 'Wrong Number of Arguments' do
      context '(nil,nil)' do
        it('raises ArgumentError') { expect { cn.match(nil, nil) }.to raise_error(ArgumentError) }
      end
    end
  end

  describe 'get' do
    v = nil
    context '(nil)' do
      it 'returns reason text' do
        pending 'Tests will be added after implementation of Sisimai::Data class'
        expect(cn.get(v)).not_to be nil
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.1266393442622951, 'fraction_numerical': 0.000819672131147541, 'mean_word_length': 2.5021520803443327, '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': '1176832', 'n_tokens_mistral': 847, 'n_tokens_neox': 839, 'n_words': 234}