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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 280690061c479c165d28f6005e7ca95aa1ce1b7e
4
- data.tar.gz: 95f63fd81e7e6b7e98c8a5560cc4bcada717705e
3
+ metadata.gz: 92455ef2621ffc03d72b7c668d15e197ef5b41fe
4
+ data.tar.gz: f97510d289eccd25608ea698b13b11f934206e59
5
5
  SHA512:
6
- metadata.gz: 72dc85da58fc84e8585bfd38334a9684bf3e4af7309730714512a413d895dccc636685740bbee4d2c145ceb8eecc06dc911db1a5ca5090e96463a9eaf9684b77
7
- data.tar.gz: 10c04b49a9b55524385de103d5d33bbb0f71e1bc51cc67361855538b6d21e3c63a421af2609118124af4e409ab5151b3a4649f7cfe060bb5f1180a9af54e3e53
6
+ metadata.gz: a3ead93fcd65e94a6957a133199bf9d45aa2320fb37c4cc3d90162971f2f911cf320e427cc927d51d705101bc0a70e6a2d5148d6653842dc340d36abeaa1893c
7
+ data.tar.gz: 197f7e987c7f78be3b94da7275982360b5910bc6292a142330080d0ec8bbc937b1261798da86a09b4b2dedc17eab3fe11cbf2d02de37592ee311613924a3aa00
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ (unreleased)
2
+ ============
3
+
4
+ * Use `-s` to run a single scope.
5
+
1
6
  1.2.1 - 2013-08-14
2
7
  ==================
3
8
 
data/bin/cutest CHANGED
@@ -8,12 +8,13 @@ if ARGV.empty?
8
8
  end
9
9
 
10
10
  require_relative "../lib/cutest"
11
- require_relative "../lib/cutest/vendor/clap"
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
@@ -15,6 +15,7 @@ Gem::Specification.new do |s|
15
15
 
16
16
  s.executables.push "cutest"
17
17
 
18
- s.add_dependency 'pry-rescue'
19
- s.add_dependency 'pry-stack_explorer'
18
+ s.add_dependency 'pry'
19
+ s.add_dependency 'awesome_print'
20
+ s.add_dependency "clap"
20
21
  end
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.3"
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
- if not cutest[:pry_rescue]
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[:current_scope] = name
131
- return if cutest[:scope] and cutest[:scope] != cutest[:current_scope]
132
-
133
- print "\n \033[93mScope: \033[0m#{cutest[:current_scope]}\n\n "
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[:scope] || cutest[:scope] == cutest[:current_scope]
178
- if !cutest[:only] || cutest[:only] == name
179
- time_taken = Benchmark.measure do
180
- prepare.each { |blk| blk.call }
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
- print " \n \033[93mTest: \033[0m#{cutest[:test]} \033[32m✔\033[0m\n \e[94m#{time_taken}\033[0m\n "
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.
@@ -1,13 +1,3 @@
1
- test do
2
- raise "This is not raised"
3
- end
4
-
5
- scope "scope" do
6
- test do
7
- assert true
8
- end
9
- end
10
-
11
1
  scope "another scope" do
12
2
  test do
13
3
  raise "This is not raised"
@@ -0,0 +1,5 @@
1
+ test "named success" do
2
+ assert true
3
+ end
4
+
5
+ assert false
data/test/run.rb CHANGED
@@ -1,9 +1,10 @@
1
1
  test "output of successful run" do
2
- expected = ".\n"
2
+ require 'pry'
3
+ expected = "•"
3
4
 
4
5
  out = %x{./bin/cutest test/fixtures/success.rb}
5
6
 
6
- assert_equal(expected, out)
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 = "\n" +
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
- assert_equal(expected, out)
20
+ assert out[expected]
24
21
  end
25
22
 
26
23
  test "output of failed run" do
27
- expected = "\n" +
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
- assert_equal(expected, out)
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 = "\n" +
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
- assert_equal(expected, out)
42
+ assert out[expected]
54
43
  end
55
44
 
56
45
  test "output of failure in nested file" do
57
- expected = "\n" +
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
- assert_equal(expected, out)
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 -o test}
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.3
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-05-27 00:00:00.000000000 Z
13
+ date: 2014-06-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: pry-rescue
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: pry-stack_explorer
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
@@ -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