Permalink
Browse files

Add spec for shift() and pad()

* Use keyword 'context'
* Use explicit values when appropriate
* Write better example descriptions
  • Loading branch information...
1 parent 765b095 commit e8ae3bcdcbd42504d1b56fd9f9f69cfb458a47f2 Reda Lemeden committed Jan 29, 2013
Showing with 109 additions and 17 deletions.
  1. +6 −6 spec/neat/columns_spec.rb
  2. +8 −8 spec/neat/omega_spec.rb
  3. +34 −0 spec/neat/pad_spec.rb
  4. +4 −3 spec/neat/row_spec.rb
  5. +27 −0 spec/neat/shift_spec.rb
  6. +17 −0 test/pad.scss
  7. +13 −0 test/shift.scss
View
@@ -7,7 +7,7 @@
ParserSupport.parse_file(identifier)
end
- describe "when passed an int argument" do
+ context "when passed '6' in a twelve-column grid" do
it "sets width in percentage" do
expect('.span-columns-default').to have_rule('width: 48.82117%')
end
@@ -29,7 +29,7 @@
end
end
- describe "when nested" do
+ context "when nested" do
it "sets relative width in percentage" do
expect('.span-columns-default .span-columns-nested').to have_rule('width: 30.11389%')
end
@@ -39,21 +39,21 @@
end
end
- describe "when passed display argument (table)" do
+ context "when passed 'table'" do
it "sets display to table-cell" do
expect('.span-columns-table').to have_rule('display: table-cell')
end
- it "sets padding" do
+ it "sets padding in percentage" do
expect('.span-columns-table').to have_rule('padding-right: 2.35765%')
end
- it "adjusts width of last element" do
+ it "substracts gutter from width of last element" do
expect('.span-columns-table:last-child').to have_rule('width: 48.82117%')
end
end
- describe "when passed display argument (inline-block)" do
+ context "when passed 'inline-block'" do
it "sets display to inline-block" do
expect('.span-columns-inline-block').to have_rule('display: inline-block')
end
View
@@ -7,49 +7,49 @@
ParserSupport.parse_file(identifier)
end
- describe "when passed no arguments" do
+ context "when passed no argument" do
it "removes right margin" do
expect('.omega-default').to have_rule('margin-right: 0')
end
end
- describe "when passed display argument (table)" do
+ context "when passed 'table'" do
it "removes right padding" do
expect('.omega-table').to have_rule('padding-right: 0')
end
end
- describe "when passed argument (block, left)" do
+ context "when passed 'block, left'" do
it "removes left margin" do
expect('.omega-block-left').to have_rule('margin-left: 0')
end
end
- describe "when passed argument (table, left)" do
+ context "when passed 'table, left'" do
it "removes left padding" do
expect('.omega-table-left').to have_rule('padding-left: 0')
end
end
- describe "when pased argument (4n)" do
+ context "when passed '4n'" do
it "removes right margin of nth-child(4n)" do
expect('.omega-nth-default:nth-child(4n)').to have_rule('margin-right: 0')
end
end
- describe "whn passed argument (4n table)" do
+ context "when passed '4n table'" do
it "removes right padding of nth-child(4n)" do
expect('.omega-nth-table:nth-child(4n)').to have_rule('padding-right: 0')
end
end
- describe "when passed argument (4n block, left)" do
+ context "when passed '4n block, left'" do
it "removes left margin of nth-child(4n)" do
expect('.omega-nth-default-left:nth-child(4n)').to have_rule('margin-left: 0')
end
end
- describe "when passed argument (4n table, left)" do
+ context "when passed '4n table, left'" do
it "removes left padding of nth-child(4n)" do
expect('.omega-nth-table-left:nth-child(4n)').to have_rule('padding-left: 0')
end
View
@@ -0,0 +1,34 @@
+require 'spec_helper'
+
+describe "@include pad()" do
+ let (:identifier) {"pad"}
+
+ before(:all) do
+ ParserSupport.parse_file(identifier)
+ end
+
+ context "when passed no argument" do
+ it "sets padding to gutter percentage" do
+ expect('.pad-default').to have_rule('padding: 2.35765%')
+ end
+ end
+
+ context "when passed '20px'" do
+ it "sets padding to '20px'" do
+ expect('.pad-explicit').to have_rule('padding: 20px')
+ end
+ end
+
+ context "when passed '30px 20px 10px 5px'" do
+ it "sets padding to '30px 20px 10px 5px'" do
+ expect('.pad-shorthand').to have_rule('padding: 30px 20px 10px 5px')
+ end
+ end
+
+ context "when passed 'default' keyword" do
+ it "replaces 'default' with gutter percentage" do
+ expect('.pad-shorthand-default').to have_rule('padding: 30px 2.35765% 10px 2.35765%')
+ end
+ end
+end
+
View
@@ -7,22 +7,23 @@
ParserSupport.parse_file(identifier)
end
- describe "when passed no argument" do
+ context "when passed no argument" do
it "adds clearfix" do
expect('.row-default:after').to have_rule('clear: both')
end
+
it "sets display to block" do
expect('.row-default').to have_rule('display: block')
end
end
- describe "when passed table display argument" do
+ context "when passed 'table'" do
it "sets display to table" do
expect('.row-table').to have_rule('display: table')
end
end
- describe "when passed invalid display argument" do
+ context "when passed invalid display argument" do
it "sets display to block" do
expect('.row-invalid-display').to have_rule('display: block')
end
View
@@ -0,0 +1,27 @@
+require 'spec_helper'
+
+describe "@include shift()" do
+ let (:identifier) {"shift"}
+
+ before(:all) do
+ ParserSupport.parse_file(identifier)
+ end
+
+ context "when passed no argument" do
+ it "shifts element one column to the left" do
+ expect('.shift-default').to have_rule('margin-left: 8.5298%')
+ end
+ end
+
+ context "when passed '2'" do
+ it "shifts element 2 column to the left" do
+ expect('.shift-positive').to have_rule('margin-left: 17.05961%')
+ end
+ end
+
+ context "when passed '-3'" do
+ it "shifts element 3 column to the right" do
+ expect('.shift-negative').to have_rule('margin-left: -25.58941%')
+ end
+ end
+end
View
@@ -0,0 +1,17 @@
+@import 'setup';
+
+.pad-default {
+ @include pad;
+}
+
+.pad-explicit {
+ @include pad(20px);
+}
+
+.pad-shorthand {
+ @include pad(30px 20px 10px 5px);
+}
+
+.pad-shorthand-default {
+ @include pad(30px default 10px default);
+}
View
@@ -0,0 +1,13 @@
+@import 'setup';
+
+.shift-default {
+ @include shift;
+}
+
+.shift-positive {
+ @include shift(2);
+}
+
+.shift-negative {
+ @include shift(-3);
+}

0 comments on commit e8ae3bc

Please sign in to comment.