Sha256: bf63d031630163dad3e7628eed54d7e9fc6d3da8822e23cee83e91843593acdd

Contents?: true

Size: 1.15 KB

Versions: 25

Compression:

Stored size: 1.15 KB

Contents

require 'pliny/commands/creator'
require 'spec_helper'

describe Pliny::Commands::Creator do
  before do
    @gen = Pliny::Commands::Creator.new(["foobar"], {}, StringIO.new)
  end

  describe "#run!" do
    before do
      FileUtils.rm_rf("/tmp/plinytest")
      FileUtils.mkdir_p("/tmp/plinytest")
      Dir.chdir("/tmp/plinytest")
    end

    it "copies the template app over" do
      @gen.run!
      assert File.exists?("./foobar")
      assert File.exists?("./foobar/Gemfile")
    end

    it "deletes the .git from it" do
      @gen.run!
      refute File.exists?("./foobar/.git")
    end

    it "changes DATABASE_URL in .env.sample to use the app name" do
      @gen.run!
      db_url = File.read("./foobar/.env.sample").split("\n").detect do |line|
        line.include?("DATABASE_URL=")
      end
      assert_equal "DATABASE_URL=postgres:///foobar-development", db_url
    end

    it "changes DATABASE_URL in .env.test to use the app name" do
      @gen.run!
      db_url = File.read("./foobar/.env.test").split("\n").detect do |line|
        line.include?("DATABASE_URL=")
      end
      assert_equal "DATABASE_URL=postgres:///foobar-test", db_url
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
pliny-0.6.3 spec/commands/creator_spec.rb
pliny-0.6.2 spec/commands/creator_spec.rb
pliny-0.6.1 spec/commands/creator_spec.rb
pliny-0.6.0 spec/commands/creator_spec.rb
pliny-0.5.0 spec/commands/creator_spec.rb