Sha256: b0450d8d014624f8454546be20f6a7e853084522c9d31ad947262a0a3b91973e

Contents?: true

Size: 929 Bytes

Versions: 25

Compression:

Stored size: 929 Bytes

Contents

require 'test_helper'
require 'minitest/mock'
require "generators/active_record/errdo_generator"

class ActiveRecordGeneratorTest < Rails::Generators::TestCase

  tests ActiveRecord::Generators::ErrdoGenerator
  destination File.expand_path("../../tmp", __FILE__)
  setup :prepare_destination

  should "make sure that migrations are produced" do
    run_generator %w(err)
    assert_migration "db/migrate/errdo_create_errs.rb", /def change/
  end

  should "throw error if table name already exists" do
    capture(:stderr) do
      assert_raises Exception do
        ActiveRecord::Base.connection.stub(:table_exists?, true) do
          run_generator %w(err)
        end
      end
      assert_no_migration "db/migrate/errdo_create_errs.rb"
    end
  end

  should "revoke correctly" do
    run_generator %w(err)
    run_generator %w(err), behavior: :revoke
    assert_no_migration "db/migrate/errdo_create_errs.rb"
  end

end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
errdo-0.12.14 test/generators/active_record_generator_test.rb
errdo-0.12.13 test/generators/active_record_generator_test.rb
errdo-0.12.12 test/generators/active_record_generator_test.rb
errdo-0.12.11 test/generators/active_record_generator_test.rb
errdo-0.12.10 test/generators/active_record_generator_test.rb
errdo-0.12.9 test/generators/active_record_generator_test.rb
errdo-0.12.8 test/generators/active_record_generator_test.rb
errdo-0.12.7 test/generators/active_record_generator_test.rb
errdo-0.12.6 test/generators/active_record_generator_test.rb
errdo-0.12.5 test/generators/active_record_generator_test.rb
errdo-0.12.4 test/generators/active_record_generator_test.rb
errdo-0.12.3 test/generators/active_record_generator_test.rb
errdo-0.12.2 test/generators/active_record_generator_test.rb
errdo-0.12.1 test/generators/active_record_generator_test.rb
errdo-0.12.0 test/generators/active_record_generator_test.rb
errdo-0.11.6 test/generators/active_record_generator_test.rb
errdo-0.11.5 test/generators/active_record_generator_test.rb
errdo-0.11.4 test/generators/active_record_generator_test.rb
errdo-0.11.3 test/generators/active_record_generator_test.rb
errdo-0.11.2 test/generators/active_record_generator_test.rb