<commit_before>require 'spec_helper'

describe Dims do
  describe '.define' do
    shared_context 'defines own conversion' do |with_abbrev = false|
      it 'defines own conversion' do
        expect(Dims::Inches).to have_method(:to_inches)
      end

      it 'returns itself' do
        n = 42.inches
        expect(n.to_inches).to be(n)
      end
    end

    context 'without define block' do
      before :example do
        clear_defined_inches
        Dims.define(:inches)
      end

      include_context 'defines own conversion'

      it "doesn't have other conversions" do
        expect(Dims::Inches).to_not have_method(:to_feet)
      end
    end

    context 'with define block' do
      before :example do
        clear_defined_inches
        clear_defined_feet

        Dims.define(:inches) { feet value / 12.0 }
        Dims.define(:feet)
      end

      include_context 'defines own conversion'

      it 'adds the `to_feet` conversion' do
        expect(Dims::Inches).to have_method(:to_feet)
      end

      it 'returns an instance of `Dims::Feet` with the correct value' do
        n = 24.inches

        expect(n.to_feet).to be_a(Dims::Feet)
        expect(n.to_feet).to eq(2.feet)
      end
    end
  end
end
<commit_msg>Rename Dims -> Measurb<commit_after>require 'spec_helper'

describe Measurb do
  describe '.define' do
    shared_context 'defines own conversion' do |with_abbrev = false|
      it 'defines own conversion' do
        expect(Measurb::Inches).to have_method(:to_inches)
      end

      it 'returns itself' do
        n = 42.inches
        expect(n.to_inches).to be(n)
      end
    end

    context 'without define block' do
      before :example do
        clear_defined_inches
        Measurb.define(:inches)
      end

      include_context 'defines own conversion'

      it "doesn't have other conversions" do
        expect(Measurb::Inches).to_not have_method(:to_feet)
      end
    end

    context 'with define block' do
      before :example do
        clear_defined_inches
        clear_defined_feet

        Measurb.define(:inches) { feet value / 12.0 }
        Measurb.define(:feet)
      end

      include_context 'defines own conversion'

      it 'adds the `to_feet` conversion' do
        expect(Measurb::Inches).to have_method(:to_feet)
      end

      it 'returns an instance of `Measurb::Feet` with the correct value' do
        n = 24.inches

        expect(n.to_feet).to be_a(Measurb::Feet)
        expect(n.to_feet).to eq(2.feet)
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.08386075949367089, 'fraction_numerical': 0.006329113924050633, 'mean_word_length': 2.3145478374836173, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '323599', 'n_tokens_mistral': 855, 'n_tokens_neox': 796, 'n_words': 218}