Sha256: bddefbc0f2c7e8bd544e040119e429f414334553e76955388d9756e31ad2153f

Contents?: true

Size: 1.94 KB

Versions: 6

Compression:

Stored size: 1.94 KB

Contents

require 'rails_helper'
require 'generators/csv_import_magic/install_generator'

RSpec.describe CsvImportMagic::Generators::InstallGenerator, type: :generator do
  destination File.expand_path('../../../../../tmp', __FILE__)

  before do
    travel_to Time.zone.parse('20170101235959')
    prepare_destination

    FileUtils.mkdir_p('tmp/config')

    out_file = File.new(File.join(ENGINE_RAILS_ROOT, 'tmp/config/routes.rb'), 'w+')
    out_file.puts("Rails.application.routes.draw do\nend")
    out_file.close

    run_generator
  end

  after do
    prepare_destination
    travel_back
  end

  specify 'check structure of routes' do
    expect(destination_root).to have_structure {
      directory 'config' do
        file 'routes.rb' do
          contains "mount CsvImportMagic::Engine => '/csv_import_magic'"
        end
      end
    }
  end

  specify 'check structure of migrateion' do
    migration_content = <<-EOF
class CreateImporters < ActiveRecord::Migration[5.1]
  def change
    create_table :importers do |t|
      t.attachment :attachment
      t.attachment :attachment_error
      t.string :source
      t.string :parser
      t.string :columns
      t.string :message
      t.string :status, default: 'pending'
      t.string :additional_data
      t.references :importable, polymorphic: true
      t.timestamps null: false
    end

    add_index :importers, [:importable_id, :importable_type]
  end
end
    EOF

    expect(destination_root).to have_structure {
      directory 'db' do
        directory 'migrate' do
          file '20170101235959_create_importers.rb'
          migration 'create_importers' do
            contains migration_content
          end
        end
      end
    }
  end

  specify 'check structure of locale' do
    expect(destination_root).to have_structure {
      directory 'config' do
        directory 'locales' do
          file 'csv_import_magic.en.yml' do
            contains 'en:'
          end
        end
      end
    }
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
csv_import_magic-0.0.11 spec/lib/generators/csv_import_magic/install_generator_spec.rb
csv_import_magic-0.0.10 spec/lib/generators/csv_import_magic/install_generator_spec.rb
csv_import_magic-0.0.8 spec/lib/generators/csv_import_magic/install_generator_spec.rb
csv_import_magic-0.0.7 spec/lib/generators/csv_import_magic/install_generator_spec.rb
csv_import_magic-0.0.6 spec/lib/generators/csv_import_magic/install_generator_spec.rb
csv_import_magic-0.0.5 spec/lib/generators/csv_import_magic/install_generator_spec.rb