Sha256: cba98532356f9b006c02b0ab8a58f8582a691ea6e979624a4247549bc61ce6b3

Contents?: true

Size: 1.78 KB

Versions: 7

Compression:

Stored size: 1.78 KB

Contents

class Nanoc::Checking::Checks::CSSTest < Nanoc::TestCase
  def test_run_ok
    VCR.use_cassette('css_run_ok') do
      with_site do |site|
        # Create files
        FileUtils.mkdir_p('output')
        File.open('output/blah.html', 'w') { |io| io.write('<h1>Hi!</h1>') }
        File.open('output/style.css', 'w') { |io| io.write('h1 { color: red; }') }

        # Run check
        check = Nanoc::Checking::Checks::CSS.create(site)
        check.run

        # Check
        assert check.issues.empty?
      end
    end
  end

  def test_run_error
    VCR.use_cassette('css_run_error') do
      with_site do |site|
        # Create files
        FileUtils.mkdir_p('output')
        File.open('output/blah.html', 'w') { |io| io.write('<h1>Hi!</h1>') }
        File.open('output/style.css', 'w') { |io| io.write('h1 { coxlor: rxed; }') }

        # Run check
        check = Nanoc::Checking::Checks::CSS.create(site)
        check.run

        # Check
        refute check.issues.empty?
        assert_equal 1, check.issues.size
        assert_equal(
          'line 1: Property coxlor doesn\'t exist: h1 { coxlor: rxed; }',
          check.issues.to_a[0].description,
        )
      end
    end
  end

  def test_run_parse_error
    VCR.use_cassette('css_run_parse_error') do
      with_site do |site|
        # Create files
        FileUtils.mkdir_p('output')
        File.open('output/blah.html', 'w') { |io| io.write('<h1>Hi!</h1>') }
        File.open('output/style.css', 'w') { |io| io.write('h1 { ; {') }

        # Run check
        check = Nanoc::Checking::Checks::CSS.create(site)
        check.run

        # Check
        refute check.issues.empty?
        assert_equal 1, check.issues.size
        assert_equal 'line 1: Parse Error: h1 { ; {', check.issues.to_a[0].description
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
nanoc-4.4.5 test/checking/checks/test_css.rb
nanoc-4.4.4 test/checking/checks/test_css.rb
nanoc-4.4.3 test/checking/checks/test_css.rb
nanoc-4.4.2 test/checking/checks/test_css.rb
nanoc-4.4.1 test/checking/checks/test_css.rb
nanoc-4.4.0 test/checking/checks/test_css.rb
nanoc-4.3.8 test/checking/checks/test_css.rb