Sha256: ede6280d7fd34f7773c4baf2df6996c13963778f00fce6f9431c0f3dfb3a4ebc

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

require 'test_helper'
require 'fileutils'

class WatchfulTest < Test::Unit::TestCase
	
	def setup
		['/tmp/first', '/tmp/second'].each do |f|
			FileUtils.touch(f)
		end
	end
	
	context 'younger_than' do
		
		should 'correctly compare mtimes' do
			
			sleep 1
			FileUtils.touch('/tmp/first')
			assert Watchful.younger_than('/tmp/first', '/tmp/second')
			
			sleep 1
			FileUtils.touch('/tmp/second')
			assert Watchful.younger_than('/tmp/second', '/tmp/first')
			
		end
		
		should 'raise exception when comparing nonexistant files' do
			begin
				Watchful.younger_than('/tmp/does/not/exist', @files[1])
				flunk
			rescue Exception
				assert true
			end
			begin
				Watchful.younger_than(@files[0], '/tmp/does/not/exist')
				flunk
			rescue Exception
				assert true
			end
		end
		
	end
	
	context 'compound_extension_of' do
		
		should "detect simple extensions" do
			assert_equal Watchful.compound_extension_of('a_long_file_name.css'), '.css'
		end
		
		should "detect compound extensions" do
			assert_equal Watchful.compound_extension_of('test.min.css'), '.min.css'
		end
		
		should "return nil for files without extensions" do
			assert_nil Watchful.compound_extension_of('test_file')
		end
		
		should 'return nil for files without basenames' do
			assert_nil Watchful.compound_extension_of('.extension')
		end
		
	end
	
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
watchful-0.0.0.pre1 test/paths_test.rb