<commit_before>require 'spec_helper'

describe BottledDecorators do
  it 'has a version number' do
    expect(BottledDecorators::VERSION).not_to be nil
  end
end

describe BottledDecorator do
  subject(:decorated){
    class ExampleDecoratedClass

      def example_method
        "This is an example"
      end

      def first_name
        "John"
      end

      def last_name
        "Hayes-Reed"
      end

    end
    ExampleDecoratedClass.new
  }
  subject(:decorator){
    class ExampleDecoratorClass
      include BottledDecorator

      def example_method
        super + " within an example"
      end

      def full_name
        "#{first_name} #{last_name}"
      end
    end
    ExampleDecoratorClass.(decorated)
  }
  subject(:stacking_decorator){
    class StackingDecoratorClass
      include BottledDecorator

      def example_method
        super + " within an example"
      end

      def full_name_reverse
        "#{last_name} #{first_name}"
      end
    end
    StackingDecoratorClass.(decorator)
  }
  describe '#new' do
    it 'responds to overridden messages' do
      expect(decorator.example_method).to eql("This is an example within an example")
    end

    it 'accesses the components original methods from decorator methods' do
      expect(decorator.full_name).to eql("<NAME>")
    end

    it 'is able to accept direct calls to the components methods' do
      expect(decorator.last_name).to eql("Hayes-Reed")
    end

    it 'is stackable for multiple decorator layers' do
      expect(stacking_decorator.example_method).to eql("This is an example within an example within an example")
    end

    it 'can access the components original methods from stacked decorator' do
      expect(stacking_decorator.full_name_reverse).to eql("<NAME>")
    end

    it 'can access child decorators methods' do
      expect(stacking_decorator.full_name).to eql("<NAME>")
    end

    it "is able to accept direct calls to the components methods from the stacked decorator" do
      expect(stacking_decorator.last_name).to eql("Hayes-Reed")
    end
  end
end<commit_msg>add tests for optional variables<commit_after>require 'spec_helper'

describe BottledDecorators do
  it 'has a version number' do
    expect(BottledDecorators::VERSION).not_to be nil
  end
end

describe BottledDecorator do
  subject(:decorated){
    class ExampleDecoratedClass

      def example_method
        "This is an example"
      end

      def first_name
        "John"
      end

      def last_name
        "Hayes-Reed"
      end

    end
    ExampleDecoratedClass.new
  }
  subject(:decorator){
    class ExampleDecoratorClass
      include BottledDecorator

      def example_method
        super + " within an example"
      end

      def full_name
        "#{first_name} #{last_name}"
      end

      def display_test_var
        @test_var
      end
    end
    ExampleDecoratorClass.(decorated, test_var: 'This is a test variable')
  }
  subject(:stacking_decorator){
    class StackingDecoratorClass
      include BottledDecorator

      def example_method
        super + " within an example"
      end

      def full_name_reverse
        "#{last_name} #{first_name}"
      end
    end
    StackingDecoratorClass.(decorator)
  }
  describe '#new' do
    it 'responds to overridden messages' do
      expect(decorator.example_method).to eql("This is an example within an example")
    end

    it 'accesses the components original methods from decorator methods' do
      expect(decorator.full_name).to eql("<NAME>")
    end

    it 'is able to accept direct calls to the components methods' do
      expect(decorator.last_name).to eql("Hayes-Reed")
    end

    it 'is stackable for multiple decorator layers' do
      expect(stacking_decorator.example_method).to eql("This is an example within an example within an example")
    end

    it 'can access the components original methods from stacked decorator' do
      expect(stacking_decorator.full_name_reverse).to eql("<NAME>")
    end

    it 'can access child decorators methods' do
      expect(stacking_decorator.full_name).to eql("<NAME>")
    end

    it "is able to accept direct calls to the components methods from the stacked decorator" do
      expect(stacking_decorator.last_name).to eql("Hayes-Reed")
    end

    it "can accept additional option variables" do
      expect(decorator.display_test_var).to eql("This is a test variable")
    end

    it "can access additional option variables from the stacked decorator" do
      expect(stacking_decorator.display_test_var).to eql("This is a test variable")
    end
  end
end
{'fraction_non_alphanumeric': 0.06795484151107252, 'fraction_numerical': 0.0, 'mean_word_length': 2.8910472972972974, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '7297134', 'n_tokens_mistral': 1385, 'n_tokens_neox': 1338, 'n_words': 421}