Sha256: be02c3d3e35a59b9378b1d5b7cfd5ed3610dd876e6826e1b8c236bc3ba5c2317

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

require_relative '../test_helper'

class DummierTest < Test::Unit::TestCase

  def setup
    @root  = File.expand_path("../../../", __FILE__)
    @dummy = File.join(@root, "test/dummy")
  end
  
  def read_file(file)
    File.read(File.join(@dummy, file))
  end

  should "have classes defined" do
    assert defined?(Dummier)
    assert defined?(Dummier::AppGenerator)
  end

  should "create test/dummy" do
    
    # remove existing dummy
    FileUtils.rm_r(@dummy) if File.exists?(@dummy)
    assert !File.exists?(@dummy)
        
    # run generator
    Dummier::AppGenerator.new(@root).run!

    # make sure the dummy is created
    assert File.exists?(@dummy)
    
    # make sure things that should get deleted do
    files = %w(public/index.html public/images/rails.png Gemfile README doc test vendor)
    files.each do |file|
      assert !File.exists?(file)
    end
    
    # make sure application template is applied
    rb = read_file('config/application.rb')
    [ "require File.expand_path('../boot', __FILE__)", /require "dummier"/, /module Dummy/ ].each do |regex|
      assert_match regex, rb
    end
    
    # make sure boot template is applied
    rb = read_file('config/boot.rb')
    [ "gemfile = File.expand_path('../../../../Gemfile', __FILE__)", "ENV['BUNDLE_GEMFILE'] = gemfile", "$:.unshift File.expand_path('../../../../lib', __FILE__)" ].each do |regex|
      assert_match regex, rb
    end    
    
  end

  context "with some hooks" do
    # todo
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dummier-0.1.0.rc1 test/unit/dummier_test.rb