cutest-cj 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/bin/cutest +2 -1
- data/cutest.gemspec +3 -2
- data/lib/cutest.rb +30 -23
- data/test/fixtures/only_run_given_scope_name.rb +0 -10
- data/test/fixtures/outside_block.rb +5 -0
- data/test/run.rb +20 -27
- metadata +19 -5
- data/lib/cutest/vendor/clap.rb +0 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92455ef2621ffc03d72b7c668d15e197ef5b41fe
|
4
|
+
data.tar.gz: f97510d289eccd25608ea698b13b11f934206e59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3ead93fcd65e94a6957a133199bf9d45aa2320fb37c4cc3d90162971f2f911cf320e427cc927d51d705101bc0a70e6a2d5148d6653842dc340d36abeaa1893c
|
7
|
+
data.tar.gz: 197f7e987c7f78be3b94da7275982360b5910bc6292a142330080d0ec8bbc937b1261798da86a09b4b2dedc17eab3fe11cbf2d02de37592ee311613924a3aa00
|
data/CHANGELOG.md
CHANGED
data/bin/cutest
CHANGED
@@ -8,12 +8,13 @@ if ARGV.empty?
|
|
8
8
|
end
|
9
9
|
|
10
10
|
require_relative "../lib/cutest"
|
11
|
-
|
11
|
+
require "clap"
|
12
12
|
|
13
13
|
files = Clap.run ARGV,
|
14
14
|
"-r" => lambda { |file| require file },
|
15
15
|
"-t" => lambda { |name| cutest[:only] = name },
|
16
16
|
"-s" => lambda { |name| cutest[:scope] = name },
|
17
|
+
"-w" => lambda { |name| cutest[:warnings] = true },
|
17
18
|
"-b" => lambda { cutest[:backtrace] = true },
|
18
19
|
"-p" => lambda {
|
19
20
|
ENV['PRY_RESCUE'] = 'true'; cutest[:pry_rescue] = true
|
data/cutest.gemspec
CHANGED
data/lib/cutest.rb
CHANGED
@@ -2,7 +2,7 @@ require 'benchmark'
|
|
2
2
|
|
3
3
|
class Cutest
|
4
4
|
unless defined?(VERSION)
|
5
|
-
VERSION = "1.2.
|
5
|
+
VERSION = "1.2.4"
|
6
6
|
FILTER = %r[/(ruby|jruby|rbx)[-/]([0-9\.])+]
|
7
7
|
CACHE = Hash.new { |h, k| h[k] = File.readlines(k) }
|
8
8
|
end
|
@@ -14,20 +14,28 @@ class Cutest
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
def self.silence_warnings
|
18
|
+
old_verbose, $VERBOSE = $VERBOSE, nil
|
19
|
+
yield
|
20
|
+
ensure
|
21
|
+
$VERBOSE = old_verbose
|
22
|
+
end
|
23
|
+
|
17
24
|
def self.run(files)
|
25
|
+
if !cutest[:warnings]
|
26
|
+
Cutest.silence_warnings do
|
27
|
+
Cutest.now_run files
|
28
|
+
end
|
29
|
+
else
|
30
|
+
Cutest.now_run files
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.now_run files
|
18
35
|
status = files.all? do |file|
|
19
36
|
run_file(file)
|
20
37
|
|
21
|
-
|
22
|
-
Process.wait
|
23
|
-
$?.success?
|
24
|
-
else
|
25
|
-
begin
|
26
|
-
Process.waitall
|
27
|
-
rescue ThreadError, Interrupt
|
28
|
-
# Ignore this as it's caused by Process.waitall when using -p
|
29
|
-
end
|
30
|
-
end
|
38
|
+
Process.wait2.last.success?
|
31
39
|
end
|
32
40
|
|
33
41
|
puts
|
@@ -127,11 +135,10 @@ private
|
|
127
135
|
# Create a class where the block will be evaluated. Recommended to improve
|
128
136
|
# isolation between tests.
|
129
137
|
def scope(name = nil, &block)
|
130
|
-
cutest[:
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
Cutest::Scope.new(&block).call
|
138
|
+
if !cutest[:scope] || cutest[:scope] == name
|
139
|
+
print "\n \033[93mScope: \033[0m#{cutest[:scope]}\n\n "
|
140
|
+
Cutest::Scope.new(&block).call
|
141
|
+
end
|
135
142
|
end
|
136
143
|
|
137
144
|
# Prepare the environment in order to run the tests. This method can be
|
@@ -174,15 +181,15 @@ private
|
|
174
181
|
def test(name = nil, &block)
|
175
182
|
cutest[:test] = name
|
176
183
|
|
177
|
-
if !cutest[:
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
block.call(setup && setup.call)
|
184
|
+
if !cutest[:only] || cutest[:only] == name
|
185
|
+
time_taken = Benchmark.measure do
|
186
|
+
prepare.each { |blk| blk.call }
|
187
|
+
block.call(setup && setup.call)
|
182
188
|
end
|
183
|
-
|
184
|
-
end
|
189
|
+
print " \n \033[93mTest: \033[0m#{cutest[:test]} \033[32m✔\033[0m\n \e[94m#{time_taken}\033[0m\n "
|
185
190
|
end
|
191
|
+
|
192
|
+
cutest[:test] = nil
|
186
193
|
end
|
187
194
|
|
188
195
|
# Assert that value is not nil or false.
|
data/test/run.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
test "output of successful run" do
|
2
|
-
|
2
|
+
require 'pry'
|
3
|
+
expected = "•"
|
3
4
|
|
4
5
|
out = %x{./bin/cutest test/fixtures/success.rb}
|
5
6
|
|
6
|
-
|
7
|
+
assert out[expected]
|
7
8
|
end
|
8
9
|
|
9
10
|
test "exit code of successful run" do
|
@@ -12,27 +13,19 @@ test "exit code of successful run" do
|
|
12
13
|
end
|
13
14
|
|
14
15
|
test "output of failed run" do
|
15
|
-
expected = "
|
16
|
-
" test: failed assertion\n" +
|
17
|
-
" line: assert false\n" +
|
18
|
-
" file: test/fixtures/failure.rb +2\n\n" +
|
19
|
-
"Cutest::AssertionFailed: expression returned false\n\n"
|
16
|
+
expected = "failed assertion"
|
20
17
|
|
21
18
|
out = %x{./bin/cutest test/fixtures/failure.rb}
|
22
19
|
|
23
|
-
|
20
|
+
assert out[expected]
|
24
21
|
end
|
25
22
|
|
26
23
|
test "output of failed run" do
|
27
|
-
expected = "
|
28
|
-
" test: some unhandled exception\n" +
|
29
|
-
" line: raise \"Oops\"\n" +
|
30
|
-
" file: test/fixtures/exception.rb +2\n\n" +
|
31
|
-
"RuntimeError: Oops\n\n"
|
24
|
+
expected = "RuntimeError"
|
32
25
|
|
33
26
|
out = %x{./bin/cutest test/fixtures/exception.rb}
|
34
27
|
|
35
|
-
|
28
|
+
assert out[expected]
|
36
29
|
end
|
37
30
|
|
38
31
|
test "exit code of failed run" do
|
@@ -42,27 +35,27 @@ test "exit code of failed run" do
|
|
42
35
|
end
|
43
36
|
|
44
37
|
test "output of custom assertion" do
|
45
|
-
expected = "
|
46
|
-
" test: failed custom assertion\n" +
|
47
|
-
" line: assert_empty \"foo\"\n" +
|
48
|
-
" file: test/fixtures/fail_custom_assertion.rb +7\n\n" +
|
49
|
-
"Cutest::AssertionFailed: not empty\n\n"
|
38
|
+
expected = "Cutest::AssertionFailed"
|
50
39
|
|
51
40
|
out = %x{./bin/cutest test/fixtures/fail_custom_assertion.rb}
|
52
41
|
|
53
|
-
|
42
|
+
assert out[expected]
|
54
43
|
end
|
55
44
|
|
56
45
|
test "output of failure in nested file" do
|
57
|
-
expected = "
|
58
|
-
" test: failed assertion\n" +
|
59
|
-
" line: assert false\n" +
|
60
|
-
" file: test/fixtures/failure.rb +2\n\n" +
|
61
|
-
"Cutest::AssertionFailed: expression returned false\n\n"
|
46
|
+
expected = "Cutest::AssertionFailed"
|
62
47
|
|
63
48
|
out = %x{./bin/cutest test/fixtures/failure_in_loaded_file.rb}
|
64
49
|
|
65
|
-
|
50
|
+
assert out[expected]
|
51
|
+
end
|
52
|
+
|
53
|
+
test "output of failure outside block" do
|
54
|
+
expected = "Cutest::AssertionFailed"
|
55
|
+
|
56
|
+
out = %x{./bin/cutest test/fixtures/outside_block.rb}
|
57
|
+
|
58
|
+
assert out[expected]
|
66
59
|
end
|
67
60
|
|
68
61
|
test "only runs given scope name" do
|
@@ -72,7 +65,7 @@ test "only runs given scope name" do
|
|
72
65
|
end
|
73
66
|
|
74
67
|
test "runs by given scope and test names" do
|
75
|
-
%x{./bin/cutest test/fixtures/only_run_given_scope_name.rb -s scope -
|
68
|
+
%x{./bin/cutest test/fixtures/only_run_given_scope_name.rb -s scope -t test}
|
76
69
|
|
77
70
|
assert_equal 0, $?.to_i
|
78
71
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cutest-cj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damian Janowski
|
@@ -10,10 +10,10 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-06-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name: pry
|
16
|
+
name: pry
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
19
|
- - ">="
|
@@ -27,7 +27,21 @@ dependencies:
|
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '0'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
|
-
name:
|
30
|
+
name: awesome_print
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: clap
|
31
45
|
requirement: !ruby/object:Gem::Requirement
|
32
46
|
requirements:
|
33
47
|
- - ">="
|
@@ -58,7 +72,6 @@ files:
|
|
58
72
|
- bin/cutest
|
59
73
|
- cutest.gemspec
|
60
74
|
- lib/cutest.rb
|
61
|
-
- lib/cutest/vendor/clap.rb
|
62
75
|
- test/assert.rb
|
63
76
|
- test/assert_equal.rb
|
64
77
|
- test/assert_raise.rb
|
@@ -67,6 +80,7 @@ files:
|
|
67
80
|
- test/fixtures/failure.rb
|
68
81
|
- test/fixtures/failure_in_loaded_file.rb
|
69
82
|
- test/fixtures/only_run_given_scope_name.rb
|
83
|
+
- test/fixtures/outside_block.rb
|
70
84
|
- test/fixtures/success.rb
|
71
85
|
- test/prepare.rb
|
72
86
|
- test/run.rb
|
data/lib/cutest/vendor/clap.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
class Clap
|
2
|
-
attr :argv
|
3
|
-
attr :opts
|
4
|
-
|
5
|
-
def self.run(args, opts)
|
6
|
-
new(args, opts).run
|
7
|
-
end
|
8
|
-
|
9
|
-
def initialize(argv, opts)
|
10
|
-
@argv = argv.dup
|
11
|
-
@opts = opts
|
12
|
-
end
|
13
|
-
|
14
|
-
def run
|
15
|
-
args = []
|
16
|
-
|
17
|
-
while argv.any?
|
18
|
-
|
19
|
-
item = argv.shift
|
20
|
-
flag = opts[item]
|
21
|
-
|
22
|
-
if flag
|
23
|
-
|
24
|
-
# Work around lambda semantics in 1.8.7.
|
25
|
-
arity = [flag.arity, 0].max
|
26
|
-
|
27
|
-
# Raise if there are not enough parameters
|
28
|
-
# available for the flag.
|
29
|
-
if argv.size < arity
|
30
|
-
raise ArgumentError
|
31
|
-
end
|
32
|
-
|
33
|
-
# Call the lambda with N items from argv,
|
34
|
-
# where N is the lambda's arity.
|
35
|
-
flag.call(*argv.shift(arity))
|
36
|
-
else
|
37
|
-
|
38
|
-
# Collect the items that don't correspond to
|
39
|
-
# flags.
|
40
|
-
args << item
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
args
|
45
|
-
end
|
46
|
-
end
|