diff --git a/hyde/tests/ext/scss/expected-site.css b/hyde/tests/ext/scss/expected-site.css new file mode 100644 index 0000000..28c7b3c --- /dev/null +++ b/hyde/tests/ext/scss/expected-site.css @@ -0,0 +1,19 @@ +* { + border: 0; + padding: 0; + margin: 0; +} +#header { + color: #333333; + border-left: 1px; + border-right: 2px; +} +#footer { + color: #333333; +} +#content { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + border-radius: 10px; +} + diff --git a/hyde/tests/ext/scss/inc/mixin.scss b/hyde/tests/ext/scss/inc/mixin.scss new file mode 100644 index 0000000..fb0b975 --- /dev/null +++ b/hyde/tests/ext/scss/inc/mixin.scss @@ -0,0 +1,6 @@ +@mixin rounded ($radius: 5px){ + -webkit-border-radius: $radius; + -moz-border-radius: $radius; + border-radius: $radius; +} + diff --git a/hyde/tests/ext/scss/inc/reset.css b/hyde/tests/ext/scss/inc/reset.css new file mode 100644 index 0000000..5698c88 --- /dev/null +++ b/hyde/tests/ext/scss/inc/reset.css @@ -0,0 +1,6 @@ +* { + border: 0; + padding: 0; + margin: 0; +} + diff --git a/hyde/tests/ext/scss/inc/vars.scss b/hyde/tests/ext/scss/inc/vars.scss new file mode 100644 index 0000000..a039409 --- /dev/null +++ b/hyde/tests/ext/scss/inc/vars.scss @@ -0,0 +1,3 @@ +$the-border: 1px; +$base-color: #111; + diff --git a/hyde/tests/ext/scss/site.scss b/hyde/tests/ext/scss/site.scss new file mode 100644 index 0000000..c62c380 --- /dev/null +++ b/hyde/tests/ext/scss/site.scss @@ -0,0 +1,20 @@ +@option compress: no; + +@import "inc/mixin"; +@import "inc/vars"; +@import "inc/reset.css"; + +#header { + color: $base-color * 3; + border-left: $the-border; + border-right: $the-border * 2; +} + +#footer { + color: ($base-color + #111) * 1.5; +} + +#content { + @include rounded(10px); +} + diff --git a/hyde/tests/ext/test_scss.py b/hyde/tests/ext/test_scss.py new file mode 100644 index 0000000..5cdb06f --- /dev/null +++ b/hyde/tests/ext/test_scss.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +""" +Use nose +`$ pip install nose` +`$ nosetests` +""" +from hyde.fs import File, Folder +from hyde.model import Expando +from hyde.generator import Generator +from hyde.site import Site + +SCSS_SOURCE = File(__file__).parent.child_folder('scss') +TEST_SITE = File(__file__).parent.parent.child_folder('_test') + + +class TestSassyCSS(object): + + def setUp(self): + TEST_SITE.make() + TEST_SITE.parent.child_folder( + 'sites/test_jinja').copy_contents_to(TEST_SITE) + SCSS_SOURCE.copy_contents_to(TEST_SITE.child('content/media/css')) + File(TEST_SITE.child('content/media/css/site.css')).delete() + + + def tearDown(self): + TEST_SITE.delete() + + def test_scss(self): + s = Site(TEST_SITE) + s.config.plugins = ['hyde.ext.plugins.css.SassyCSSPlugin'] + source = TEST_SITE.child('content/media/css/site.scss') + target = File(Folder(s.config.deploy_root_path).child('media/css/site.css')) + gen = Generator(s) + gen.generate_resource_at_path(source) + + assert target.exists + text = target.read_all() + expected_text = File(SCSS_SOURCE.child('expected-site.css')).read_all() + + assert text == expected_text + return +