<commit_before>require 'spec_helper'

describe ::Object do
  before(:all) do
    class SomeFakeClass < OpenStruct
    end
  end

  subject do
    SomeFakeClass
  end

  describe ".try_chain" do
    it "wraps multiple calls to try and calls try on return value" do
      expect(subject.try_chain(:name, :underscore)).to eq "some_fake_class"
    end

    it "handles return if nil is in chain" do
      expect(subject.try_chain(:name, :somefakemethod)).to be_nil
    end
<commit_msg>spec for configuration options<commit_after>require 'spec_helper'

describe ::Object do
  before(:all) do
    class SomeFakeClass < OpenStruct
    end
  end

  subject do
    SomeFakeClass
  end

  describe ".define_configuration_options" do
    before(:all) do
      class Shape < OpenStruct
        class_attribute :some_measurement
        self.some_measurement = 20

        define_configuration_options!(:dimensions) do
          option :size, :default => 0
          option :weight, :default => 10
          option :calculated, :default => lambda{ self.size + self.weight }
          option :calculated_with_context, :default => lambda{|context| self.calculated + context.some_measurement }
        end

        define_configuration_options(:geometry) do
          option :sides
          option :subtype
          option :vertices, :default => 10
        end

        configure_geometry do |config|
          config.sides = 0
        end
      end

      class Square < Shape
        configure_geometry do |config|
          config.sides = 4
        end
      end

      class Triangle < Shape
      end
    end

    subject { Shape }

    it { expect(subject::DimensionsConfiguration.new).to be_a(Trax::Core::Configuration) }
    it { expect(subject.dimensions_configuration.size).to eq 0 }
    it { expect(subject.dimensions_configuration.weight).to eq 10 }
    it { expect(subject.dimensions_configuration.calculated).to eq 10 }
    it { expect(subject.dimensions_configuration.calculated_with_context).to eq 30 }
    it { expect(subject.geometry_configuration.sides).to eq 0 }

    context "inheritance" do
      context "subclass calls configure" do
        subject { Square }

        it { expect(subject.geometry_configuration.sides).to eq 4 }
        it { expect(subject.geometry_configuration.vertices).to eq 10 }
      end

      context "subclass does not call configure" do
        subject { Triangle }

        it { expect(subject.geometry_configuration.sides).to eq 0 }
      end
    end
  end

  describe ".try_chain" do
    it "wraps multiple calls to try and calls try on return value" do
      expect(subject.try_chain(:name, :underscore)).to eq "some_fake_class"
    end

    it "handles return if nil is in chain" do
      expect(subject.try_chain(:name, :somefakemethod)).to be_nil
    end

{'fraction_non_alphanumeric': 0.08002858163629868, 'fraction_numerical': 0.007502679528403001, 'mean_word_length': 2.7086092715231787, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '5088170', 'n_tokens_mistral': 836, 'n_tokens_neox': 784, 'n_words': 231}