<commit_before>require 'test_helper'

require 'groupy'

class GroupyTest < ActiveSupport::TestCase
  
  class Food

    def initialize(dish)
      @dish = dish
    end
    attr_reader :dish

    include Groupy
    groupy :dish do
      group :healthy do
        group :fruit do
          value :apple
          value :orange
        end
        value :rice
      end

      group :unhealthy do
        value :fried_egg
        value :bacon
      end
    end
  end
  
  test "groupies" do
    groupy = Food.groupies[:dish]
    assert_instance_of Groupy::OuterGroup, groupy
  end

  test "subgroups" do
    assert_equal [:healthy, :fruit, :apple, :orange, :rice, :unhealthy, :fried_egg, :bacon].sort_by(&:to_s), Food.groupies[:dish].subgroups.keys.sort_by(&:to_s)
    assert_equal ["apple", "orange", "rice"], Food.groupies[:dish].subgroups[:healthy]
    assert_equal ["apple", "orange"],         Food.groupies[:dish].subgroups[:fruit]
    assert_equal ["apple"],                   Food.groupies[:dish].subgroups[:apple]
  end

  test "? methods" do
    orange = Food.new("orange")
    assert orange.healthy?
    assert !orange.rice?
    assert orange.fruit?
    assert orange.orange?
  end
  
  # TODO: setup an AR test

end<commit_msg>we can do two groupies<commit_after>require 'test_helper'

require 'groupy'

class GroupyTest < ActiveSupport::TestCase
  
  class Food

    def initialize(dish)
      @dish = dish
      @spiciness = "small"
    end
    attr_reader :dish
    attr_reader :spiciness

    include Groupy
    groupy :dish do
      group :healthy do
        group :fruit do
          value :apple
          value :orange
        end
        value :rice
      end

      group :unhealthy do
        value :fried_egg
        value :bacon
      end
    end

    # we can have multiple groupies
    groupy :spiciness do
      group :wussy do
        value :small
      end
      value :extreme
    end
  end
  
  test "groupies" do
    groupy = Food.groupies[:dish]
    assert_instance_of Groupy::OuterGroup, groupy
  end

  test "subgroups" do
    assert_equal [:healthy, :fruit, :apple, :orange, :rice, :unhealthy, :fried_egg, :bacon].sort_by(&:to_s), Food.groupies[:dish].subgroups.keys.sort_by(&:to_s)
    assert_equal ["apple", "orange", "rice"], Food.groupies[:dish].subgroups[:healthy]
    assert_equal ["apple", "orange"],         Food.groupies[:dish].subgroups[:fruit]
    assert_equal ["apple"],                   Food.groupies[:dish].subgroups[:apple]
  end

  test "? methods" do
    orange = Food.new("orange")
    assert orange.healthy?
    assert !orange.rice?
    assert orange.fruit?
    assert orange.orange?
  
    # and the second groupy
    assert orange.wussy?
    assert orange.small?
    assert !orange.extreme?
  end
  
  # TODO: setup an AR test

end
{'fraction_non_alphanumeric': 0.10552763819095477, 'fraction_numerical': 0.0, 'mean_word_length': 2.518939393939394, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2839442', 'n_tokens_mistral': 943, 'n_tokens_neox': 890, 'n_words': 234}