require 'rubygems' require 'test/unit' require 'shoulda' $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(File.dirname(__FILE__)) require 'deadweight' class Test::Unit::TestCase UNUSED_SELECTORS = ['#foo .bar .baz'] USED_SELECTORS = ['#foo', '#foo .bar'] def self.should_correctly_report_selectors should "report unused selectors" do assert_reports_unused_selectors(@result) end should "not report used selectors" do assert_does_not_report_used_selectors(@result) end end def assert_correct_selectors_in_output(output) selectors = output.split("\n") assert_reports_unused_selectors(selectors) assert_does_not_report_used_selectors(selectors) end def assert_reports_unused_selectors(output) UNUSED_SELECTORS.each do |s| assert output.include?(s) end end def assert_does_not_report_used_selectors(output) USED_SELECTORS.each do |s| assert !output.include?(s) end end def default_settings(dw) dw.log_file = 'test.log' dw.root = File.dirname(__FILE__) + '/fixtures' dw.stylesheets << '/style.css' dw.pages << '/index.html' end end