Sha256: 15e950349e76984790f989197d0c1448b6dcf6932a854a0e5e39dcc305f75a68

Contents?: true

Size: 1.6 KB

Versions: 16

Compression:

Stored size: 1.6 KB

Contents

#!/usr/bin/env ruby

require 'test/unit'
currentPath = File.dirname(__FILE__)
require File.join( currentPath, '../lib/masterview' )
require 'masterview/extras/watcher.rb'

class TestTemplateFileWatcher < Test::Unit::TestCase
  CurrentPath = File.dirname(__FILE__)
  MVTemplateDir = File.join(CurrentPath, '../examples')
  MVFilenamePattern = '*.html'
  TmpOutputDir = File.join(CurrentPath, '../tmp/views')

  MVProductFile = File.join(CurrentPath, '../examples/product.html')

  def setup
    FileUtils.remove_dir(TmpOutputDir, true)
  end

  def test_a_run
    files_run = MasterView::TemplateFileWatcher.check(MVTemplateDir, MVFilenamePattern, true) do |f|
      MasterView::Parser.parse_file( f, TmpOutputDir )
    end
    assert_equal [MVProductFile], files_run
    assert File.exist?(TmpOutputDir+'/layouts/product.rhtml')
    assert File.exist?(TmpOutputDir+'/product/_form.rhtml')
    assert File.exist?(TmpOutputDir+'/product/edit.rhtml')
    assert File.exist?(TmpOutputDir+'/product/list.rhtml')
    assert File.exist?(TmpOutputDir+'/product/new.rhtml')
    assert File.exist?(TmpOutputDir+'/product/show.rhtml')
  end

  def test_b_no_change
    files_run = MasterView::TemplateFileWatcher.check(MVTemplateDir, MVFilenamePattern, true) do |f|
      MasterView::Parser.parse_file( f, TmpOutputDir )
    end
    assert_equal [], files_run
  end

  def test_c_file_changed_run
    FileUtils.touch MVProductFile
    files_run = MasterView::TemplateFileWatcher.check(MVTemplateDir, MVFilenamePattern, true) do |f|
      MasterView::Parser.parse_file( f, TmpOutputDir )
    end
    assert_equal [MVProductFile], files_run
  end

end


Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
masterview-0.0.16 test/template_file_watcher_test.rb
masterview-0.0.11 test/template_file_watcher_test.rb
masterview-0.0.12 test/template_file_watcher_test.rb
masterview-0.0.13 test/template_file_watcher_test.rb
masterview-0.0.14 test/template_file_watcher_test.rb
masterview-0.0.15 test/template_file_watcher_test.rb
masterview-0.0.17 test/template_file_watcher_test.rb
masterview-0.0.2 test/template_file_watcher_test.rb
masterview-0.0.10 test/template_file_watcher_test.rb
masterview-0.0.9 test/template_file_watcher_test.rb
masterview-0.0.7 test/template_file_watcher_test.rb
masterview-0.0.8 test/template_file_watcher_test.rb
masterview_parser-0.0.6 test/template_file_watcher_test.rb
masterview_parser-0.0.5 test/template_file_watcher_test.rb
masterview_parser-0.0.3 test/template_file_watcher_test.rb
masterview_parser-0.0.4 test/template_file_watcher_test.rb