true 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.
@@ -2,31 +2,35 @@
2
2
  // ======
3
3
 
4
4
  @mixin assert-true(
5
- $test
5
+ $assert,
6
+ $fail-message: '#{$assert} is not true.'
6
7
  ) {
7
- @if $test { @include pass; }
8
- @else { @include fail('#{$test} is not true.'); }
8
+ @if $assert { @include pass; }
9
+ @else { @include fail($fail-message); }
9
10
  }
10
11
 
11
12
  @mixin assert-false(
12
- $test
13
+ $assert,
14
+ $fail-message: '#{$assert} is not false.'
13
15
  ) {
14
- @if not $test { @include pass; }
15
- @else { @include fail('#{$test} is not false.'); }
16
+ @if not $assert { @include pass; }
17
+ @else { @include fail($fail-message); }
16
18
  }
17
19
 
18
20
  @mixin assert-equal(
19
- $test,
20
- $expected
21
+ $assert,
22
+ $expected,
23
+ $fail-message: '#{$assert} != #{$expected}'
21
24
  ) {
22
- @if $test == $expected { @include pass; }
23
- @else { @include fail('#{$test} != #{$expected}'); }
25
+ @if $assert == $expected { @include pass; }
26
+ @else { @include fail($fail-message); }
24
27
  }
25
28
 
26
29
  @mixin assert-unequal(
27
- $test,
28
- $expected
30
+ $assert,
31
+ $expected,
32
+ $fail-message: '#{$assert} == #{$expected}'
29
33
  ) {
30
- @if $test != $expected { @include pass; }
31
- @else { @include fail('#{$test} == #{$expected}'); }
34
+ @if $assert != $expected { @include pass; }
35
+ @else { @include fail($fail-message); }
32
36
  }
@@ -1,20 +1,14 @@
1
1
  // Test Modules
2
2
  // ============
3
3
 
4
- $test-results: null;
5
- $test-module-name: null;
4
+ $test-output: terminal css !default;
6
5
 
7
- // Establish a new test module
8
- @mixin start-test-module(
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: $test-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
- // Report the results of the module
32
- @mixin report-test-results(
33
- $name: $test-module-name,
34
- $results: $test-results
25
+ // Establish a new test module
26
+ @mixin test-module(
27
+ $name,
28
+ $output: $test-output
35
29
  ) {
36
- $results: collate-results($results);
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
- @if $name {
42
- $result-message: '#{$name}: Passed #{$pass} of #{$total} (#{$fail} tests failed)';
43
- /* #{$result-message} #{if($fail > 0, '************', null)}*/
44
- @debug $result-message;
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
- // End module
45
+ $module-name: null;
50
46
  $test-results: null;
51
- $test-module-name: null;
52
47
  }
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: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Eric Meyer