Sha256: bd8bdad016ada62a82df225f1e1f3dc11465a2b32c4ad2fd5eef747a3e0010ed

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 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)
    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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
deadweight-0.1.1 test/test_helper.rb