Sha256: 4b382ac1f0ec1c72a1a92e0f7c74a6434fbe625e111443b746f139c3a085cf85

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

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), "output is missing #{s.inspect}:\n#{output}"
    end
  end

  def assert_does_not_report_used_selectors(output)
    USED_SELECTORS.each do |s|
      assert !output.include?(s), "output should not contain #{s.inspect}:\n#{output}"
    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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
deadweight-0.1.3 test/test_helper.rb
deadweight-0.1.2 test/test_helper.rb