true 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +9 -0
- data/README.md +43 -0
- data/sass/true/_assert.scss +18 -14
- data/sass/true/_modules.scss +19 -24
- metadata +3 -3
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
True Changelog
|
2
2
|
==============
|
3
3
|
|
4
|
+
0.1.2 (6/7/13)
|
5
|
+
--------------
|
6
|
+
- Use nesting for modules with `test-module()`
|
7
|
+
- Added failure message argument to all assertions.
|
8
|
+
|
9
|
+
0.1.1 (6/6/13)
|
10
|
+
--------------
|
11
|
+
- Fix bug in `lib/true.rb` compass plugin registration.
|
12
|
+
|
4
13
|
0.1.0 (6/6/13)
|
5
14
|
--------------
|
6
15
|
- `assert-true()`, `assert-false()`, `assert-equal()`, and `assert-unequal()`.
|
data/README.md
CHANGED
@@ -2,3 +2,46 @@ True
|
|
2
2
|
====
|
3
3
|
|
4
4
|
A testing framework for compass/sass libraries.
|
5
|
+
|
6
|
+
Install
|
7
|
+
-------
|
8
|
+
|
9
|
+
in command line:
|
10
|
+
|
11
|
+
`gem install true`
|
12
|
+
|
13
|
+
in config.rb:
|
14
|
+
|
15
|
+
`require 'true'`
|
16
|
+
|
17
|
+
Usage
|
18
|
+
-----
|
19
|
+
|
20
|
+
in your scss:
|
21
|
+
|
22
|
+
```scss
|
23
|
+
@import "true";
|
24
|
+
|
25
|
+
// Track and report results in a test module
|
26
|
+
@include test-module('My Tests') {
|
27
|
+
|
28
|
+
// silent classes can help you organize tests and scope variables.
|
29
|
+
%test__feature-1 {
|
30
|
+
$test-1: 3*5;
|
31
|
+
$test-2: if(something, true, false);
|
32
|
+
|
33
|
+
// Assert something, with a message to post if the assertion fails.
|
34
|
+
@include assert-equal($test-1, 15,
|
35
|
+
'Simple multiplication failed.');
|
36
|
+
|
37
|
+
// You can assert-equal, assert-unequal, assert-true, or assert-false.
|
38
|
+
@include assert-true($test-2,
|
39
|
+
'Something returned false.');
|
40
|
+
}
|
41
|
+
|
42
|
+
}
|
43
|
+
```
|
44
|
+
|
45
|
+
**true** will report test results
|
46
|
+
both in the command line
|
47
|
+
and in the output css file.
|
data/sass/true/_assert.scss
CHANGED
@@ -2,31 +2,35 @@
|
|
2
2
|
// ======
|
3
3
|
|
4
4
|
@mixin assert-true(
|
5
|
-
$
|
5
|
+
$assert,
|
6
|
+
$fail-message: '#{$assert} is not true.'
|
6
7
|
) {
|
7
|
-
@if $
|
8
|
-
@else { @include fail(
|
8
|
+
@if $assert { @include pass; }
|
9
|
+
@else { @include fail($fail-message); }
|
9
10
|
}
|
10
11
|
|
11
12
|
@mixin assert-false(
|
12
|
-
$
|
13
|
+
$assert,
|
14
|
+
$fail-message: '#{$assert} is not false.'
|
13
15
|
) {
|
14
|
-
@if not $
|
15
|
-
@else { @include fail(
|
16
|
+
@if not $assert { @include pass; }
|
17
|
+
@else { @include fail($fail-message); }
|
16
18
|
}
|
17
19
|
|
18
20
|
@mixin assert-equal(
|
19
|
-
$
|
20
|
-
$expected
|
21
|
+
$assert,
|
22
|
+
$expected,
|
23
|
+
$fail-message: '#{$assert} != #{$expected}'
|
21
24
|
) {
|
22
|
-
@if $
|
23
|
-
@else { @include fail(
|
25
|
+
@if $assert == $expected { @include pass; }
|
26
|
+
@else { @include fail($fail-message); }
|
24
27
|
}
|
25
28
|
|
26
29
|
@mixin assert-unequal(
|
27
|
-
$
|
28
|
-
$expected
|
30
|
+
$assert,
|
31
|
+
$expected,
|
32
|
+
$fail-message: '#{$assert} == #{$expected}'
|
29
33
|
) {
|
30
|
-
@if $
|
31
|
-
@else { @include fail(
|
34
|
+
@if $assert != $expected { @include pass; }
|
35
|
+
@else { @include fail($fail-message); }
|
32
36
|
}
|
data/sass/true/_modules.scss
CHANGED
@@ -1,20 +1,14 @@
|
|
1
1
|
// Test Modules
|
2
2
|
// ============
|
3
3
|
|
4
|
-
$test-
|
5
|
-
$test-module-name: null;
|
4
|
+
$test-output: terminal css !default;
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
$name
|
10
|
-
) {
|
11
|
-
$test-results: compact();
|
12
|
-
$test-module-name: $name;
|
13
|
-
}
|
6
|
+
$module-name: null;
|
7
|
+
$test-results: null;
|
14
8
|
|
15
9
|
// Collate test results
|
16
10
|
@function collate-results(
|
17
|
-
$results
|
11
|
+
$results
|
18
12
|
) {
|
19
13
|
$total: length($results);
|
20
14
|
$pass: 0;
|
@@ -28,25 +22,26 @@ $test-module-name: null;
|
|
28
22
|
@return $total $pass $fail;
|
29
23
|
}
|
30
24
|
|
31
|
-
//
|
32
|
-
@mixin
|
33
|
-
$name
|
34
|
-
$
|
25
|
+
// Establish a new test module
|
26
|
+
@mixin test-module(
|
27
|
+
$name,
|
28
|
+
$output: $test-output
|
35
29
|
) {
|
36
|
-
$
|
30
|
+
$module-name: $name;
|
31
|
+
$test-results: compact();
|
32
|
+
|
33
|
+
@content;
|
34
|
+
|
35
|
+
$results: collate-results($test-results);
|
37
36
|
$total: nth($results, 1);
|
38
37
|
$pass: nth($results, 2);
|
39
38
|
$fail: nth($results, 3);
|
40
39
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
} @else {
|
46
|
-
@warn 'Remember to start your test module.';
|
47
|
-
}
|
40
|
+
$result-message: '#{$name}: Passed #{$pass} of #{$total} (#{$fail} tests failed)';
|
41
|
+
|
42
|
+
@if index($output, css) { /* #{$result-message} */ }
|
43
|
+
@if index($output, terminal) { @debug $result-message; }
|
48
44
|
|
49
|
-
|
45
|
+
$module-name: null;
|
50
46
|
$test-results: null;
|
51
|
-
$test-module-name: null;
|
52
47
|
}
|
metadata
CHANGED