Sha256: a446a1e5d8ef28620b2508013ba7afbf447ba811837fcfd0c5b5d2673aedd790

Contents?: true

Size: 1.89 KB

Versions: 12

Compression:

Stored size: 1.89 KB

Contents

require "rails_helper"
require "generator_spec/test_case"
require File.expand_path("../../../lib/generators/paper_trail/install_generator", __FILE__)

describe PaperTrail::InstallGenerator, type: :generator do
  include GeneratorSpec::TestCase
  destination File.expand_path("../tmp", __FILE__)

  after(:all) { prepare_destination } # cleanup the tmp directory

  describe "no options" do
    before(:all) do
      prepare_destination
      run_generator
    end

    it "generates a migration for creating the 'versions' table" do
      expect(destination_root).to have_structure {
        directory "db" do
          directory "migrate" do
            migration "create_versions" do
              contains "class CreateVersions"
              contains "def change"
              contains "create_table :versions"
            end
          end
        end
      }
    end
  end

  describe "`--with-changes` option set to `true`" do
    before(:all) do
      prepare_destination
      run_generator %w(--with-changes)
    end

    it "generates a migration for creating the 'versions' table" do
      expect(destination_root).to have_structure {
        directory "db" do
          directory "migrate" do
            migration "create_versions" do
              contains "class CreateVersions"
              contains "def change"
              contains "create_table :versions"
            end
          end
        end
      }
    end

    it "generates a migration for adding the 'object_changes' column to the 'versions' table" do
      expect(destination_root).to have_structure {
        directory "db" do
          directory "migrate" do
            migration "add_object_changes_to_versions" do
              contains "class AddObjectChangesToVersions"
              contains "def change"
              contains "add_column :versions, :object_changes, :text"
            end
          end
        end
      }
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/paper_trail-5.2.3/spec/generators/install_generator_spec.rb
paper_trail-6.0.2 spec/generators/install_generator_spec.rb
paper_trail-6.0.1 spec/generators/install_generator_spec.rb
paper_trail-6.0.0 spec/generators/install_generator_spec.rb
paper_trail-5.2.3 spec/generators/install_generator_spec.rb
paper_trail-5.2.2 spec/generators/install_generator_spec.rb
paper_trail-5.2.1 spec/generators/install_generator_spec.rb
paper_trail-5.2.0 spec/generators/install_generator_spec.rb
paper_trail-5.1.1 spec/generators/install_generator_spec.rb
paper_trail-5.1.0 spec/generators/install_generator_spec.rb
paper_trail-5.0.1 spec/generators/install_generator_spec.rb
paper_trail-5.0.0 spec/generators/install_generator_spec.rb