Sha256: 55e9ea8cd0e1d5682cf2efac44d32aa6d584f96d7e17114f08f613aa354d217a

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

RSpec.describe "hanami db", type: :integration do
  describe "drop" do
    it "drops database" do
      project = "bookshelf_db_drop"

      with_project(project) do
        db = Pathname.new("db").join("#{project}_development.sqlite").to_s

        hanami "db create"
        expect(db).to be_an_existing_file

        hanami "db drop"
        expect(db).to_not be_an_existing_file
      end
    end

    it "doesn't drop in production" do
      project = "bookshelf_db_drop_production"

      with_project(project) do
        RSpec::Support::Env["HANAMI_ENV"] = "production"
        db = Pathname.new("db").join("#{project}.sqlite").to_s
        FileUtils.touch(db) # simulate existing database

        hanami "db drop"

        expect(exitstatus).to eq(1)
        expect(db).to be_an_existing_file
      end
    end

    it "prints help message" do
      with_project do
        output = <<~OUT
Command:
  hanami db drop

Usage:
  hanami db drop

Description:
  Drop the database (only for development/test)

Options:
  --help, -h                        # Print this help
OUT

        run_cmd 'hanami db drop --help', output
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hanami-2.0.0.beta2 spec/integration/cli/db/drop_spec.rb
hanami-2.0.0.beta1.1 spec/integration/cli/db/drop_spec.rb
hanami-2.0.0.beta1 spec/integration/cli/db/drop_spec.rb