true 0.2.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: edbabfb443c014cde7537ac4bb2b9d6d901424e3
4
- data.tar.gz: a9455cced338c3eb213b247291ae8584bca02e08
3
+ metadata.gz: 4991a75b377b7447e85b46077701cd8886520605
4
+ data.tar.gz: 4e7afcea7dbd134caa728473f2b73a1e7ffd01e1
5
5
  SHA512:
6
- metadata.gz: a56c48a52c8047dacd1cc35f2059c8aafffedbe4ffaefcc576b5fc49cd50b019612c7b3cafb95f43468b536950f8e8c92d20130f2967575d557b04ebe8cad159
7
- data.tar.gz: 049944205f25a1ceff0c5c42d46c2a735e9471822d5da2bd1dc15351a312462ac677f36d6ffc6026dd73ffc0216f5ac8e42005e96268e42b99729fdb10b82c12
6
+ metadata.gz: 7ee7cc9c924ad1dfddeb231e7083b1299a4dc8f01cf53067a68fbf7f53521a0eb1282ed5b0f6826a2d8771883a2f89a0d8dfaf3016c3de1918e58930aa7a5314
7
+ data.tar.gz: 786b63b92a43ec1ad116fc2aaf901537cb9a7e7eb75951942e74da9612ef54b80d6b83b62eaa32f385acaaa69fa706ee41f9c670e87094e279bacdb9773f5da4
data/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
1
  True Changelog
2
2
  ==============
3
3
 
4
+ 1.0.0 (10/3/14)
5
+ ---------------
6
+ - Add command-line interface: `true-cli <path-to-file>`
7
+ - Use `-s` flag for silent output
8
+ - Check for unit differences between numbers.
9
+ - Add assertion-failure details to css output.
10
+
11
+
4
12
  0.2.0 (7/15/14)
5
13
  ---------------
6
14
  - Simplified reporting in both terminal and CSS.
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013, Eric Meyer
1
+ Copyright (c) 2014, Eric Suzanne
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  [![Build Status](https://travis-ci.org/ericam/true.png?branch=master)](https://travis-ci.org/ericam/true)
2
2
 
3
+
3
4
  True
4
5
  ====
5
6
 
@@ -21,6 +22,7 @@ use True for logical unit tests,
21
22
  and use version-control for integration testing
22
23
  by comparing changes in output files.
23
24
 
25
+
24
26
  Install
25
27
  -------
26
28
 
@@ -32,166 +34,73 @@ in config.rb:
32
34
 
33
35
  `require 'true'`
34
36
 
35
- Usage
36
- -----
37
-
38
- Production example from
39
- [Susy Next](https://github.com/ericam/susy/blob/susy-next/test/scss/math/_columns.scss):
40
-
41
- ```scss
42
- @import "true";
43
-
44
- // Column Math Tests
45
- // =================
46
-
47
- @include test-module('Column Math') {
48
-
49
- // Is Symmetrical
50
- // --------------
51
-
52
- @include test('[function] is-symmetrical()') {
53
- $sym: 12;
54
- $asym: 1 2 4 1 2 1;
55
- $baz: compact(4);
56
-
57
- // 12 is a symmetrical grid.
58
- $s: is-symmetrical($sym);
59
- @include assert-true($s,
60
- 'Simple number should be symmetrical grid.');
61
-
62
- // (1 2 4 1 2 1) is not a symmetrical grid.
63
- $a: is-symmetrical($asym);
64
- @include assert-false($a,
65
- 'List should be asymmetrical grid.');
66
-
67
- // compact(4) is not a symmetrical grid (because it is a list).
68
- $b: is-symmetrical($baz);
69
- @include assert-false($b,
70
- 'Single-item list should be asymmetrical grid.');
71
- }
72
-
73
-
74
- // Column Count
75
- // ------------
76
-
77
- @include test('[function] column-count()') {
78
- $sym: 12;
79
- $asym: 1 2 4 1 2 1;
80
-
81
- // A symmetrical grid is equal to its column count.
82
- $s-count: column-count($sym);
83
- @include assert-equal($s-count, $sym,
84
- 'Symmetrical grid-count should equal $columns setting.');
85
-
86
- // An asymmetrical grid has a column-count equal to its length.
87
- $a-count: column-count($asym);
88
- $a-length: length($asym);
89
- @include assert-equal($a-count, $a-length,
90
- 'Asymmetrical grid-count should equal $columns length.');
91
- }
92
-
93
-
94
- // Column Sum
95
- // ----------
96
37
 
97
- @include test('[function] symmetrical column-sum()') {
98
- $cols : 9;
99
- $guts : .5;
100
- $sum : column-sum($cols, $guts);
101
- $outer : column-sum($cols, $guts, outer);
102
-
103
- @include assert-equal($sum, 13,
104
- 'Column-sum for "9 .5" should be "13".');
105
-
106
- @include assert-equal($outer, 13.5,
107
- 'Outer column-sum for "9 .5" should be "13.5".');
108
- }
109
-
110
- @include test('[function] asymmetrical column-sum()') {
111
- $sum : column-sum(1 2 3 1 2, .25);
112
- $outer : column-sum(1 2 3 1 2, .25, outer);
38
+ Command Line
39
+ -----
113
40
 
114
- @include assert-equal($sum, 10,
115
- 'Column-sum for "(1 2 3 1 2) .25" should be "10".');
41
+ `true-cli [options] PATH`
116
42
 
117
- @include assert-equal($outer, 10.25,
118
- 'Outer column-sum for "(1 2 3 1 2) .25" should be "10.25".');
119
- }
43
+ Options:
44
+ * `-s` slient
45
+ * `-c` config file
46
+ * `-d` debug config file settings
120
47
 
48
+ Config file (optional):
121
49
 
122
- // Get Columns
123
- // -----------
50
+ ``` yaml
51
+ options:
52
+ color: true #enables colored output
124
53
 
125
- @include test('[function] symmetrical get-columns()') {
126
- $span: 3;
127
- $context: 12;
128
- $sub: get-columns($span, 4, $context);
129
-
130
- @include assert-equal($sub, $span,
131
- 'Symmetrical get-columns subset should be equal to its span.');
132
- }
54
+ # require ruby sass extension libraries
55
+ require:
56
+ - "compass"
57
+ - "serialy_sassy"
58
+ ```
133
59
 
134
- @include test('[function] asymmetrical get-columns()') {
135
- $span: 3;
136
- $context: 1 2 3 1 2;
137
- $sub: get-columns($span, 2, $context);
60
+ default location: `test/true.yml`
138
61
 
139
- @include assert-equal($sub, 2 3 1,
140
- 'Get-columns subset for "3 of (1 2 3 1 2) at 2" should be "2 3 1".');
141
- }
142
62
 
63
+ Usage
64
+ -----
143
65
 
144
- // Get Column Span Sum
145
- // -------------------
66
+ ```scss
67
+ @import "true";
146
68
 
147
- @include test('[function] symmetrical get-column-span-sum()') {
148
- $cols: 12;
149
- $guts: 1/8;
69
+ @include test-module('Utilities') {
150
70
 
151
- $sum: get-column-span-sum(3, 2, $cols, $guts);
152
- @include assert-equal($sum, 3.25,
153
- 'Inner span-sum for "3 of 12 1/8 at 2" should be "3.25"');
71
+ @include test('Map Add [function]') {
72
+ $base: (one: 1, two: 1, three: 1);
73
+ $add: (one: 1, two: 2, three: -1);
154
74
 
155
- $sum: get-column-span-sum(3, last, $cols, $guts, outer);
156
- @include assert-equal($sum, 3.375,
157
- 'Outer span-sum for "last 3 of 12 1/8" should be "3.375".');
75
+ $test: map-add($base, $add);
76
+ $expect: (one: 2, two: 3, three: 0);
77
+ @include assert-equal($test, $expect,
78
+ 'Returns the sum of two numeric maps');
158
79
  }
159
80
 
160
- @include test('[function] asymmetrical get-column-span-sum()') {
161
- $cols: 1 2 3 2 1 2 3;
162
- $guts: 1/4;
163
-
164
- $sum: get-column-span-sum(3, 2, $cols, $guts);
165
- @include assert-equal($sum, 7.5,
166
- 'Inner span-sum for "3 at 2 of (1 2 3 2 1 2 3)" should be "7.5".');
81
+ @include test('Strict Equal [function]') {
82
+ $test: is-equal(1, 1rem);
83
+ @include assert-equal($test, false,
84
+ 'Returns false for equal numbers with different units.');
167
85
 
168
- $sum: get-column-span-sum(3, last, $cols, $guts, outer);
169
- @include assert-equal($sum, 6.75,
170
- 'Outer span-sum for "last 3 of (1 2 3 2 1 2 3)" should be "6.75".');
86
+ $test: is-equal(1, 1);
87
+ @include assert-equal($test, true,
88
+ 'Returns true for numbers that are truely equal.');
171
89
  }
172
-
173
90
  }
174
91
  ```
175
92
 
176
- **True** will report detailed results in the terminal,
177
- and a summary of results in the output css.
93
+ **True** will report to both the terminal and an output css file by default.
178
94
 
179
- Here's the Susy "Column Math" CSS output:
95
+ Here's a sample of the CSS output:
180
96
 
181
97
  ```css
98
+ /* ### Utilities ---------- */
99
+ /* - Map Add [function] (1 Assertions, 1 Passed, 0 Failed) */
100
+ /* - Strict Equal [function] (2 Assertions, 2 Passed, 0 Failed) */
182
101
  /*
183
-
184
- ### Column Math ------ */
185
- /* - [function] is-symmetrical() (3 Assertions, 3 Passed, 0 Failed) */
186
- /* - [function] column-count() (2 Assertions, 2 Passed, 0 Failed) */
187
- /* - [function] symmetrical column-sum() (2 Assertions, 2 Passed, 0 Failed) */
188
- /* - [function] asymmetrical column-sum() (2 Assertions, 2 Passed, 0 Failed) */
189
- /* - [function] symmetrical get-columns() (1 Assertions, 1 Passed, 0 Failed) */
190
- /* - [function] asymmetrical get-columns() (1 Assertions, 1 Passed, 0 Failed) */
191
- /* - [function] symmetrical get-column-span-sum() (2 Assertions, 2 Passed, 0 Failed) */
192
- /* - [function] asymmetrical get-column-span-sum() (2 Assertions, 2 Passed, 0 Failed) */
193
- /*
194
- 8 Tests:
195
- - 8 Passed
196
- - 0 Failed */
102
+ */
103
+ /* 2 Tests: */
104
+ /* - 2 Passed */
105
+ /* - 0 Failed */
197
106
  ```
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 1.0.0
data/bin/true-cli ADDED
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env ruby
2
+ require 'sass'
3
+ require 'true'
4
+ require 'yaml'
5
+ require 'optparse'
6
+ COLORS = {
7
+ :ok => "\033[92m",
8
+ :fail => "\033[91m",
9
+ :end => "\033[0m"
10
+ }
11
+ options = {'debug' => false, 'slient' => false, 'color' => false}
12
+ config_file = File.join(Dir.pwd, 'test', 'true.yml')
13
+ OptionParser.new do |opts|
14
+ opts.banner = "Usage: true-cli [options] file"
15
+
16
+ opts.on('-c', '--config PATH', String, 'path to config file') do |config|
17
+ config_file = config
18
+ end
19
+ opts.on('-d', '--debug') do
20
+ options['debug'] = true
21
+ end
22
+ opts.on('-s', '--slient') do
23
+ options['slient'] = true
24
+ end
25
+ end.parse!(ARGV)
26
+
27
+
28
+ def with_captured_stdout
29
+ begin
30
+ old_stderr = $stderr
31
+ $stderr = StringIO.new('', 'r+')
32
+ yield
33
+ $stderr.string
34
+ ensure
35
+ $stderr = old_stderr
36
+ end
37
+ end
38
+ output = with_captured_stdout do
39
+ ARGV.each do |file|
40
+ Sass::Engine.for_file(file, {}).render
41
+ end
42
+ end
43
+
44
+ if File.exists?(config_file)
45
+ puts "Using config file: #{config_file}" unless options['slient']
46
+ config_options = YAML.load(File.read(config_file))
47
+ options.merge!(config_options['options']) if config_options.has_key?('options')
48
+ if options['debug']
49
+ puts config_options.inspect
50
+ end
51
+ if config_options.has_key?('require')
52
+ config_options['require'].each do |path|
53
+ require path
54
+ end
55
+ end
56
+ end
57
+
58
+ if output.empty?
59
+ puts "No test files supplied"
60
+ exit(2)
61
+ end
62
+
63
+ matches = output.match(%r{(?<tests>\d+) Tests, (?<passed>\d+) Passed, (?<failed>\d+) Failed})
64
+
65
+ if matches[:failed] == '0'
66
+ if options['color']
67
+ puts COLORS[:ok] + output + COLORS[:end] unless options['slient']
68
+ else
69
+ puts output unless options['slient']
70
+ end
71
+ exit(0)
72
+ else
73
+ if options['color']
74
+ puts COLORS[:fail] + output + COLORS[:end] unless options['slient']
75
+ else
76
+ puts output unless options['slient']
77
+ end
78
+ exit(3)
79
+ end
data/lib/true.rb CHANGED
@@ -1,12 +1,9 @@
1
1
  true_stylesheets_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'sass'))
2
+ ENV['SASS_PATH'] ||= ''
2
3
  begin
3
4
  require 'compass'
4
- Compass::Frameworks.register('true', :stylesheets_directory => true_stylesheets_path)
5
+ ENV['SASS_PATH'] = ENV['SASS_PATH'] + File::PATH_SEPARATOR + Compass.configuration.sass_load_paths.join(File::PATH_SEPARATOR)
5
6
  rescue LoadError
6
- # compass not found, register on the Sass path via the environment.
7
- if ENV.key? 'SASS_PATH'
8
- ENV['SASS_PATH'] += File::PATH_SEPARATOR + true_stylesheets_path
9
- else
10
- ENV['SASS_PATH'] = true_stylesheets_path
11
- end
12
7
  end
8
+ # compass not found, register on the Sass path via the environment.
9
+ ENV['SASS_PATH'] += File::PATH_SEPARATOR + true_stylesheets_path
@@ -29,7 +29,7 @@
29
29
  $name: map-get($test-results, name);
30
30
  $debug-message: 'Expected: #{inspect($expected)}',
31
31
  'Result: #{inspect($assert)}';
32
- $result: if($assert == $expected, pass, fail);
32
+ $result: if(is-equal($assert, $expected), pass, fail);
33
33
  @include report-assert($name, $result, $fail-message, $debug-message...);
34
34
  }
35
35
 
@@ -41,8 +41,7 @@
41
41
  $name: map-get($test-results, name);
42
42
  $debug-message: 'Expected: #{inspect($expected)}',
43
43
  'Result: #{inspect($assert)}';
44
- $result: if($assert != $expected, pass, fail);
45
-
44
+ $result: if(is-equal($assert, $expected), fail, pass);
46
45
  @include report-assert($name, $result, $fail-message, $debug-message...);
47
46
  }
48
47
 
@@ -65,6 +64,9 @@
65
64
  @if $fail-message {
66
65
  @warn $fail-message;
67
66
  }
67
+
68
+ $test-details: $test-details + $-tnl + ' - error: '
69
+ + '(#{$debug}) ' + $fail-message !global;
68
70
  }
69
71
 
70
72
  $test-results: map-add($test-results, (run: 1, $result: 1)) !global;
@@ -48,7 +48,7 @@ $module-results: null;
48
48
  $pass: map-get($module-results, pass);
49
49
  $fail: map-get($module-results, fail);
50
50
 
51
- $css-message: '#{$run} Tests:\a - #{$pass} Passed\a - #{$fail} Failed';
51
+ $css-message: '#{$run} Tests:#{$-tnl} - #{$pass} Passed#{$-tnl} - #{$fail} Failed';
52
52
 
53
53
  @include spacer-comment;
54
54
  @include result-message($css-message, css);
@@ -2,6 +2,7 @@
2
2
  // =====
3
3
 
4
4
  $test-results: null;
5
+ $test-details: '';
5
6
 
6
7
  // Establish a new test
7
8
  @mixin test(
@@ -9,9 +10,11 @@ $test-results: null;
9
10
  $output: map-get($true, output)
10
11
  ) {
11
12
  $test-results: map-merge($blank-results, (name: $name)) !global;
13
+ $test-details: '' !global;
12
14
  @content;
13
- @include report-test($name, $test-results, $output);
15
+ @include report-test($name, $test-results, $output, $test-details);
14
16
  $test-results: null !global;
17
+ $test-details: '' !global;
15
18
  }
16
19
 
17
20
  // Report test results
@@ -20,7 +23,8 @@ $test-results: null;
20
23
  @mixin report-test(
21
24
  $name,
22
25
  $results,
23
- $output: map-get($true, output)
26
+ $output: map-get($true, output),
27
+ $details: ''
24
28
  ) {
25
29
  $pass: map-get($results, pass);
26
30
  $fail: map-get($results, fail);
@@ -28,7 +32,7 @@ $test-results: null;
28
32
 
29
33
  $message: '#{$name} (#{report($results, Assertions)})';
30
34
 
31
- @include test-result($result, $message, $output);
35
+ @include test-result($result, $message, $output, $details);
32
36
  }
33
37
 
34
38
  // Pass / Fail Tests
@@ -37,14 +41,15 @@ $test-results: null;
37
41
  @mixin test-result(
38
42
  $result,
39
43
  $message: '',
40
- $output: map-get($true, output)
44
+ $output: map-get($true, output),
45
+ $details: ''
41
46
  ) {
42
47
  $css: null;
43
48
  $terminal: null;
44
49
 
45
50
  @if $result == fail {
46
51
  $message: if($message, $message, map-get($true, fail));
47
- $css: '- FAIL: ' + if($message, $message, '');
52
+ $css: '- FAIL: ' + if($message, $message, '') + $details;
48
53
  $terminal: 'FAIL: ' + if($message, $message, '');
49
54
  } @else if $result == pass {
50
55
  $message: if($message, $message, map-get($true, pass));
@@ -17,26 +17,6 @@
17
17
  @return $base;
18
18
  }
19
19
 
20
- // Return a map as a string
21
- @function map-to-string(
22
- $map
23
- ) {
24
- @if type-of($map) != map {
25
- @return $map;
26
- } @else {
27
- $return: '(';
28
- $i: 1;
29
- @each $key, $value in $map {
30
- $return: $return + '#{$key}: #{$value}';
31
- @if $i < length(map-keys($map)) {
32
- $return: $return + ', ';
33
- }
34
- $i: $i + 1;
35
- }
36
- @return $return + ')';
37
- }
38
- }
39
-
40
20
  // Split a string
41
21
  @function str-split($string, $substring) {
42
22
  $strings: ();
@@ -49,3 +29,12 @@
49
29
  $strings: append($strings, $string);
50
30
  @return $strings;
51
31
  }
32
+
33
+ // Check for strict equality
34
+ @function is-equal($one, $two) {
35
+ @if type-of($one) == number and type-of($two) == number {
36
+ @return $one == $two and unit($one) == unit($two);
37
+ } @else {
38
+ @return $one == $two;
39
+ }
40
+ }
metadata CHANGED
@@ -1,10 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: 'true'
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - Eric Meyer
7
+ - Eric Suzanne
8
+ - Scott Davis
9
+ - Chris Eppstein
8
10
  autorequire:
9
11
  bindir: bin
10
12
  cert_chain: []
@@ -14,26 +16,23 @@ dependencies:
14
16
  name: sass
15
17
  requirement: !ruby/object:Gem::Requirement
16
18
  requirements:
17
- - - '>='
19
+ - - ~>
18
20
  - !ruby/object:Gem::Version
19
- version: 3.3.0
20
- - - <
21
- - !ruby/object:Gem::Version
22
- version: '3.5'
21
+ version: '3.4'
23
22
  type: :runtime
24
23
  prerelease: false
25
24
  version_requirements: !ruby/object:Gem::Requirement
26
25
  requirements:
27
- - - '>='
28
- - !ruby/object:Gem::Version
29
- version: 3.3.0
30
- - - <
26
+ - - ~>
31
27
  - !ruby/object:Gem::Version
32
- version: '3.5'
28
+ version: '3.4'
33
29
  description: Unit tests for maintaining test-driven Sass libraries.
34
30
  email:
35
31
  - eric@oddbird.net
36
- executables: []
32
+ - me@sdavis.info
33
+ - chris@eppsteins.net
34
+ executables:
35
+ - true-cli
37
36
  extensions: []
38
37
  extra_rdoc_files:
39
38
  - CHANGELOG.md
@@ -55,7 +54,8 @@ files:
55
54
  - LICENSE.txt
56
55
  - README.md
57
56
  - VERSION
58
- homepage: http://eric.andmeyer.com/true
57
+ - bin/true-cli
58
+ homepage: http://ericsuzanne.com/true
59
59
  licenses: []
60
60
  metadata: {}
61
61
  post_install_message:
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  version: '1.2'
81
81
  requirements: []
82
82
  rubyforge_project: 'true'
83
- rubygems_version: 2.0.3
83
+ rubygems_version: 2.1.10
84
84
  signing_key:
85
85
  specification_version: 3
86
86
  summary: Testing framework for Sass libraries.