test/deadweight_test.rb in deadweight-0.1.0 vs test/deadweight_test.rb in deadweight-0.1.1

- old
+ new

@@ -1,27 +1,35 @@ 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' - + default_settings(@dw) @result = @dw.run end - should "report unused selectors" do - assert @result.include?('#foo .bar .baz') - end + context "when initialized with a block" do + setup do + @dwb = Deadweight.new do |dw| + default_settings(dw) + end - should "not report used selectors" do - assert !@result.include?('#foo') - assert !@result.include?('#foo .bar') + @result = @dwb.run + end + + should "have the same attributes" do + assert_equal(@dw.log_file, @dwb.log_file) + assert_equal(@dw.root, @dwb.root) + assert_equal(@dw.stylesheets, @dwb.stylesheets) + assert_equal(@dw.pages, @dwb.pages) + end + + should_correctly_report_selectors end + should_correctly_report_selectors + 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) @@ -54,7 +62,11 @@ assert @dw.run.include?(".something") end should 'provide the results of its last run with #unused_selectors' do assert_equal @result, @dw.unused_selectors + end + + should 'provide the parsed CSS rules with #parsed_rules' do + assert_equal 'color: green;', @dw.parsed_rules['#foo'] end end