Skip to content
Browse files

Add spec for media()

* Closes #58
  • Loading branch information...
1 parent e8ae3bc commit ffcf0346992ac3ab4263d7a9f68b641140cdb858 @kaishin kaishin committed Jan 29, 2013
View
6 spec/neat/columns_spec.rb
@@ -7,7 +7,7 @@
ParserSupport.parse_file(identifier)
end
- context "when passed '6' in a twelve-column grid" do
+ context "with argument '6' in a twelve-column grid" do
it "sets width in percentage" do
expect('.span-columns-default').to have_rule('width: 48.82117%')
end
@@ -39,7 +39,7 @@
end
end
- context "when passed 'table'" do
+ context "with argument 'table'" do
it "sets display to table-cell" do
expect('.span-columns-table').to have_rule('display: table-cell')
end
@@ -53,7 +53,7 @@
end
end
- context "when passed 'inline-block'" do
+ context "with argument 'inline-block'" do
it "sets display to inline-block" do
expect('.span-columns-inline-block').to have_rule('display: inline-block')
end
View
47 spec/neat/media_spec.rb
@@ -0,0 +1,47 @@
+require 'spec_helper'
+
+describe "@include media()" do
+ let (:identifier) {"media"}
+
+ before(:all) do
+ ParserSupport.parse_file(identifier)
+ end
+
+ context "with argument '481px'" do
+ it "outputs (min-width: 481px)" do
+ expect('.media-default').to be_contained_in('screen and (min-width: 481px)')
+ end
+ end
+
+ context "with argument 'max-width 480px'" do
+ it "outputs (max-width: 480px)" do
+ expect('.media-max-width').to be_contained_in('screen and (max-width: 480px)')
+ end
+ end
+
+ context "with argument 'min-width 320px max-width 480px'" do
+ it "outputs (min-width: 320px) and (max-width: 480px)" do
+ expect('.media-min-max-width').to be_contained_in('screen and (min-width: 320px) and (max-width: 480px)')
+ end
+ end
+
+ context "with argument '481px, 6'" do
+ it "outputs (min-width: 481px)" do
+ expect('.change-media-context').to be_contained_in('screen and (min-width: 481px)')
+ end
+
+ it "uses a 6-column grid" do
+ expect('.change-media-context').to have_rule('width: 100%')
+ end
+ end
+
+ context "with argument 'max-width 480px 6'" do
+ it "outputs (max-width: 480px)" do
+ expect('.change-media-context-shorthand').to be_contained_in('screen and (max-width: 480px)')
+ end
+
+ it "uses a 6-column grid" do
+ expect('.change-media-context').to have_rule('width: 100%')
+ end
+ end
+end
View
16 spec/neat/omega_spec.rb
@@ -7,49 +7,49 @@
ParserSupport.parse_file(identifier)
end
- context "when passed no argument" do
+ context "with no argument" do
it "removes right margin" do
expect('.omega-default').to have_rule('margin-right: 0')
end
end
- context "when passed 'table'" do
+ context "with argument 'table'" do
it "removes right padding" do
expect('.omega-table').to have_rule('padding-right: 0')
end
end
- context "when passed 'block, left'" do
+ context "with argument 'block, left'" do
it "removes left margin" do
expect('.omega-block-left').to have_rule('margin-left: 0')
end
end
- context "when passed 'table, left'" do
+ context "with argument 'table, left'" do
it "removes left padding" do
expect('.omega-table-left').to have_rule('padding-left: 0')
end
end
- context "when passed '4n'" do
+ context "with argument '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
- context "when passed '4n table'" do
+ context "with argument '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
- context "when passed '4n block, left'" do
+ context "with argument '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
- context "when passed '4n table, left'" do
+ context "with argument '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
8 spec/neat/pad_spec.rb
@@ -7,25 +7,25 @@
ParserSupport.parse_file(identifier)
end
- context "when passed no argument" do
+ context "with 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
+ context "with argument '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
+ context "with argument '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
+ context "with argument '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
View
6 spec/neat/row_spec.rb
@@ -7,7 +7,7 @@
ParserSupport.parse_file(identifier)
end
- context "when passed no argument" do
+ context "with no argument" do
it "adds clearfix" do
expect('.row-default:after').to have_rule('clear: both')
end
@@ -17,13 +17,13 @@
end
end
- context "when passed 'table'" do
+ context "with argument 'table'" do
it "sets display to table" do
expect('.row-table').to have_rule('display: table')
end
end
- context "when passed invalid display argument" do
+ context "with invalid display argument" do
it "sets display to block" do
expect('.row-invalid-display').to have_rule('display: block')
end
View
6 spec/neat/shift_spec.rb
@@ -7,19 +7,19 @@
ParserSupport.parse_file(identifier)
end
- context "when passed no argument" do
+ context "with 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
+ context "with argument '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
+ context "with argument '-3'" do
it "shifts element 3 column to the right" do
expect('.shift-negative').to have_rule('margin-left: -25.58941%')
end
View
10 spec/support/matchers/be_contained_in.rb
@@ -0,0 +1,10 @@
+RSpec::Matchers.define :be_contained_in do |expected|
+ match do |actual|
+ @query = ParserSupport.parser.find_by_selector(actual, expected)
+ @query.any?
+ end
+
+ failure_message_for_should do |actual|
+ %{expected selector #{actual} to be contained in #{expected}}
+ end
+end
View
31 test/media.scss
@@ -0,0 +1,31 @@
+@import 'setup';
+
+.media-default {
+ @include media(481px) {
+ color: #000;
+ }
+}
+
+.media-max-width {
+ @include media(max-width 480px) {
+ position: relative;
+ }
+}
+
+.media-min-max-width {
+ @include media(min-width 320px max-width 480px) {
+ position: relative;
+ }
+}
+
+.change-media-context {
+ @include media(481px, 6) {
+ @include span-columns(6);
+ }
+}
+
+.change-media-context-shorthand {
+ @include media(max-width 480px 6) {
+ @include span-columns(6);
+ }
+}

0 comments on commit ffcf034

Please sign in to comment.
Something went wrong with that request. Please try again.