<commit_before># -*- coding: utf-8 -*-
require 'rspec'
require File.expand_path('../lib/era_ja/error', File.dirname(__FILE__))

RSpec.shared_examples "should equal 'R01.07.02'" do
  it { expect(subject.to_era).to eq "R01.07.02" }

  context "with '%o%E.%m.%d'" do
    it { expect(subject.to_era("%o%E.%m.%d")).to eq "R01.07.02" }
  end

  context "with '%o%-E.%-m.%-d'" do
    it { expect(subject.to_era("%o%-E.%-m.%-d")).to eq "R1.7.2" }
  end
end

RSpec.shared_examples "should equal '令和01年07月02日'" do
  context "with '%O%E年%m月%d日'" do
    it { expect(subject.to_era("%O%E年%m月%d日")).to eq "令和01年07月02日" }
  end
end

RSpec.shared_examples "should equal 'R01.05.01'" do
  it { expect(subject.to_era).to eq "R01.05.01" }

  context "with '%o%E.%m.%d'" do
    it { expect(subject.to_era("%o%E.%m.%d")).to eq "R01.05.01" }
  end
end

RSpec.shared_examples "should equal 'r01.05.01'" do
  context "with era_names option" do
    context "when era_names is correct" do
      let(:era_names) { { reiwa: ["r", "令和"] } }
      it { expect(subject.to_era(era_names: era_names)).to eq "r01.05.01" }
    end

    context "when era_names have no reiwa values" do
      let(:era_names) { { heisei: ["h", "平成"] } }
      it { expect { subject.to_era(era_names: era_names) }.to raise_error(KeyError) }
    end<commit_msg>:white_check_mark: Add spec for %O%J%-E<commit_after># -*- coding: utf-8 -*-
require 'rspec'
require File.expand_path('../lib/era_ja/error', File.dirname(__FILE__))

RSpec.shared_examples "should equal 'R01.07.02'" do
  it { expect(subject.to_era).to eq "R01.07.02" }

  context "with '%o%E.%m.%d'" do
    it { expect(subject.to_era("%o%E.%m.%d")).to eq "R01.07.02" }
  end

  context "with '%o%-E.%-m.%-d'" do
    it { expect(subject.to_era("%o%-E.%-m.%-d")).to eq "R1.7.2" }
  end
end

RSpec.shared_examples "should equal '令和01年07月02日'" do
  context "with '%O%E年%m月%d日'" do
    it { expect(subject.to_era("%O%E年%m月%d日")).to eq "令和01年07月02日" }
  end

  context "with '%O%-E年%m月%d日'" do
    it { expect(subject.to_era("%O%-E年%m月%d日")).to eq "令和1年07月02日" }
  end

  context "with '%O%J%-E年%m月%d日'" do
    it { expect(subject.to_era("%O%J%-E年%m月%d日")).to eq "令和元年07月02日" }
  end
end

RSpec.shared_examples "should equal 'R01.05.01'" do
  it { expect(subject.to_era).to eq "R01.05.01" }

  context "with '%o%E.%m.%d'" do
    it { expect(subject.to_era("%o%E.%m.%d")).to eq "R01.05.01" }
  end
end

RSpec.shared_examples "should equal 'r01.05.01'" do
  context "with era_names option" do
    context "when era_names is correct" do
      let(:era_names) { { reiwa: ["r", "令和"] } }
      it { expect(subject.to_era(era_names: era_names)).to eq "r01.05.01" }
    end

    context "when era_names have no reiwa values" do
      let(:era_names) { { heisei: ["h", "平成"] } }
      it { expect { subject.to_era(era_names: era_names) }.to raise_error(KeyError) }
    end
{'fraction_non_alphanumeric': 0.1984626135569532, 'fraction_numerical': 0.04786862334032145, 'mean_word_length': 3.4456521739130435, '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': '615489', 'n_tokens_mistral': 1340, 'n_tokens_neox': 1232, 'n_words': 251}