uspec 0.2.1 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +21 -0
- data/.rubocop.yml +56 -0
- data/README.markdown +16 -9
- data/bin/uspec +1 -1
- data/lib/uspec.rb +4 -9
- data/lib/uspec/cli.rb +26 -21
- data/lib/uspec/dsl.rb +30 -11
- data/lib/uspec/result.rb +30 -34
- data/lib/uspec/stats.rb +27 -21
- data/lib/uspec/version.rb +1 -1
- data/uspec.gemspec +2 -0
- data/uspec/cli_spec.rb +4 -4
- data/uspec/result_spec.rb +34 -4
- data/uspec/uspec_spec.rb +18 -2
- metadata +18 -3
- data/.travis.yml +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11c5e0a54306aeafdf5547c71c02c3ed64fabc60f068bff1d6d395cc1fac11b3
|
4
|
+
data.tar.gz: 918d6e06e01c9c0541a410d9ecc5aad0a7c7f416c0532d533f461383dfad70d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46c2d5c8833632e28692a834c664a3947e21f8a0049133b99b409282eecaafa7d4e2ce2b6247e24bd625d8924f80634f6343c2013ce1b73789fcdd631ecd7075
|
7
|
+
data.tar.gz: 79fc6300bf5e09df01a0cfce23aca9514d58e571f222a0843f9e68c948a48550add600eb75fd429eefeccaeb81d48ca95cb3da2ee7f66fcb3eed3b28e962e903
|
@@ -0,0 +1,21 @@
|
|
1
|
+
version: 2.1
|
2
|
+
orbs:
|
3
|
+
ruby: circleci/ruby@0.1.2
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
docker:
|
8
|
+
- image: circleci/ruby:2.6.3-stretch-node
|
9
|
+
executor: ruby/default
|
10
|
+
steps:
|
11
|
+
- checkout
|
12
|
+
- run:
|
13
|
+
name: Which bundler?
|
14
|
+
command: bundle -v
|
15
|
+
- ruby/bundle-install
|
16
|
+
test:
|
17
|
+
executor: ruby/default
|
18
|
+
steps:
|
19
|
+
- run:
|
20
|
+
name: Uspec tests
|
21
|
+
command: bundle exec uspec
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# Rubocop override settings
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 2.0
|
5
|
+
|
6
|
+
Metrics/LineLength:
|
7
|
+
Max: 120
|
8
|
+
Exclude:
|
9
|
+
- config_module.gemspec
|
10
|
+
- "uspec/**/*"
|
11
|
+
|
12
|
+
Naming/PredicateName:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Style/PreferredHashMethods:
|
16
|
+
Exclude:
|
17
|
+
- "**/*"
|
18
|
+
|
19
|
+
Style/Documentation:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Style/MethodDefParentheses:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Style/ParallelAssignment:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
Style/SingleLineMethods:
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
Style/Alias:
|
32
|
+
Enabled: false
|
33
|
+
|
34
|
+
Style/CaseEquality:
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
Style/SymbolArray:
|
38
|
+
Enabled: false
|
39
|
+
|
40
|
+
Bundler/OrderedGems:
|
41
|
+
Enabled: false
|
42
|
+
|
43
|
+
Style/StringLiterals:
|
44
|
+
EnforcedStyle: double_quotes
|
45
|
+
|
46
|
+
Style/StringLiteralsInInterpolation:
|
47
|
+
EnforcedStyle: double_quotes
|
48
|
+
|
49
|
+
Layout/AccessModifierIndentation:
|
50
|
+
EnforcedStyle: outdent
|
51
|
+
|
52
|
+
Style/EnforcedStyleForMultiline:
|
53
|
+
EnforcedStyle: consistent_comma
|
54
|
+
|
55
|
+
Naming/RescuedExceptionsVariableName:
|
56
|
+
PreferredName: error
|
data/README.markdown
CHANGED
@@ -3,8 +3,9 @@ Uspec
|
|
3
3
|
|
4
4
|
Uspec is a shiny little testing framework for your apps!
|
5
5
|
|
6
|
-
[](https://rubygems.org/gems/uspec/)
|
7
|
+
[](https://app.circleci.com/pipelines/github/acook/uspec)
|
8
|
+
[](https://codeclimate.com/github/acook/uspec)
|
8
9
|
|
9
10
|
Philosophy / Why Uspec?
|
10
11
|
-----------------------
|
@@ -61,12 +62,12 @@ Or install it directly with:
|
|
61
62
|
Quickstart
|
62
63
|
----------
|
63
64
|
|
64
|
-
0. Create a `
|
65
|
+
0. Create a `uspec` directory to keep your specs in.
|
65
66
|
1. Name your specs ending with `_spec.rb`.
|
66
67
|
2. Write some specs in Ruby using the `spec` method (example above).
|
67
68
|
2. Use the included `uspec` executable to run your specs.
|
68
69
|
|
69
|
-
**Hint:** A lot of people also put `require_relative 'spec_helper'`
|
70
|
+
**Hint:** A lot of people also put `require_relative 'spec_helper'` at the top of their test files for sharing code between tests.
|
70
71
|
|
71
72
|
Commandline Usage
|
72
73
|
-----------------
|
@@ -77,7 +78,7 @@ uspec - minimalistic ruby testing framework
|
|
77
78
|
usage: uspec [<file_or_path>...]
|
78
79
|
```
|
79
80
|
|
80
|
-
- Without arguments the `uspec` command will automatially look for
|
81
|
+
- Without arguments the `uspec` command will automatially look for a `uspec` directory and load any `*_spec.rb` files inside them.
|
81
82
|
- You can also pass in arbitrary files and it will attempt to run them as specs.
|
82
83
|
- If you pass in directories `uspec` will scan for and run any specs inside them.
|
83
84
|
- Uspec will return the number of failures as its status code to the commandline, 0 if none.
|
@@ -85,7 +86,7 @@ usage: uspec [<file_or_path>...]
|
|
85
86
|
Output
|
86
87
|
------
|
87
88
|
|
88
|
-
|
89
|
+
A brief explanation of `uspec`'s output to show you what it can do!
|
89
90
|
|
90
91
|
### Success
|
91
92
|
|
@@ -157,7 +158,7 @@ When you run the test Uspec will helpfully display:
|
|
157
158
|
Tips & Tricks
|
158
159
|
-------------
|
159
160
|
|
160
|
-
Because there's no matchers and only one method there's no
|
161
|
+
Because there's no matchers and only one method there's no need for specialized reference documentation, but here are some ideas to get you going!
|
161
162
|
|
162
163
|
### String matching
|
163
164
|
|
@@ -200,6 +201,11 @@ If there's no error, then Uspec will see the result of the method call (whatever
|
|
200
201
|
If the wrong Exception is raised, then because of reraising (by just calling `raise` without parameters),
|
201
202
|
Ruby will dutifully pass along the error for Uspec to display.
|
202
203
|
|
204
|
+
Mocks, Spies, Stubs, and More!
|
205
|
+
-----------------------
|
206
|
+
|
207
|
+
Since `uspec` is a very straight forward testing utility it is easy to use any of the standard Ruby mocking frameworks with it. However, the [Impasta gem](https://github.com/acook/impasta) was made specifically for simple but comprehensive mocking, stubbing, and spying.
|
208
|
+
|
203
209
|
Assertions & Debugging
|
204
210
|
----------------------
|
205
211
|
|
@@ -223,7 +229,8 @@ end
|
|
223
229
|
MyFoo.new.assert
|
224
230
|
```
|
225
231
|
|
226
|
-
|
232
|
+
Assertions will be displayed as they occur, success or failure along with any informative output.
|
233
|
+
If there are any specs that fail, when your application exits its error code will equal the number of failures.
|
227
234
|
|
228
235
|
```
|
229
236
|
$ ruby foo.rb
|
@@ -250,4 +257,4 @@ Contributing
|
|
250
257
|
Author
|
251
258
|
------
|
252
259
|
|
253
|
-
> Anthony M. Cook 2013-
|
260
|
+
> Anthony M. Cook 2013-2020
|
data/bin/uspec
CHANGED
data/lib/uspec.rb
CHANGED
@@ -8,15 +8,10 @@ module Uspec
|
|
8
8
|
exit 2
|
9
9
|
end
|
10
10
|
|
11
|
+
# this method used to be how we injected the spec method
|
11
12
|
def self.extended object
|
12
|
-
object.
|
13
|
+
#unless object.respond_to? :spec
|
14
|
+
# object.extend Uspec::DSL
|
15
|
+
#end
|
13
16
|
end
|
14
17
|
end
|
15
|
-
|
16
|
-
at_exit do
|
17
|
-
failures = Uspec::Stats.exit_code
|
18
|
-
status = $!.respond_to?(:status) ? $!.status : 0
|
19
|
-
errors = $!.respond_to?(:cause) && $!.cause ? 1 : 0
|
20
|
-
code = [failures, status, errors].max
|
21
|
-
exit code
|
22
|
-
end
|
data/lib/uspec/cli.rb
CHANGED
@@ -2,29 +2,34 @@ require 'pathname'
|
|
2
2
|
require_relative '../uspec'
|
3
3
|
|
4
4
|
class Uspec::CLI
|
5
|
-
|
6
|
-
|
7
|
-
warn "uspec v#{::Uspec::VERSION} - minimalistic ruby testing framework"
|
8
|
-
warn "usage: #{File.basename $0} [<file_or_path>...]"
|
9
|
-
end
|
5
|
+
def initialize args
|
6
|
+
usage unless (args & %w[-h --help -? /? -v --version]).empty?
|
10
7
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
@paths = args
|
9
|
+
@pwd = Pathname.pwd.freeze
|
10
|
+
@stats = Uspec::Stats.new
|
11
|
+
@dsl = Uspec::DSL.new self
|
12
|
+
end
|
13
|
+
attr :stats, :dsl
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
usage
|
21
|
-
end
|
22
|
-
end
|
15
|
+
def usage
|
16
|
+
warn "uspec v#{::Uspec::VERSION} - minimalistic ruby testing framework"
|
17
|
+
warn "usage: #{File.basename $0} [<file_or_path>...]"
|
18
|
+
exit 1
|
23
19
|
end
|
24
20
|
|
25
|
-
def
|
26
|
-
|
27
|
-
|
21
|
+
def run_specs
|
22
|
+
run_paths
|
23
|
+
end
|
24
|
+
|
25
|
+
def invoke
|
26
|
+
run_specs
|
27
|
+
puts @stats.summary
|
28
|
+
exit exit_code
|
29
|
+
end
|
30
|
+
|
31
|
+
def exit_code
|
32
|
+
[@stats.failure.size, 255].min
|
28
33
|
end
|
29
34
|
|
30
35
|
def paths
|
@@ -51,7 +56,7 @@ class Uspec::CLI
|
|
51
56
|
end
|
52
57
|
elsif path.exist? then
|
53
58
|
puts "#{path.basename path.extname}:"
|
54
|
-
|
59
|
+
dsl.instance_eval(path.read, path.to_s)
|
55
60
|
else
|
56
61
|
warn "path not found: #{path}"
|
57
62
|
end
|
@@ -74,7 +79,7 @@ class Uspec::CLI
|
|
74
79
|
MSG
|
75
80
|
puts
|
76
81
|
warn message
|
77
|
-
|
82
|
+
stats.failure << Uspec::Result.new(message, error, caller)
|
78
83
|
end
|
79
84
|
|
80
85
|
end
|
data/lib/uspec/dsl.rb
CHANGED
@@ -1,23 +1,42 @@
|
|
1
1
|
require_relative "result"
|
2
2
|
|
3
3
|
module Uspec
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
class DSL
|
5
|
+
def initialize cli
|
6
|
+
@__uspec_cli = cli
|
7
|
+
end
|
8
8
|
|
9
|
-
|
9
|
+
def __uspec_cli
|
10
|
+
@__uspec_cli
|
11
|
+
end
|
10
12
|
|
11
|
-
|
13
|
+
def __uspec_stats
|
14
|
+
@__uspec_cli.stats
|
15
|
+
end
|
12
16
|
|
13
|
-
|
14
|
-
|
15
|
-
|
17
|
+
def spec description
|
18
|
+
print ' -- ', description
|
19
|
+
|
20
|
+
if block_given? then
|
21
|
+
begin
|
22
|
+
raw_result = yield
|
23
|
+
rescue Exception => raw_result
|
24
|
+
end
|
16
25
|
end
|
17
26
|
|
18
27
|
result = Result.new description, raw_result, caller
|
19
28
|
|
20
|
-
|
29
|
+
unless block_given? then
|
30
|
+
result.pending!
|
31
|
+
end
|
32
|
+
|
33
|
+
if result.success?
|
34
|
+
__uspec_stats.success << result
|
35
|
+
elsif result.pending?
|
36
|
+
stats.pending << result
|
37
|
+
else
|
38
|
+
__uspec_stats.failure << result
|
39
|
+
end
|
21
40
|
|
22
41
|
print ': ', result.pretty, "\n"
|
23
42
|
rescue => error
|
@@ -30,7 +49,7 @@ module Uspec
|
|
30
49
|
MSG
|
31
50
|
puts
|
32
51
|
warn message
|
33
|
-
|
52
|
+
__uspec_stats.failure << Uspec::Result.new(message, error, caller)
|
34
53
|
end
|
35
54
|
end
|
36
55
|
end
|
data/lib/uspec/result.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative "terminal"
|
2
|
+
require "toisb"
|
2
3
|
|
3
4
|
module Uspec
|
4
5
|
class Result
|
@@ -8,14 +9,17 @@ module Uspec
|
|
8
9
|
@spec = spec
|
9
10
|
@raw = raw
|
10
11
|
@source = source
|
12
|
+
@handler = ::TOISB.wrap raw
|
11
13
|
end
|
12
|
-
attr_reader :spec, :raw, :source
|
14
|
+
attr_reader :spec, :raw, :source, :handler
|
13
15
|
|
14
16
|
def pretty
|
15
17
|
if raw == true then
|
16
18
|
green raw
|
17
19
|
elsif raw == false then
|
18
20
|
red raw
|
21
|
+
elsif pending? then
|
22
|
+
yellow 'pending'
|
19
23
|
elsif Exception === raw then
|
20
24
|
[
|
21
25
|
red('Exception'), vspace,
|
@@ -26,10 +30,10 @@ module Uspec
|
|
26
30
|
].join
|
27
31
|
else
|
28
32
|
[
|
29
|
-
red('
|
33
|
+
red('Failed'), vspace,
|
30
34
|
hspace, 'Spec did not return a boolean value ', newline,
|
31
35
|
hspace, 'in spec at ', source.first, vspace,
|
32
|
-
hspace, red(
|
36
|
+
hspace, red(subklassinfo), inspector, newline
|
33
37
|
].join
|
34
38
|
end
|
35
39
|
end
|
@@ -41,18 +45,28 @@ module Uspec
|
|
41
45
|
end
|
42
46
|
|
43
47
|
def message
|
44
|
-
"#{red
|
48
|
+
"#{red subklassinfo}#{raw.message}"
|
45
49
|
end
|
46
50
|
|
47
|
-
def
|
48
|
-
|
51
|
+
def subklassinfo
|
52
|
+
"#{handler.subklassinfo}: "
|
49
53
|
end
|
50
54
|
|
51
55
|
# Attempts to inspect an object
|
52
56
|
def inspector
|
53
|
-
|
57
|
+
if String === raw && raw.include?(?\n) then
|
58
|
+
# if object is a multiline string, display it unescaped
|
59
|
+
[
|
60
|
+
vspace,
|
61
|
+
hspace, yellow('"""'), newline,
|
62
|
+
raw, normal, newline,
|
63
|
+
hspace, yellow('"""')
|
64
|
+
].join
|
65
|
+
else
|
66
|
+
handler.inspector!
|
67
|
+
end
|
54
68
|
rescue Exception => error
|
55
|
-
return
|
69
|
+
return handler.simple_inspector if error.message.include? handler.get_id
|
56
70
|
|
57
71
|
error_file, error_line, _ = error.backtrace[4].split ?:
|
58
72
|
|
@@ -74,38 +88,20 @@ module Uspec
|
|
74
88
|
MSG
|
75
89
|
end
|
76
90
|
|
77
|
-
|
78
|
-
|
79
|
-
Module === raw ? raw : ancestor_klasses[1]
|
80
|
-
end
|
81
|
-
|
82
|
-
# Returns the superclass of the object
|
83
|
-
def superklass
|
84
|
-
ancestor_klasses[2]
|
85
|
-
end
|
86
|
-
|
87
|
-
# Gets the object ID of an object
|
88
|
-
def get_id
|
89
|
-
raw.__id__.to_s(16) rescue 0
|
90
|
-
end
|
91
|
-
|
92
|
-
# Obtain the singleton class of an object
|
93
|
-
def singleton
|
94
|
-
@singleton ||= (class << raw; self; end) rescue raw.class
|
91
|
+
def success?
|
92
|
+
raw == true
|
95
93
|
end
|
96
94
|
|
97
|
-
def
|
98
|
-
|
95
|
+
def failure?
|
96
|
+
raw != true && !@pending
|
99
97
|
end
|
100
98
|
|
101
|
-
|
102
|
-
|
103
|
-
@ancestors ||= safe_send singleton, :ancestors
|
99
|
+
def pending?
|
100
|
+
!!@pending
|
104
101
|
end
|
105
102
|
|
106
|
-
|
107
|
-
|
108
|
-
(Module === object ? Module : Object).instance_method(method).bind(object).call(*args, &block)
|
103
|
+
def pending!
|
104
|
+
@pending = true
|
109
105
|
end
|
110
106
|
|
111
107
|
def inspect
|
data/lib/uspec/stats.rb
CHANGED
@@ -1,30 +1,36 @@
|
|
1
1
|
module Uspec
|
2
2
|
class Stats
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
def results
|
9
|
-
@results ||= clear_results!
|
10
|
-
end
|
11
|
-
|
12
|
-
def clear_results!
|
13
|
-
@results = Array.new
|
14
|
-
end
|
3
|
+
def initialize
|
4
|
+
clear_results!
|
5
|
+
end
|
6
|
+
attr :success, :failure, :pending
|
15
7
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
8
|
+
def clear_results!
|
9
|
+
@success = Array.new
|
10
|
+
@failure = Array.new
|
11
|
+
@pending = Array.new
|
12
|
+
end
|
21
13
|
|
22
|
-
|
23
|
-
|
14
|
+
def inspect
|
15
|
+
<<-INFO
|
24
16
|
#{super} Failures: #{exit_code}
|
25
17
|
#{results.map{|r| r.inspect}.join "\n\t" }
|
26
|
-
|
27
|
-
|
18
|
+
INFO
|
19
|
+
end
|
20
|
+
|
21
|
+
def results
|
22
|
+
@success + @failure + @pending
|
23
|
+
end
|
24
|
+
|
25
|
+
def summary
|
26
|
+
[
|
27
|
+
"test summary: ",
|
28
|
+
Uspec::Terminal.green("#{@success.size} successful"),
|
29
|
+
", ",
|
30
|
+
Uspec::Terminal.red("#{@failure.size} failed"),
|
31
|
+
", ",
|
32
|
+
Uspec::Terminal.yellow("#{@pending.size} pending")
|
33
|
+
].join
|
28
34
|
end
|
29
35
|
end
|
30
36
|
end
|
data/lib/uspec/version.rb
CHANGED
data/uspec.gemspec
CHANGED
@@ -22,6 +22,8 @@ Gem::Specification.new do |gem|
|
|
22
22
|
# technically should still work in 2.0 but some of the test suite won't pass
|
23
23
|
gem.required_ruby_version = ">= 2.1"
|
24
24
|
|
25
|
+
gem.add_dependency "that_object_is_so_basic", "~> 0.0.5"
|
26
|
+
|
25
27
|
gem.add_development_dependency "pry"
|
26
28
|
gem.add_development_dependency "pry-doc"
|
27
29
|
end
|
data/uspec/cli_spec.rb
CHANGED
@@ -12,19 +12,19 @@ end
|
|
12
12
|
spec 'runs a path of specs' do
|
13
13
|
output = capture do
|
14
14
|
path = Pathname.new(__FILE__).parent.parent.join('example_specs').to_s
|
15
|
-
Uspec::CLI.
|
15
|
+
Uspec::CLI.new(Array(path)).run_specs
|
16
16
|
end
|
17
17
|
|
18
|
-
output.include?
|
18
|
+
output.include?('I love passing tests') || output
|
19
19
|
end
|
20
20
|
|
21
21
|
spec 'runs an individual spec' do
|
22
22
|
output = capture do
|
23
23
|
path = Pathname.new(__FILE__).parent.parent.join('example_specs', 'example_spec.rb').to_s
|
24
|
-
Uspec::CLI.
|
24
|
+
Uspec::CLI.new(Array(path)).run_specs
|
25
25
|
end
|
26
26
|
|
27
|
-
output.include?
|
27
|
+
output.include?('I love passing tests') || output
|
28
28
|
end
|
29
29
|
|
30
30
|
spec 'broken requires in test files count as test failures' do
|
data/uspec/result_spec.rb
CHANGED
@@ -15,9 +15,31 @@ obj = TestObject.new
|
|
15
15
|
|
16
16
|
spec "ensure BasicObject subclasses work" do
|
17
17
|
result = Uspec::Result.new "BasicObject Subclass Result", obj, []
|
18
|
-
expected = "#<TestObject:"
|
18
|
+
expected = "#<BasicObject/TestObject:"
|
19
19
|
actual = result.pretty
|
20
|
-
actual.include?(expected) || result.
|
20
|
+
actual.include?(expected) || result.pretty
|
21
|
+
end
|
22
|
+
|
23
|
+
spec "display basic info about Object" do
|
24
|
+
result = Uspec::Result.new "Object Result", Object.new, []
|
25
|
+
expected = "Object < BasicObject"
|
26
|
+
actual = result.pretty
|
27
|
+
actual.include?(expected) || result.pretty
|
28
|
+
end
|
29
|
+
|
30
|
+
spec "display basic info about Array" do
|
31
|
+
result = Uspec::Result.new "Array Result", [], []
|
32
|
+
expected = "Array < Object"
|
33
|
+
actual = result.pretty
|
34
|
+
actual.include?(expected) || result.pretty
|
35
|
+
end
|
36
|
+
|
37
|
+
spec "display basic info about Array class" do
|
38
|
+
result = Uspec::Result.new "Array Class Result", Array, []
|
39
|
+
#expected = "Class < ???" # TODO: Make classes display nicer in TOISB
|
40
|
+
expected = "#<Class:Object> < #<Class:BasicObject>: \e[0mArray"
|
41
|
+
actual = result.pretty
|
42
|
+
actual.include?(expected) || result.pretty
|
21
43
|
end
|
22
44
|
|
23
45
|
parent = [obj]
|
@@ -29,12 +51,20 @@ spec "ensure parent object of BasicObject subclasses get a useful error message"
|
|
29
51
|
actual.include?(expected) || result.inspector
|
30
52
|
end
|
31
53
|
|
32
|
-
class ::InspectFail; def inspect; raise; end; end
|
54
|
+
class ::InspectFail; def inspect; raise RuntimeError, "This error is intentional and part of the test."; end; end
|
33
55
|
inspect_fail = InspectFail.new
|
34
56
|
|
35
57
|
spec "display a useful error message when a user-defined inspect method fails" do
|
36
58
|
result = Uspec::Result.new "Inspect Fail Result", inspect_fail, []
|
37
|
-
expected = "raises an
|
59
|
+
expected = "raises an exception"
|
38
60
|
actual = result.pretty
|
39
61
|
actual.include?(expected) || result.inspector
|
40
62
|
end
|
63
|
+
|
64
|
+
spec "display strings more like their actual contents" do
|
65
|
+
expected = "this string:\nshould display \e[42;2mproperly"
|
66
|
+
result = Uspec::Result.new "Inspect Fail Result", expected, []
|
67
|
+
actual = result.pretty
|
68
|
+
actual.include?(expected) || result.inspector
|
69
|
+
end
|
70
|
+
|
data/uspec/uspec_spec.rb
CHANGED
@@ -10,6 +10,16 @@ spec 'catches errors' do
|
|
10
10
|
output.include? 'Exception'
|
11
11
|
end
|
12
12
|
|
13
|
+
spec 'catches even non-StandardError-subclass exceptions' do
|
14
|
+
output = capture do
|
15
|
+
spec 'not implemented error' do
|
16
|
+
raise ::NotImplementedError, 'test exception'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
output.include? 'Exception'
|
21
|
+
end
|
22
|
+
|
13
23
|
spec 'complains when spec block returns non boolean' do
|
14
24
|
output = capture do
|
15
25
|
spec 'whatever' do
|
@@ -17,7 +27,7 @@ spec 'complains when spec block returns non boolean' do
|
|
17
27
|
end
|
18
28
|
end
|
19
29
|
|
20
|
-
output.include? '
|
30
|
+
output.include? 'Failed'
|
21
31
|
end
|
22
32
|
|
23
33
|
spec 'marks test as pending when no block supplied' do
|
@@ -35,13 +45,15 @@ end
|
|
35
45
|
spec 'exit code is the number of failures' do
|
36
46
|
expected = 50
|
37
47
|
output = capture do
|
48
|
+
__uspec_stats.clear_results! # because we're forking, we will have a copy of the current results
|
49
|
+
|
38
50
|
expected.times do |count|
|
39
51
|
spec "fail ##{count + 1}" do
|
40
52
|
false
|
41
53
|
end
|
42
54
|
end
|
43
55
|
|
44
|
-
|
56
|
+
exit __uspec_cli.exit_code
|
45
57
|
end
|
46
58
|
actual = $?.exitstatus
|
47
59
|
|
@@ -50,11 +62,15 @@ end
|
|
50
62
|
|
51
63
|
spec 'if more than 255 failures, exit status is 255' do
|
52
64
|
capture do
|
65
|
+
__uspec_stats.clear_results! # because we're forking, we will have a copy of the current results
|
66
|
+
|
53
67
|
500.times do
|
54
68
|
spec 'fail' do
|
55
69
|
false
|
56
70
|
end
|
57
71
|
end
|
72
|
+
|
73
|
+
exit __uspec_cli.exit_code
|
58
74
|
end
|
59
75
|
|
60
76
|
$?.exitstatus == 255 || $?
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony M. Cook
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: that_object_is_so_basic
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.0.5
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.5
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: pry
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -48,11 +62,12 @@ executables:
|
|
48
62
|
extensions: []
|
49
63
|
extra_rdoc_files: []
|
50
64
|
files:
|
65
|
+
- ".circleci/config.yml"
|
51
66
|
- ".editorconfig"
|
52
67
|
- ".gitignore"
|
68
|
+
- ".rubocop.yml"
|
53
69
|
- ".ruby-gemset"
|
54
70
|
- ".ruby-version"
|
55
|
-
- ".travis.yml"
|
56
71
|
- Gemfile
|
57
72
|
- LICENSE.txt
|
58
73
|
- README.markdown
|
data/.travis.yml
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
|
3
|
-
rvm:
|
4
|
-
- 2.6.3
|
5
|
-
- 2.5.5
|
6
|
-
- 2.4.6
|
7
|
-
- 2.3.8
|
8
|
-
- 2.2.10
|
9
|
-
- 2.1.10
|
10
|
-
|
11
|
-
- 2.0.0
|
12
|
-
- 1.9.3
|
13
|
-
- 1.9.2
|
14
|
-
- jruby-19mode
|
15
|
-
- ruby-head
|
16
|
-
|
17
|
-
before_install:
|
18
|
-
- gem update bundler
|
19
|
-
before_script:
|
20
|
-
- bundle exec gem list
|
21
|
-
script: bundle exec uspec
|
22
|
-
|
23
|
-
matrix:
|
24
|
-
allow_failures:
|
25
|
-
- rvm: 2.0.0
|
26
|
-
- rvm: 1.9.3
|
27
|
-
- rvm: 1.9.2
|
28
|
-
- rvm: ruby-head
|
29
|
-
- rvm: jruby-19mode
|
30
|
-
|
31
|
-
sudo: false
|