<commit_before>require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))

describe Snowflake::Node do
  describe "callbacks" do
    class TestNodeWithCallbacks
      include Snowflake::Node

      attribute :name,         String, :key => true
      attribute :age,          Integer
      attribute :mood,         String
      attribute :description,  String

      validates_presence_of :name
      
      attr_accessor :callbacks
      
      def initialize(attributes = {})
        @callbacks = []
        super(attributes)
      end
      
      before_save "@callbacks << :before_save"
      after_save "@callbacks << :after_save"
      
      before_create "@callbacks << :before_create"
      after_create "@callbacks << :after_create"
      
      before_update "@callbacks << :before_update"
      after_update "@callbacks << :after_update"

      before_destroy "@callbacks << :before_destroy"
      after_destroy "@callbacks << :after_destroy"
      
      before_rename "@callbacks << :before_rename"
      after_rename "@callbacks << :after_rename"
      
      before_validation "@callbacks << :before_validation"
      after_validation "@callbacks << :after_validation"
      
      after_initialize "@callbacks << :after_initialize"
      after_get "@callbacks << :after_get"
    end
    
    before(:all) do
      @test_callback_node = TestNodeWithCallbacks.create(:name => 'rolly', :mood => 'Awesome')<commit_msg>hack, hack, hack<commit_after>require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))

describe Snowflake::Node do
  describe "callbacks" do
    class TestNodeWithCallbacks
      include Snowflake::Node

      attribute :name,         String, :key => true
      attribute :age,          Integer
      attribute :mood,         String
      attribute :description,  String

      validates_presence_of :name
      
      attr_accessor :callbacks
      
      def initialize(attributes = {})
        @callbacks = []
        super(attributes)
      end
      
      before_save "@callbacks << :before_save"
      after_save "@callbacks << :after_save"
      
      before_create "@callbacks << :before_create"
      after_create :do_stuff_after_create
      
      before_update "@callbacks << :before_update"
      after_update "@callbacks << :after_update"

      before_destroy "@callbacks << :before_destroy"
      after_destroy "@callbacks << :after_destroy"
      
      before_rename "@callbacks << :before_rename"
      after_rename "@callbacks << :after_rename"
      
      before_validation "@callbacks << :before_validation"
      after_validation "@callbacks << :after_validation"
      
      after_initialize "@callbacks << :after_initialize"
      after_get "@callbacks << :after_get"
      
      def do_stuff_after_create
        @callbacks << :after_create
      end
    end
    
    before(:all) do
      @test_callback_node = TestNodeWithCallbacks.create(:name => 'rolly', :mood => 'Awesome')
{'fraction_non_alphanumeric': 0.10344827586206896, 'fraction_numerical': 0.0, 'mean_word_length': 2.772727272727273, 'pattern_counts': {'":': 0, '<': 59, '<?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': '5197312', 'n_tokens_mistral': 850, 'n_tokens_neox': 847, 'n_words': 177}