Sha256: e9dfc9bdf0ea0f3dcfc43981ab6eb28c7c7753852a93701f3cc2a913b97a740c

Contents?: true

Size: 1.76 KB

Versions: 11

Compression:

Stored size: 1.76 KB

Contents

require File.join(File.dirname(__FILE__), "test_generator_helper.rb")

class TestTogifyGenerator < Test::Unit::TestCase
  include RubiGen::GeneratorTestHelper

  def setup
    setup_fake_tog_app
  end

  def teardown
    teardown_fake_tog_app
  end

  def test_generator_without_options
    run_generator('togify', [APP_ROOT], sources)

    assert_generated_file "Rakefile" do |body|
      assert_has_require body, 'tasks/tog'
    end
    
    assert_generated_file "config/environment.rb" do |body|
      assert_has_require body, 'desert'
    end
    
    @plugins.each{|plugin|
      assert_directory_exists("vendor/plugins/#{plugin}")
      assert_generated_file "config/routes.rb" do |body|
        assert_has_plugin_routes body, plugin
      end
    }
    generated_migration = Dir.glob("#{APP_ROOT}/db/migrate/*_integrate_tog.rb")[0]
    assert generated_migration, "should be a IntegrateTog migration in the togified app"
    File.open(generated_migration, "r") do |file|
      assert file.read=~/tog_core.*tog_user.*tog_social.*tog_mail.*tog_mail.*tog_social.*tog_user.*tog_core/m,"plugins migrations should be in correct order"
    end
  end
  
  
  def test_generator_with_dev_repositories
    run_generator('togify', [APP_ROOT], sources, {:development => true})
    @plugins.each{|plugin|
      assert_remote_origin_of_plugin(plugin, "git@github.com:tog/(.*).git")
    }
  end
  
  private
  def sources
    [RubiGen::PathSource.new(:test, File.join(File.dirname(__FILE__),"..", generator_path))]
  end

  def generator_path
    "app_generators"
  end

  def assert_remote_origin_of_plugin(plugin, match)
    FileUtils.chdir File.join(APP_ROOT, "vendor", "plugins", "#{plugin}") do
      remote_origin = %x{git config remote.origin.url}
      assert remote_origin.match(match)
    end
  end

end

Version data entries

11 entries across 11 versions & 4 rubygems

Version Path
IamPersistent-tog-0.4.4 test/test_togify_generator.rb
cauta-tog-0.5.3 test/test_togify_generator.rb
tog-tog-0.4.1 test/test_togify_generator.rb
tog-tog-0.4.2 test/test_togify_generator.rb
tog-tog-0.4.4 test/test_togify_generator.rb
tog-tog-0.5.0 test/test_togify_generator.rb
tog-tog-0.5.1 test/test_togify_generator.rb
tog-tog-0.5.2 test/test_togify_generator.rb
tog-tog-0.5.3 test/test_togify_generator.rb
tog-tog-0.5.4 test/test_togify_generator.rb
tog-0.5.4 test/test_togify_generator.rb