Sha256: 88bc935230c060b93b2000f740171c113106c683f686f6f535e205505433b349

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

# encoding: utf-8
require "spec_helper_dev"

module Generators
  class Install
    describe CopyMigration, :sandbox do

      let(:filename) { "20140101010101_create_items_items" }
      let(:filepath) { "#{ sandbox }/#{ filename }.rb" }
      let(:content)  { "some content" }
      let(:params) do
        {
          gemname:     "uuids",
          source_root: sandbox,
          source_file: filepath,
          target_root: sandbox,
          target_dir:  "db/migrate"
        }
      end

      before  { File.write filepath, content }
      subject { CopyMigration.new params }

      describe "#source" do

        it "returns migrations source" do
          expect(subject.source).to eq("#{ filename }.rb")
        end
      end

      describe "#target" do

        let(:regexp) do
          Regexp.new "db/migrate/\\d{14}_create_items_items[.]uuids[.]rb"
        end

        it "returns the name of migration target" do
          expect(subject.target).to match(regexp)
        end
      end

      describe "#content" do

        it "returns the migration content" do
          expect(subject.content).to eq(content)
        end
      end

      describe "#created?" do

        let(:folder) { File.join sandbox, "db", "migrate" }
        let(:copy)   { File.join(folder, "#{ filename }.uuids.rb") }

        it "returns false before migration copy created" do
          expect(subject).not_to be_created
        end

        it "returns true after migration copy created" do
          FileUtils.mkdir_p folder
          File.write copy, content
          expect(subject).to be_created
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
uuids-1.4.1 spec/lib/generators/install/copy_migration_spec.rb