Sha256: 2da23572676aa254f1a392f553ad7d5291a3a05eca718a14e041de8d9e0b66d8

Contents?: true

Size: 1.22 KB

Versions: 7

Compression:

Stored size: 1.22 KB

Contents

require 'assert'
require 'ardb/runner/generate_command'

class Ardb::Runner::GenerateCommand

  class UnitTests < Assert::Context
    desc "Ardb::Runner::GenerateCommand"
    setup do
      @cmd = Ardb::Runner::GenerateCommand.new(['something'])
    end
    subject{ @cmd }

    should have_imeths :run, :migration_cmd

  end

  class MigrationTests < UnitTests
    desc "Ardb::Runner::GenerateCommand::MigrationCommand"
    setup do
      @cmd = Ardb::Runner::GenerateCommand::MigrationCommand.new('a_migration')
    end

    should have_readers :identifier, :class_name, :file_name, :template

    should "know its given identifier" do
      assert_equal 'a_migration', subject.identifier
    end

    should "know its class name" do
      assert_equal "AMigrations", subject.class_name
    end

    should "know its file name" do
      assert_match /.+_a_migration$/, subject.file_name
    end

    should "know its template" do
      assert_includes "require 'ardb/migration_helpers'", subject.template
      assert_includes "class #{subject.class_name} < ActiveRecord::Migration", subject.template
      assert_includes "include Ardb::MigrationHelpers", subject.template
      assert_includes "def change", subject.template
    end

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ardb-0.26.0 test/unit/runner/generate_command_tests.rb
ardb-0.25.0 test/unit/runner/generate_command_tests.rb
ardb-0.24.0 test/unit/runner/generate_command_tests.rb
ardb-0.23.0 test/unit/runner/generate_command_tests.rb
ardb-0.22.1 test/unit/runner/generate_command_tests.rb
ardb-0.22.0 test/unit/runner/generate_command_tests.rb
ardb-0.21.0 test/unit/runner/generate_command_tests.rb