Module: Html::Test::Assertions

Instance Method Summary collapse

Instance Method Details

#assert_tidy(body = nil) ⇒ Object



4
5
6
# File 'lib/assertions.rb', line 4

def assert_tidy(body = nil)
	assert_validates(:tidy, body)
end

#assert_validates(types = nil, body = nil, url = nil, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/assertions.rb', line 16

def assert_validates(types = nil, body = nil, url = nil, options = {})
	verbose = ( options[:verbose] ) ? options[:verbose] : Html::Test::Validator.verbose
	body ||= @response.body
	types ||= [:tidy, :w3c, :xmllint]
	types = [types] if !types.is_a?(Array)
	types.each do |t|
		log("validating #{url} with #{t} ... ") if verbose
		error = Html::Test::Validator.send("#{t}_errors", body)
		if error.nil?
			log("OK\n") if verbose
		else
			log("FAILURE\n") if verbose
			assert_message = "Validator #{t} failed"
			assert_message << " for url #{url}" if url
			assert_message << " with message '#{error}'"

#	Why would I want to print this in the log file???
#						Rails.logger.error(assert_message + " for response body:\n #{with_line_counts(body)}")
			assert(error.nil?, assert_message)
		end
	end
end

#assert_w3c(body = nil) ⇒ Object



8
9
10
# File 'lib/assertions.rb', line 8

def assert_w3c(body = nil)
	assert_validates(:w3c, body)
end

#assert_xmllint(body = nil) ⇒ Object



12
13
14
# File 'lib/assertions.rb', line 12

def assert_xmllint(body = nil)
	assert_validates(:xmllint, body)
end