Sha256: a0e9b51b8bd2cb489db78844c5b5565271dcfe3b223ccdf4d31ca94ee6625421

Contents?: true

Size: 1.49 KB

Versions: 3

Compression:

Stored size: 1.49 KB

Contents

require 'test/unit'
require File.dirname(__FILE__) + '/../lib/staticmatic'

class StaticMaticBaseTest < Test::Unit::TestCase
  def setup
    @base_dir = File.dirname(__FILE__) + '/sandbox/test_site'
    @tmp_dir = File.dirname(__FILE__) + '/sandbox/tmp'
    
    @staticmatic = StaticMatic::Base.new(@base_dir)
  end
  
  def test_should_setup_directories
    staticmatic = StaticMatic::Base.new(@tmp_dir)
    staticmatic.run('setup')
    
    StaticMatic::Base.base_dirs.each do |dir|
      assert File.exists?("#{@tmp_dir}/#{dir}"), "Should create #{dir}"
    end
    
    StaticMatic::Base.base_dirs.reverse.each do |dir|
      Dir.entries("#{@tmp_dir}/#{dir}").each do |file|
        next if file.match(/^\./)
        File.delete("#{@tmp_dir}/#{dir}/#{file}")
      end
      Dir.delete("#{@tmp_dir}/#{dir}") if File.exists?("#{@tmp_dir}/#{dir}")
    end

  end
  
  def test_should_set_layout_template
    @staticmatic.layout = "application"
    assert_match "StaticMatic - Test Site Template", @staticmatic.layout
  end

  def test_should_generate_html_with_layout
    content = @staticmatic.generate_html_with_layout("index")
    assert_match "StaticMatic - Test Site Template", content
    assert_match "This is some test content", content
  end
  
  def test_should_generate_css
    content = @staticmatic.generate_css("application")
  end
  
  def test_should_find_source_filename_from_path
    assert_equal "application", @staticmatic.source_template_from_path("@base_dir/src/stylesheets/application.css")
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
staticmatic-0.2.0 test/base_test.rb
staticmatic-0.2.1 test/base_test.rb
staticmatic-0.3.0 test/base_test.rb