Sha256: 478ba13576519163157f0b94e440329ca10c24343c558b25f1dd219c0acb1999

Contents?: true

Size: 1.02 KB

Versions: 10

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

require 'generators/active_record/devise_multi_factor_generator'

describe ActiveRecord::Generators::DeviseMultiFactorGenerator, type: :generator do
  destination File.expand_path('../../../../../tmp', __FILE__)

  before do
    prepare_destination
  end

  it 'runs all methods in the generator' do
    gen = generator %w(users)
    expect(gen).to receive(:copy_devise_multi_factor_migration)
    gen.invoke_all
  end

  describe 'the generated files' do
    before do
      run_generator %w(users)
    end

    describe 'the migration' do
      subject { migration_file('db/migrate/devise_multi_factor_add_to_users.rb') }

      it { is_expected.to exist }
      it { is_expected.to be_a_migration }
      it { is_expected.to contain /def change/ }
      it { is_expected.to contain /def change_table :user, bulk: true do |t|/ }
      it { is_expected.to contain /t.integer :second_factor_attempts_count, default: 0, null: false/ }
      it { is_expected.to contain /t.string :encrypted_otp_secret_key/ }
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
devise-multi-factor-3.2.5 spec/generators/active_record/devise_multi_factor_generator_spec.rb
devise-multi-factor-3.2.4 spec/generators/active_record/devise_multi_factor_generator_spec.rb
devise-multi-factor-3.2.3 spec/generators/active_record/devise_multi_factor_generator_spec.rb
devise-multi-factor-3.2.2 spec/generators/active_record/devise_multi_factor_generator_spec.rb
devise-multi-factor-3.2.1 spec/generators/active_record/devise_multi_factor_generator_spec.rb
devise-multi-factor-3.2.0 spec/generators/active_record/devise_multi_factor_generator_spec.rb
devise-multi-factor-3.1.8 spec/generators/active_record/devise_multi_factor_generator_spec.rb
devise-multi-factor-3.1.7 spec/generators/active_record/devise_multi_factor_generator_spec.rb
devise-multi-factor-3.1.6 spec/generators/active_record/devise_multi_factor_generator_spec.rb
devise-multi-factor-3.1.5 spec/generators/active_record/devise_multi_factor_generator_spec.rb