Sha256: 727af8179a2f8dc166c3f4ab9dfaa47077e2999e49d900ceb0422cbbedf778ee

Contents?: true

Size: 894 Bytes

Versions: 22

Compression:

Stored size: 894 Bytes

Contents

# frozen_string_literal: true

require "hanami/utils/string"

RSpec.shared_examples "a new migration" do
  let(:migration) { Hanami::Utils::String.new(input).underscore.to_s }

  it "generates migration" do
    project = "bookshelf_generate_migration_#{Random.rand(100_000_000)}"

    with_project(project) do
      run_cmd "hanami generate migration #{input}", migration

      #
      # db/migrations/<timestamp>_<migration>.rb
      #
      migrations = Pathname.new("db").join("migrations").children
      file       = migrations.find do |child|
        child.to_s.include?(migration)
      end

      expect(file).to_not be_nil, "Expected to find a migration matching: #{file}.\nFound: #{migrations.map(&:basename).join(' ')}"

      expect(file.to_s).to have_file_content <<~END
        Hanami::Model.migration do
          change do
          end
        end
      END
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
hanami-2.2.1 spec/support/shared_examples/cli/generate/migration.rb
hanami-2.2.0 spec/support/shared_examples/cli/generate/migration.rb
hanami-2.2.0.rc1 spec/support/shared_examples/cli/generate/migration.rb
hanami-2.2.0.beta2 spec/support/shared_examples/cli/generate/migration.rb
hanami-2.2.0.beta1 spec/support/shared_examples/cli/generate/migration.rb
hanami-2.1.0 spec/support/shared_examples/cli/generate/migration.rb
hanami-2.1.0.rc3 spec/support/shared_examples/cli/generate/migration.rb
hanami-2.1.0.rc2 spec/support/shared_examples/cli/generate/migration.rb
hanami-2.1.0.rc1 spec/support/shared_examples/cli/generate/migration.rb
hanami-2.1.0.beta2.1 spec/support/shared_examples/cli/generate/migration.rb
hanami-2.1.0.beta2 spec/support/shared_examples/cli/generate/migration.rb
hanami-2.1.0.beta1 spec/support/shared_examples/cli/generate/migration.rb
hanami-2.0.3 spec/support/shared_examples/cli/generate/migration.rb
hanami-2.0.2 spec/support/shared_examples/cli/generate/migration.rb
hanami-2.0.1 spec/support/shared_examples/cli/generate/migration.rb
hanami-2.0.0 spec/support/shared_examples/cli/generate/migration.rb
hanami-2.0.0.rc1 spec/support/shared_examples/cli/generate/migration.rb
hanami-2.0.0.beta4 spec/support/shared_examples/cli/generate/migration.rb
hanami-2.0.0.beta3 spec/support/shared_examples/cli/generate/migration.rb
hanami-2.0.0.beta2 spec/support/shared_examples/cli/generate/migration.rb