Sha256: b5b63dcc2bdcc3250010f785d9c67864fe191c93d1ac3514d6262e98fc74ec92

Contents?: true

Size: 1.5 KB

Versions: 3

Compression:

Stored size: 1.5 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_generate_html_with_layout
    content = @staticmatic.generate_html_with_layout("index")
    assert_match "StaticMatic", content
    assert_match "This is some test content", content
  end
  
  def test_should_generate_html_with_layout_assigned_in_template
    content = @staticmatic.generate_html_with_layout("layout_test")
    assert_match "Alternate Layout", 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.7.1 test/base_test.rb
staticmatic-0.7.0 test/base_test.rb
staticmatic-0.8.1 test/base_test.rb