Sha256: 5f99e998afac2f82877ba22fd66d62436f3d551a86aef4dbc3da1186a34d9b32

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

require 'test_helper'

class DeadweightTest < Test::Unit::TestCase
  def setup
    @dw = Deadweight.new
    @dw.log_file = 'test.log'
    @dw.root = File.dirname(__FILE__) + '/fixtures'
    @dw.stylesheets << '/style.css'
    @dw.pages << '/index.html'

    @result = @dw.run
  end

  should "report unused selectors" do
    assert @result.include?('#foo .bar .baz')
  end

  should "not report used selectors" do
    assert !@result.include?('#foo')
    assert !@result.include?('#foo .bar')
  end

  should 'strip pseudo classes from selectors' do
    # #oof:hover (#oof does not exist)
    assert @result.include?('#oof:hover'), @result.inspect

    # #foo:hover (#foo does exist)
    assert !@result.include?('#foo:hover')

    # #rab:hover::selection (#rab does not exist)
    assert @result.include?('#rab:hover::selection')
  end

  should "accept Procs as targets" do
    @dw.mechanize = true

    @dw.pages << proc {
      fetch('/index.html')
      agent.page.links.first.click
    }

    assert @dw.run.empty?
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
aanand-deadweight-0.0.3 test/deadweight_test.rb
mojodna-deadweight-0.0.4 test/deadweight_test.rb