Sha256: 39ecdba5be1887544247352d2bf3120f0784de11602cb220193631be12be7777

Contents?: true

Size: 1.8 KB

Versions: 1

Compression:

Stored size: 1.8 KB

Contents

require 'test_helper'

require "watchful/configuration"

class FirstTestConfiguration < Watchful::Configuration

	action :name => 'Placeholder Action'

end

puts "FirstTestConfiguration is a Configuration?".kind_of? Watchful::Configuration

class WatchfulTest < Test::Unit::TestCase
	
	context 'Configuration class' do
		
		context 'dependencies' do
			
			context 'have_command?' do
				
				should 'raise an exception for an empty string' do
					begin
						Watchful::Action.have_command?('')
						flunk
					rescue Exception
						assert true
					end
				end
				
				should 'raise an exception for a non-string argument' do
					begin
						Watchful::Action.have_command?(nil)
						flunk
					rescue Exception
						assert true
					end
				end
				
				should 'return false for missing commands' do
					assert_equal Watchful::Action.have_command?('Y0CbR4CEP2XY'), false
				end
				
				should 'return true for available commands' do
					assert_equal Watchful::Action.have_command?('cat'), true
				end
				
			end
			
			should 'confirm valid dependencies' do
				a = Watchful::Action.new(
					:name => 'Test Action',
					:dependencies => ['cat', 'echo'], :command => 'cat %s %s',
					:in => '.txt', :out => '.copy'
				)
				assert_equal a.has_dependencies?, true
			end
			
			should 'detect a missing binary dependency' do
				a = Watchful::Action.new(
					:name => 'Test Action',
					:dependencies => ['Y0CbR4CEP2XY'], :command => 'Y0CbR4CEP2XY %s %s',
					:in => '.txt', :out => '.copy'
				)
				assert_equal a.has_dependencies?, false
			end
			
			should 'confirm availability of no dependencies' do
				a = Watchful::Action.new(
					:name => 'Test Action',
					:dependencies => nil, :command => '',
					:in => '.txt', :out => '.copy'
				)
				assert_equal a.has_dependencies?, true
			end
			
		end
		
	end
	
end

Version data entries

1 entries across 1 versions & 1 rubygems

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