From 589a9cd019b02edbf125e19a00d528b78b4f0b7b Mon Sep 17 00:00:00 2001 From: Kyle Neath Date: Fri, 20 Sep 2013 13:34:01 -0700 Subject: [PATCH] Ensure tricky comments don't cause exceptions We had this comment in our codebase and it was causing the whole parse to fail --- lib/kss/section.rb | 2 +- test/fixtures/css/buttons.css | 9 +++++++++ test/parser_test.rb | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/kss/section.rb b/lib/kss/section.rb index e6b7da1..25496d7 100644 --- a/lib/kss/section.rb +++ b/lib/kss/section.rb @@ -35,7 +35,7 @@ def section return @section unless @section.nil? cleaned = section_comment.strip.sub(/\.$/, '') # Kill trailing period - @section = cleaned.match(/Styleguide (.+)/)[1] + @section = cleaned.match(/Styleguide (.+)/i)[1] @section end diff --git a/test/fixtures/css/buttons.css b/test/fixtures/css/buttons.css index 47e7ade..a76436f 100644 --- a/test/fixtures/css/buttons.css +++ b/test/fixtures/css/buttons.css @@ -58,3 +58,12 @@ Styleguide Buttons - Truly Lime a.button.lime { color: lime; } + +/* +A button truly lime in color + +Seen in styleguide 10.2 +*/ +a.button.tricksy { + background: sparkles; +} diff --git a/test/parser_test.rb b/test/parser_test.rb index a2c572d..5bee1b7 100644 --- a/test/parser_test.rb +++ b/test/parser_test.rb @@ -76,7 +76,7 @@ def setup end test "public sections returns hash of sections" do - assert_equal 4, @css_parsed.sections.count + assert_equal 5, @css_parsed.sections.count end test "parse multiple paths" do