Skip to content

Commit

Permalink
add unit test for environment option
Browse files Browse the repository at this point in the history
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
  • Loading branch information
appleboy committed Mar 27, 2014
1 parent fc8edf5 commit 44940de
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 3 deletions.
25 changes: 23 additions & 2 deletions test/compass_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,19 @@ describe('gulp-compass plugin', function() {
process += 1;
});

compass(path.join(__dirname, 'sass/base/compile2.scss'), {
project: __dirname,
config_file: path.join(__dirname, 'config.rb'),
environment: 'development'
}, function(code, stdout, stderr, new_path){
if (+code !== 0) {
throw new Error('compile scss error with config.rb file');
}
new_path = gutil.replaceExtension(new_path, '.css');
name_list.push(path.relative(__dirname, new_path).replace(/\\/g, '/'));
process += 1;
});

compass(path.join(__dirname, 'sass/import.scss'), {
project: __dirname,
style: 'compressed',
Expand Down Expand Up @@ -139,7 +152,7 @@ describe('gulp-compass plugin', function() {
});

timer = setInterval(function(){
if (process === 8) {
if (process === 9) {
clearInterval(timer);
done();
}
Expand Down Expand Up @@ -210,8 +223,16 @@ describe('gulp-compass plugin', function() {
actual.should.equal(expected);
});

it('test environment option', function() {
var actual, expected;

actual = read_file(path.join(__dirname, 'css/base/compile2.css'));
expected = read_file(path.join(__dirname, 'expected/compile2.css'));
actual.should.equal(expected);
});

it('output path test array', function() {
var expected = ['css/base/compile.css', 'css/compile.css', 'css/import.css', 'css/import2.css', 'css/multiple-require.css', 'css/require.css', 'css/simple.css', 'css/spriting.css'];
var expected = ['css/base/compile.css', 'css/base/compile2.css', 'css/compile.css', 'css/import.css', 'css/import2.css', 'css/multiple-require.css', 'css/require.css', 'css/simple.css', 'css/spriting.css'];
name_list.sort().should.eql(expected);
});

Expand Down
2 changes: 1 addition & 1 deletion test/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# You can select your preferred output style here (can be overridden via the command line):
# output_style = :expanded or :nested or :compact or :compressed
output_style = :compressed
output_style = (environment == :development) ? :expanded : :compressed

# To enable relative paths to assets via compass helper functions. Uncomment:
relative_assets = true
Expand Down
72 changes: 72 additions & 0 deletions test/expected/compile2.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font: inherit;
font-size: 100%;
vertical-align: baseline;
}

html {
line-height: 1;
}

ol, ul {
list-style: none;
}

table {
border-collapse: collapse;
border-spacing: 0;
}

caption, th, td {
text-align: left;
font-weight: normal;
vertical-align: middle;
}

q, blockquote {
quotes: none;
}
q:before, q:after, blockquote:before, blockquote:after {
content: "";
content: none;
}

a img {
border: none;
}

article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary {
display: block;
}

li {
font-family: serif;
font-weight: bold;
font-size: 1.2em;
}

.content-navigation {
border-color: #3bbfce;
color: #2ca2af;
}

.border {
padding: 8px;
margin: 8px;
border-color: #3bbfce;
}
17 changes: 17 additions & 0 deletions test/sass/base/compile2.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@import 'compass/reset';
@import 'imported';

$blue: #3bbfce;
$margin: 16px;

.content-navigation {
border-color: $blue;
color:
darken($blue, 9%);
}

.border {
padding: $margin / 2;
margin: $margin / 2;
border-color: $blue;
}

0 comments on commit 44940de

Please sign in to comment.