<commit_before>require 'spec_helper'

RSpec.describe OxfordDictionary::Client do
  let(:app_id) { 'ID' }
  let(:app_key) { 'KEY' }
  let(:client) { described_class.new(app_id: app_id, app_key: app_key) }

  describe '#new' do
    it 'requires an argument' do
      expect { OxfordDictionary::Client.new(nil) }.
        to raise_error(ArgumentError, 'API id and key required.')
    end

    it 'requires a hash argument' do
      expect { OxfordDictionary::Client.new('string') }.
        to raise_error(ArgumentError, 'API id and key required.')
    end

    it 'requires both id and key' do
      expect { OxfordDictionary.new(app_id: 'ID') }.
        to raise_error(ArgumentError, 'API id and key required.')
    end
  end

  describe '#entry' do
    subject { client.entry(args) }

    context 'when the argument is a Hash' do
      let(:args) { { word: 'ace', dataset: 'en-us', params: {} } }

      it 'calls the Entries endpoint with correct arguments' do
        expect_any_instance_of(OxfordDictionary::Endpoints::Entries).
          to receive(:entry).
          with(word: args[:word], dataset: args[:dataset], params: args[:params])

        subject
      end
    end
  end

  describe '#lemma' do
    subject { client.lemma(word: word, language: language, params: params) }
    let(:word) { 'ace' }
    let(:language) { 'en' }
    let(:params) { {} }

    it 'calls the Lemmas endpoint with correct arguments' do
      expect_any_instance_of(OxfordDictionary::Endpoints::Lemmas).
        to receive(:lemma).
        with(word: word, language: language, params: params)

      subject
    end
  end

  describe '#translation' do
    subject do
      client.translation(
        word: word,
        source_language: source_language,
        target_language: target_language,
        params: params)
    end

    let(:word) { 'ace' }
    let(:source_language) { 'en' }
    let(:target_language) { 'es' }<commit_msg>Fix client spec RuboCop offenses<commit_after>require 'spec_helper'

RSpec.describe OxfordDictionary::Client do
  let(:app_id) { 'ID' }
  let(:app_key) { 'KEY' }
  let(:client) { described_class.new(app_id: app_id, app_key: app_key) }

  describe '#new' do
    it 'requires an argument' do
      expect { OxfordDictionary::Client.new(nil) }.
        to raise_error(ArgumentError, 'API id and key required.')
    end

    it 'requires a hash argument' do
      expect { OxfordDictionary::Client.new('string') }.
        to raise_error(ArgumentError, 'API id and key required.')
    end

    it 'requires both id and key' do
      expect { OxfordDictionary.new(app_id: 'ID') }.
        to raise_error(ArgumentError, 'API id and key required.')
    end
  end

  describe '#entry' do
    subject { client.entry(args) }

    context 'when the argument is a Hash' do
      let(:args) { { word: 'ace', dataset: 'en-us', params: {} } }

      it 'calls the Entries endpoint with correct arguments' do
        expect_any_instance_of(OxfordDictionary::Endpoints::Entries).
          to receive(:entry).
          with(word: args[:word],
               dataset: args[:dataset],
               params: args[:params])

        subject
      end
    end
  end

  describe '#lemma' do
    subject { client.lemma(word: word, language: language, params: params) }
    let(:word) { 'ace' }
    let(:language) { 'en' }
    let(:params) { {} }

    it 'calls the Lemmas endpoint with correct arguments' do
      expect_any_instance_of(OxfordDictionary::Endpoints::Lemmas).
        to receive(:lemma).
        with(word: word, language: language, params: params)

      subject
    end
  end

  describe '#translation' do
    subject do
      client.translation(
        word: word,
        source_language: source_language,
        target_language: target_language,
        params: params
      )
    end

    let(:word) { 'ace' }
    let(:source_language) { 'en' }
    let(:target_language) { 'es' }
{'fraction_non_alphanumeric': 0.11936475409836066, 'fraction_numerical': 0.0, 'mean_word_length': 2.8060428849902532, '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': '1027585', 'n_tokens_mistral': 1202, 'n_tokens_neox': 1162, 'n_words': 334}