<commit_before>describe Neo4j::Migrations::Helpers do
  include described_class
  include Neo4j::Migrations::Helpers::Schema
  include Neo4j::Migrations::Helpers::IdProperty
  include Neo4j::Migrations::Helpers::Relationships

  before do
    clear_model_memory_caches
    delete_db
    delete_schema

    stub_active_node_class('Bookcase') do
      has_many :out, :books, type: :has_books
    end

    create_constraint(:Book, :name, type: :unique)
    create_index(:Book, :author_name, type: :exact)
    stub_active_node_class('Book') do
      property :name
      property :author_name
    end

    Book.create!(name: 'Book1')
    Book.create!(name: 'Book2')
    Book.create!(name: 'Book3')
  end

  describe '#remove_property' do
    it 'removes a property' do
      remove_property :Book, :name
      expect(Book.all(:n).pluck('n.title')).to eq([nil, nil, nil])
    end
  end

  describe '#rename_property' do
    it 'renames a property' do
      rename_property :Book, :name, :title
      expect(Book.all(:n).pluck('n.title')).to include('Book1', 'Book2', 'Book3')
    end

    it 'fails to remove when destination property is already defined' do
      expect { rename_property :Book, :author_name, :name }.to raise_error(
        'Property `name` is already defined in `Book`. To overwrite, call `remove_property(:Book, :name)` before this method.')
    end
  end

  describe '#drop_nodes' do
    it 'drops all nodes given a label' do
      drop_nodes :Book
      expect(Book.all.count).to eq(0)
    end
  end

  describe '#add_labels' do
    it 'adds labels to a node' do
      add_labels :Book, [:Item, :Readable]
      expect(Book.first.labels).to eq([:Book, :Item, :Readable])
    end
  end

  describe '#remove_labels' do
    it 'removes labels from a node' do
      add_label :Book, :Item
      expect(Book.first.labels).to eq([:Book, :Item])
      remove_label :Book, :Item
      expect(Book.first.labels).to eq([:Book])
    end
  end

  describe '#rename_label' do
    it 'renames a label' do
      execute 'CREATE (n:`Item` { name: "Lorem Ipsum" })'
      rename_label :Item, :Book
      expect(Book.find_by(name: 'Lorem Ipsum')).not_to be_nil<commit_msg>Fixing specs<commit_after>describe Neo4j::Migrations::Helpers do
  include described_class
  include Neo4j::Migrations::Helpers::Schema
  include Neo4j::Migrations::Helpers::IdProperty
  include Neo4j::Migrations::Helpers::Relationships

  before do
    clear_model_memory_caches
    delete_db
    delete_schema

    stub_active_node_class('Bookcase') do
      has_many :out, :books, type: :has_books
    end

    create_constraint(:Book, :name, type: :unique)
    create_index(:Book, :author_name, type: :exact)
    stub_active_node_class('Book') do
      property :name
      property :author_name
    end

    Book.create!(name: 'Book1')
    Book.create!(name: 'Book2')
    Book.create!(name: 'Book3')
  end

  describe '#remove_property' do
    it 'removes a property' do
      remove_property :Book, :name
      expect(Book.all(:n).pluck('n.title')).to eq([nil, nil, nil])
    end
  end

  describe '#rename_property' do
    it 'renames a property' do
      rename_property :Book, :name, :title
      expect(Book.all(:n).pluck('n.title')).to include('Book1', 'Book2', 'Book3')
    end

    it 'fails to remove when destination property is already defined' do
      expect { rename_property :Book, :author_name, :name }.to raise_error(
        'Property `name` is already defined in `Book`. To overwrite, call `remove_property(:Book, :name)` before this method.')
    end
  end

  describe '#drop_nodes' do
    it 'drops all nodes given a label' do
      drop_nodes :Book
      expect(Book.all.count).to eq(0)
    end
  end

  describe '#add_labels' do
    it 'adds labels to a node' do
      add_labels :Book, [:Item, :Readable]
      expect(Book.first.labels.sort).to eq([:Book, :Item, :Readable])
    end
  end

  describe '#remove_labels' do
    it 'removes labels from a node' do
      add_label :Book, :Item
      expect(Book.first.labels.sort).to eq([:Book, :Item])
      remove_label :Book, :Item
      expect(Book.first.labels).to eq([:Book])
    end
  end

  describe '#rename_label' do
    it 'renames a label' do
      execute 'CREATE (n:`Item` { name: "<NAME>" })'
      rename_label :Item, :Book
      expect(Book.find_by(name: '<NAME>')).not_to be_nil
{'fraction_non_alphanumeric': 0.1243953006219765, 'fraction_numerical': 0.00506795669200645, 'mean_word_length': 3.3947368421052633, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6629417', 'n_tokens_mistral': 1463, 'n_tokens_neox': 1443, 'n_words': 390}