Permalink
Browse files

Add new-breakpoint() spec

  • Loading branch information...
1 parent cf6f5ea commit a84f91e1341bea77953b9cb15786027a4f57f0ec Reda Lemeden committed Mar 11, 2013
Showing with 47 additions and 0 deletions.
  1. +19 −0 spec/neat/new_breakpoint_spec.rb
  2. +15 −0 spec/support/matchers/have_value.rb
  3. +13 −0 test/new-breakpoint.scss
@@ -0,0 +1,19 @@
+require 'spec_helper'
+
+describe "new-breakpoint()" do
+ let (:identifier) {"new-breakpoint"}
+
+ before(:all) do
+ ParserSupport.parse_file(identifier)
+ end
+
+ context "with argument 'max-width 768px 12'" do
+ it "outputs (max-width 768px)" do
+ expect('.responsive-element').to be_contained_in('screen and (max-width: 768px)')
+ end
+
+ it "adds 'max-width 768px 12' to visual grid breakpoints" do
+ expect('$visual-grid-breakpoints').to have_value('max-width 768px 12')
+ end
+ end
+end
@@ -0,0 +1,15 @@
+RSpec::Matchers.define :have_value do |expected|
+ match do |actual|
+ selector_id = actual.sub('$','#')
+ value_attribute = ParserSupport.parser.find_by_selector(selector_id)[0]
+
+ unless value_attribute.nil?
+ actual_value = value_attribute.split(':')[1].strip.sub(';', '')
+ actual_value == expected
+ end
+ end
+
+ failure_message_for_should do |actual|
+ %{expected variable #{actual} to have value #{expected}}
+ end
+end
View
@@ -0,0 +1,13 @@
+@import 'setup';
+
+$tablet: new-breakpoint(max-width 768px 12);
+
+.responsive-element {
+ @include media($tablet) {
+ color: #000;
+ }
+}
+
+#visual-grid-breakpoints {
+ value: $visual-grid-breakpoints
+}

0 comments on commit a84f91e

Please sign in to comment.