true 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  True Changelog
2
2
  ==============
3
3
 
4
+ 0.1.4 (6/9/13)
5
+ --------------
6
+ - Null result is considered a failure.
7
+ - Allow output to be turned off for certain modules/tests/assertions.
8
+
4
9
  0.1.3 (6/7/13)
5
10
  --------------
6
11
  - Nest assertions within `test() {}` named tests.
data/README.md CHANGED
@@ -3,10 +3,9 @@ True
3
3
 
4
4
  A testing framework for compass/sass libraries.
5
5
 
6
- At this point,
7
- True is better at testing functions than mixins -
8
- because it is easier to test a value
9
- than the actual property-value css output.
6
+ At this point
7
+ True can only test values,
8
+ not property/value output.
10
9
 
11
10
  Install
12
11
  -------
@@ -5,34 +5,39 @@ $test-module-results : null;
5
5
 
6
6
  // Establish a new test module
7
7
  @mixin test-module(
8
- $name
8
+ $name,
9
+ $output: true
9
10
  ) {
10
11
  // Setup
11
12
  $test-result-context: module;
12
13
  $test-module-results: compact();
13
14
 
14
- @include result-message('
15
+ @if $output {
16
+ @include result-message('
15
17
 
16
18
  ### #{$name} ------', css);
19
+ }
17
20
 
18
21
  // Content
19
22
  @content;
20
23
 
21
24
  // Results
22
- $results: collate-results($test-module-results);
23
- $total: nth($results, 1);
24
- $pass: nth($results, 2);
25
- $fail: nth($results, 3);
25
+ @if $output {
26
+ $results: collate-results($test-module-results);
27
+ $total: nth($results, 1);
28
+ $pass: nth($results, 2);
29
+ $fail: nth($results, 3);
26
30
 
27
- $debug-message: '#{$name}: #{$total} Tests, #{$pass} Passed, #{$fail} failed';
28
- @include result-message($debug-message, debug);
31
+ $debug-message: '#{$name}: #{$total} Tests, #{$pass} Passed, #{$fail} failed';
32
+ @include result-message($debug-message, debug);
29
33
 
30
- $css-message: '
34
+ $css-message: '
31
35
  Summary:
32
36
  - #{$total} Tests
33
37
  - #{$pass} Passed
34
38
  - #{$fail} Failed';
35
- @include result-message($css-message, css);
39
+ @include result-message($css-message, css);
40
+ }
36
41
 
37
42
  // Teardown
38
43
  $test-result-context: null;
@@ -1,12 +1,17 @@
1
1
  // Results
2
2
  // =======
3
3
 
4
- $test-result-context: null;
4
+ $test-result-context : null;
5
5
 
6
- $pass-marker : p;
7
- $fail-marker : f;
6
+ $pass-marker : p;
7
+ $fail-marker : f;
8
+
9
+ $test-pass-message : '.' !default;
10
+ $test-fail-message : 'F' !default;
8
11
 
9
12
  // Collate test results
13
+ // --------------------
14
+
10
15
  @function collate-results(
11
16
  $results
12
17
  ) {
@@ -22,7 +27,10 @@ $fail-marker : f;
22
27
  @return $total $pass $fail;
23
28
  }
24
29
 
25
- // Record the results
30
+
31
+ // Record test results
32
+ // -------------------
33
+
26
34
  @mixin record-result(
27
35
  $result,
28
36
  $context: $test-result-context
@@ -43,24 +51,54 @@ $fail-marker : f;
43
51
  }
44
52
  }
45
53
 
54
+
55
+ // Report test results
56
+ // -------------------
57
+
58
+ @mixin report-test(
59
+ $name,
60
+ $results,
61
+ $context: module,
62
+ $output: true
63
+ ) {
64
+ $results: collate-results($test-results);
65
+ $total: nth($results, 1);
66
+ $pass: nth($results, 2);
67
+ $fail: nth($results, 3);
68
+
69
+ $message: '#{$name} (#{$total} assertions, #{$pass} passed, #{$fail} failed)';
70
+
71
+ @if $fail > 0 or $pass < 1 {
72
+ $fail-message: '- FAIL: ' + $message;
73
+ @include fail($fail-message, $context, $output: $output);
74
+ @if $output { @include result-message('FAIL: ' + $message, css); }
75
+ }
76
+ @else {
77
+ $pass-message: '- ' + $message;
78
+ @include pass($test-pass-message, $context, $output: $output);
79
+ @if $output { @include result-message($pass-message, css); }
80
+ }
81
+
82
+ }
83
+
84
+
46
85
  // Pass / Fail
47
86
  // -----------
48
87
 
49
- $test-pass-message : '.' !default;
50
- $test-fail-message : 'F' !default;
51
-
52
88
  @mixin pass(
53
89
  $pass: $test-pass-message,
54
- $context: $test-result-context
90
+ $context: $test-result-context,
91
+ $output: true
55
92
  ) {
56
93
  @include record-result(pass, $context);
57
- @include result-message($pass, debug);
94
+ @if $output { @include result-message($pass, debug); }
58
95
  }
59
96
 
60
97
  @mixin fail(
61
98
  $fail: $test-fail-message,
62
- $context: $test-result-context
99
+ $context: $test-result-context,
100
+ $output: true
63
101
  ) {
64
102
  @include record-result(fail, $context);
65
- @include result-message($fail, warn);
103
+ @if $output { @include result-message($fail, warn); }
66
104
  }
@@ -5,7 +5,8 @@ $test-results: null;
5
5
 
6
6
  // Establish a new test
7
7
  @mixin test(
8
- $name
8
+ $name,
9
+ $output: true
9
10
  ) {
10
11
  // Setup
11
12
  $test-results: compact();
@@ -19,33 +20,8 @@ $test-results: null;
19
20
  $test-result-context: $old-result-context;
20
21
 
21
22
  // Results
22
- @include report-test($name, $test-results, $test-result-context);
23
+ @include report-test($name, $test-results, $test-result-context, $output);
23
24
 
24
25
  // Teardown
25
26
  $test-results: null;
26
27
  }
27
-
28
- @mixin report-test(
29
- $name,
30
- $results,
31
- $context
32
- ) {
33
- $results: collate-results($test-results);
34
- $total: nth($results, 1);
35
- $pass: nth($results, 2);
36
- $fail: nth($results, 3);
37
-
38
- $message: '#{$name} (#{$total} assertions, #{$pass} passed, #{$fail} failed)';
39
-
40
- @if $fail > 0 {
41
- $fail-message: '- FAIL: ' + $message;
42
- @include fail($fail-message, module);
43
- @include result-message('FAIL: ' + $message, css);
44
- }
45
- @else {
46
- $pass-message: '- ' + $message;
47
- @include pass($test-pass-message, module);
48
- @include result-message($pass-message, css);
49
- }
50
-
51
- }
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: "true"
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Eric Meyer
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-06-07 00:00:00 Z
18
+ date: 2013-06-09 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: compass