Sha256: 3ef539b1c364c62f7b2087da28f43a09d882d19c58e9a07e9fd90b14edc43613

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 KB

Contents

require 'spec_helper_integration'
require 'generators/doorkeeper/migration_generator'

describe 'Doorkeeper::MigrationGenerator' do
  include GeneratorSpec::TestCase

  tests Doorkeeper::MigrationGenerator
  destination ::File.expand_path('../tmp/dummy', __FILE__)

  describe 'after running the generator' do
    before :each do
      prepare_destination
    end

    context 'pre Rails 5.0.0' do
      it 'creates a migration with no version specifier' do
        expect(Rails).to receive(:version).at_least(:once).and_return '4.2.0'
        stub_const("Rails::VERSION::MAJOR", 4)
        stub_const("Rails::VERSION::MINOR", 2)

        run_generator

        assert_migration 'db/migrate/create_doorkeeper_tables.rb' do |migration|
          assert migration.include?("ActiveRecord::Migration\n")
        end
      end
    end

    context 'post Rails 5.0.0' do
      it 'creates a migration with a version specifier' do
        expect(Rails).to receive(:version).at_least(:once).and_return '5.0.0'
        stub_const("Rails::VERSION::MAJOR", 5)
        stub_const("Rails::VERSION::MINOR", 0)

        run_generator

        assert_migration 'db/migrate/create_doorkeeper_tables.rb' do |migration|
          assert migration.include?("ActiveRecord::Migration[5.0]\n")
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
doorkeeper-mongodb-4.0.1 spec/generators/migration_generator_spec.rb
doorkeeper-mongodb-4.0.0 spec/generators/migration_generator_spec.rb