Sha256: 93b9e2555b7f50ae1fbd4ea09b41a640f2a257d7889766c6f60da2b079247fec

Contents?: true

Size: 1.29 KB

Versions: 4

Compression:

Stored size: 1.29 KB

Contents

require 'generators/activity_notification/active_record/migration_generator'

describe ActivityNotification::Generators::MigrationGenerator, type: :generator do

  # setup_default_destination
  destination File.expand_path("../../../../tmp", __FILE__)
  before { prepare_destination }

  it 'runs generating migration tasks' do
    gen = generator
    expect(gen).to receive :create_migrations
    gen.invoke_all
  end

  describe 'the generated files' do
    context 'without name argument' do
      before do
        run_generator
      end

      describe 'CreateNotifications migration file' do
        subject { file(Dir["tmp/db/migrate/*_create_notifications.rb"].first.gsub!('tmp/', '')) }
        it { is_expected.to exist }
        it { is_expected.to contain(/class CreateNotifications < ActiveRecord::Migration/) }
      end
    end

    context 'with CreateCustomNotifications as name argument' do
      before do
        run_generator %w(CreateCustomNotifications)
      end

      describe 'CreateCustomNotifications migration file' do
        subject { file(Dir["tmp/db/migrate/*_create_custom_notifications.rb"].first.gsub!('tmp/', '')) }
        it { is_expected.to exist }
        it { is_expected.to contain(/class CreateCustomNotifications < ActiveRecord::Migration/) }
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
activity_notification-1.0.1 spec/generators/active_record/migration_generator_spec.rb
activity_notification-1.0.0 spec/generators/active_record/migration_generator_spec.rb
activity_notification-0.0.10 spec/generators/active_record/migration_generator_spec.rb
activity_notification-0.0.9 spec/generators/active_record/migration_generator_spec.rb