uspec 0.2.2 → 1.0.2
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 +16 -0
- data/.ruby-version +1 -1
- data/README.markdown +18 -51
- 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 +27 -33
- data/lib/uspec/stats.rb +27 -21
- data/lib/uspec/version.rb +1 -1
- data/uspec.gemspec +2 -0
- data/uspec/cli_spec.rb +6 -5
- data/uspec/result_spec.rb +32 -3
- data/uspec/uspec_spec.rb +8 -2
- metadata +18 -4
- 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: c6763c9a1b9995386967bfb824889265c9bee560a86012728055bb107a4dd910
|
4
|
+
data.tar.gz: 74912e14810a2b03d596addcb14fe3696cd79efd3f8c104c49a4d65055aaca87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ead8cbbee34c75b337685d1c3533c6129d39d870cd9abf94b7365317760f6c42aeab6a7d30749fab352139c947669514c2870d3542bbcd1e2160e020f5574fcc
|
7
|
+
data.tar.gz: cfa24d4154e3b0a95257cd544fa45451c551e460cb3a7f6ac995c3446a1a09623729d03843c41bace49adfda04ea1a58e42cb1eb62e431a4e149d83afaa85e13
|
@@ -0,0 +1,16 @@
|
|
1
|
+
version: 2.1
|
2
|
+
orbs:
|
3
|
+
ruby: circleci/ruby@0.1.2
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
executor: ruby/default
|
8
|
+
steps:
|
9
|
+
- checkout
|
10
|
+
- run:
|
11
|
+
name: Which bundler?
|
12
|
+
command: bundle -v
|
13
|
+
- ruby/bundle-install
|
14
|
+
- run:
|
15
|
+
name: Uspec tests
|
16
|
+
command: bundle exec uspec
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.0.1
|
data/README.markdown
CHANGED
@@ -4,7 +4,7 @@ Uspec
|
|
4
4
|
Uspec is a shiny little testing framework for your apps!
|
5
5
|
|
6
6
|
[](https://rubygems.org/gems/uspec/)
|
7
|
-
[](https://app.circleci.com/pipelines/github/acook/uspec)
|
8
8
|
[](https://codeclimate.com/github/acook/uspec)
|
9
9
|
|
10
10
|
Philosophy / Why Uspec?
|
@@ -24,7 +24,7 @@ This also means *no monkey patching* core classes!
|
|
24
24
|
Uspec's output is in beautiful ansi technicolor,
|
25
25
|
with red for failures, green for successes, and yellow for pending specs. Here's a screenshot:
|
26
26
|
|
27
|
-

|
28
28
|
|
29
29
|
Uspec is tiny, painless, and easy to use. Download it and give it a try!
|
30
30
|
|
@@ -62,12 +62,12 @@ Or install it directly with:
|
|
62
62
|
Quickstart
|
63
63
|
----------
|
64
64
|
|
65
|
-
0. Create a `
|
65
|
+
0. Create a `uspec` directory to keep your specs in.
|
66
66
|
1. Name your specs ending with `_spec.rb`.
|
67
67
|
2. Write some specs in Ruby using the `spec` method (example above).
|
68
68
|
2. Use the included `uspec` executable to run your specs.
|
69
69
|
|
70
|
-
**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.
|
71
71
|
|
72
72
|
Commandline Usage
|
73
73
|
-----------------
|
@@ -78,7 +78,7 @@ uspec - minimalistic ruby testing framework
|
|
78
78
|
usage: uspec [<file_or_path>...]
|
79
79
|
```
|
80
80
|
|
81
|
-
- 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.
|
82
82
|
- You can also pass in arbitrary files and it will attempt to run them as specs.
|
83
83
|
- If you pass in directories `uspec` will scan for and run any specs inside them.
|
84
84
|
- Uspec will return the number of failures as its status code to the commandline, 0 if none.
|
@@ -86,11 +86,11 @@ usage: uspec [<file_or_path>...]
|
|
86
86
|
Output
|
87
87
|
------
|
88
88
|
|
89
|
-
|
89
|
+
A brief explanation of `uspec`'s output to show you what it can do!
|
90
90
|
|
91
91
|
### Success
|
92
92
|
|
93
|
-
If a spec passes:
|
93
|
+
If a spec passes (returns true):
|
94
94
|
|
95
95
|
```
|
96
96
|
-- AwesomeMcCoolname.generate creates a cool name: true
|
@@ -98,7 +98,7 @@ If a spec passes:
|
|
98
98
|
|
99
99
|
### Failure
|
100
100
|
|
101
|
-
If a spec fails:
|
101
|
+
If a spec fails (returns false):
|
102
102
|
|
103
103
|
```
|
104
104
|
-- AwesomeMcCoolname.generate creates a cool name: false
|
@@ -106,13 +106,13 @@ If a spec fails:
|
|
106
106
|
|
107
107
|
### Exception
|
108
108
|
|
109
|
-
If the spec
|
109
|
+
If the spec encounters an error (raises an Exception):
|
110
110
|
|
111
111
|
```
|
112
112
|
-- AwesomeMcCoolname.generate creates a cool name: Exception
|
113
113
|
|
114
114
|
Encountered an Exception while running spec
|
115
|
-
at uspec/awesome_mc_coolname_spec.rb:3: in `<main>'
|
115
|
+
in spec at uspec/awesome_mc_coolname_spec.rb:3: in `<main>'
|
116
116
|
|
117
117
|
RuntimeError < StandardError: 'wtf'
|
118
118
|
|
@@ -130,13 +130,13 @@ spec 'AwesomeMcCoolname.generate creates a cool name' do
|
|
130
130
|
end
|
131
131
|
```
|
132
132
|
|
133
|
-
Then Uspec will let you know:
|
133
|
+
Then Uspec will let you know so you can debug it:
|
134
134
|
|
135
135
|
```ruby
|
136
|
-
-- AwesomeMcCoolname.generate creates a badass name:
|
136
|
+
-- AwesomeMcCoolname.generate creates a badass name: Failed
|
137
137
|
|
138
138
|
Spec did not return a boolean value
|
139
|
-
at uspec/awesome_mc_coolname_spec.rb:6: in `<main>'
|
139
|
+
in spec at uspec/awesome_mc_coolname_spec.rb:6: in `<main>'
|
140
140
|
|
141
141
|
Integer < Numeric: 5
|
142
142
|
```
|
@@ -158,7 +158,7 @@ When you run the test Uspec will helpfully display:
|
|
158
158
|
Tips & Tricks
|
159
159
|
-------------
|
160
160
|
|
161
|
-
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!
|
162
162
|
|
163
163
|
### String matching
|
164
164
|
|
@@ -201,43 +201,10 @@ If there's no error, then Uspec will see the result of the method call (whatever
|
|
201
201
|
If the wrong Exception is raised, then because of reraising (by just calling `raise` without parameters),
|
202
202
|
Ruby will dutifully pass along the error for Uspec to display.
|
203
203
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
You can also use `uspec` to track assertions in an application or any object you want. Every spec block you use will be tracked and recorded. It's really no problem at all to do.
|
208
|
-
|
209
|
-
You can load Uspec's features directly into a class and use its DSL:
|
210
|
-
|
211
|
-
```ruby
|
212
|
-
require 'uspec'
|
213
|
-
|
214
|
-
class MyFoo
|
215
|
-
extend Uspec::DSL
|
216
|
-
|
217
|
-
def assert
|
218
|
-
spec 'foo is valid' do
|
219
|
-
false
|
220
|
-
end
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
MyFoo.new.assert
|
225
|
-
```
|
226
|
-
|
227
|
-
If there are any specs that fail, your application will exit with an error code equal to the number of failures.
|
228
|
-
|
229
|
-
```
|
230
|
-
$ ruby foo.rb
|
231
|
-
-- foo is valid: false
|
232
|
-
$ echo $?
|
233
|
-
1
|
234
|
-
```
|
235
|
-
|
236
|
-
Uspec is just Ruby
|
237
|
-
------------------
|
204
|
+
Mocks, Spies, Stubs, and More!
|
205
|
+
-----------------------
|
238
206
|
|
239
|
-
|
240
|
-
From there you can just run the file with ruby: `ruby my_test_spec.rb`
|
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.
|
241
208
|
|
242
209
|
Contributing
|
243
210
|
------------
|
@@ -251,4 +218,4 @@ Contributing
|
|
251
218
|
Author
|
252
219
|
------
|
253
220
|
|
254
|
-
> Anthony M. Cook 2013-
|
221
|
+
> Anthony M. Cook 2013-2021
|
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
|
+
__uspec_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
@@ -18,6 +18,8 @@ module Uspec
|
|
18
18
|
green raw
|
19
19
|
elsif raw == false then
|
20
20
|
red raw
|
21
|
+
elsif pending? then
|
22
|
+
yellow 'pending'
|
21
23
|
elsif Exception === raw then
|
22
24
|
[
|
23
25
|
red('Exception'), vspace,
|
@@ -28,10 +30,10 @@ module Uspec
|
|
28
30
|
].join
|
29
31
|
else
|
30
32
|
[
|
31
|
-
red('
|
33
|
+
red('Failed'), vspace,
|
32
34
|
hspace, 'Spec did not return a boolean value ', newline,
|
33
35
|
hspace, 'in spec at ', source.first, vspace,
|
34
|
-
hspace, red(
|
36
|
+
hspace, red(subklassinfo), inspector, (Class === raw ? ' Class' : ''), newline
|
35
37
|
].join
|
36
38
|
end
|
37
39
|
end
|
@@ -43,18 +45,28 @@ module Uspec
|
|
43
45
|
end
|
44
46
|
|
45
47
|
def message
|
46
|
-
"#{red
|
48
|
+
"#{red subklassinfo}#{raw.message}"
|
47
49
|
end
|
48
50
|
|
49
|
-
def
|
50
|
-
|
51
|
+
def subklassinfo
|
52
|
+
"#{handler.subklassinfo}: "
|
51
53
|
end
|
52
54
|
|
53
55
|
# Attempts to inspect an object
|
54
56
|
def inspector
|
55
|
-
|
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
|
56
68
|
rescue Exception => error
|
57
|
-
return
|
69
|
+
return handler.simple_inspector if error.message.include? handler.get_id
|
58
70
|
|
59
71
|
error_file, error_line, _ = error.backtrace[4].split ?:
|
60
72
|
|
@@ -76,38 +88,20 @@ module Uspec
|
|
76
88
|
MSG
|
77
89
|
end
|
78
90
|
|
79
|
-
|
80
|
-
|
81
|
-
Module === raw ? raw : ancestor_klasses[1]
|
82
|
-
end
|
83
|
-
|
84
|
-
# Returns the superclass of the object
|
85
|
-
def superklass
|
86
|
-
ancestor_klasses[2]
|
87
|
-
end
|
88
|
-
|
89
|
-
# Gets the object ID of an object
|
90
|
-
def get_id
|
91
|
-
raw.__id__.to_s(16) rescue 0
|
92
|
-
end
|
93
|
-
|
94
|
-
# Obtain the singleton class of an object
|
95
|
-
def singleton
|
96
|
-
@singleton ||= (class << raw; self; end) rescue raw.class
|
91
|
+
def success?
|
92
|
+
raw == true
|
97
93
|
end
|
98
94
|
|
99
|
-
def
|
100
|
-
|
95
|
+
def failure?
|
96
|
+
raw != true && !@pending
|
101
97
|
end
|
102
98
|
|
103
|
-
|
104
|
-
|
105
|
-
@ancestors ||= safe_send singleton, :ancestors
|
99
|
+
def pending?
|
100
|
+
!!@pending
|
106
101
|
end
|
107
102
|
|
108
|
-
|
109
|
-
|
110
|
-
(Module === object ? Module : Object).instance_method(method).bind(object).call(*args, &block)
|
103
|
+
def pending!
|
104
|
+
@pending = true
|
111
105
|
end
|
112
106
|
|
113
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
@@ -1,5 +1,4 @@
|
|
1
1
|
require_relative 'uspec_helper'
|
2
|
-
require 'open3'
|
3
2
|
|
4
3
|
spec 'shows usage' do
|
5
4
|
output = capture do
|
@@ -9,22 +8,24 @@ spec 'shows usage' do
|
|
9
8
|
output.include? 'usage'
|
10
9
|
end
|
11
10
|
|
11
|
+
spec 'pending test doesn\'t crash'
|
12
|
+
|
12
13
|
spec 'runs a path of specs' do
|
13
14
|
output = capture do
|
14
15
|
path = Pathname.new(__FILE__).parent.parent.join('example_specs').to_s
|
15
|
-
Uspec::CLI.
|
16
|
+
Uspec::CLI.new(Array(path)).run_specs
|
16
17
|
end
|
17
18
|
|
18
|
-
output.include?
|
19
|
+
output.include?('I love passing tests') || output
|
19
20
|
end
|
20
21
|
|
21
22
|
spec 'runs an individual spec' do
|
22
23
|
output = capture do
|
23
24
|
path = Pathname.new(__FILE__).parent.parent.join('example_specs', 'example_spec.rb').to_s
|
24
|
-
Uspec::CLI.
|
25
|
+
Uspec::CLI.new(Array(path)).run_specs
|
25
26
|
end
|
26
27
|
|
27
|
-
output.include?
|
28
|
+
output.include?('I love passing tests') || output
|
28
29
|
end
|
29
30
|
|
30
31
|
spec 'broken requires in test files count as test failures' do
|
data/uspec/result_spec.rb
CHANGED
@@ -13,11 +13,32 @@ end
|
|
13
13
|
class ::TestObject < BasicObject; end
|
14
14
|
obj = TestObject.new
|
15
15
|
|
16
|
-
spec "ensure BasicObject
|
16
|
+
spec "ensure BasicObject subclass instances 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: \e[0m#<Object:"
|
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 < Module: \e[0mArray Class"
|
40
|
+
actual = result.pretty
|
41
|
+
actual.include?(expected) || result.pretty
|
21
42
|
end
|
22
43
|
|
23
44
|
parent = [obj]
|
@@ -38,3 +59,11 @@ spec "display a useful error message when a user-defined inspect method fails" d
|
|
38
59
|
actual = result.pretty
|
39
60
|
actual.include?(expected) || result.inspector
|
40
61
|
end
|
62
|
+
|
63
|
+
spec "display strings more like their actual contents" do
|
64
|
+
expected = "this string:\nshould display \e[42;2mproperly"
|
65
|
+
result = Uspec::Result.new "Inspect Fail Result", expected, []
|
66
|
+
actual = result.pretty
|
67
|
+
actual.include?(expected) || result.inspector
|
68
|
+
end
|
69
|
+
|
data/uspec/uspec_spec.rb
CHANGED
@@ -27,7 +27,7 @@ spec 'complains when spec block returns non boolean' do
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
output.include? '
|
30
|
+
output.include? 'Failed'
|
31
31
|
end
|
32
32
|
|
33
33
|
spec 'marks test as pending when no block supplied' do
|
@@ -45,13 +45,15 @@ end
|
|
45
45
|
spec 'exit code is the number of failures' do
|
46
46
|
expected = 50
|
47
47
|
output = capture do
|
48
|
+
__uspec_stats.clear_results! # because we're forking, we will have a copy of the current results
|
49
|
+
|
48
50
|
expected.times do |count|
|
49
51
|
spec "fail ##{count + 1}" do
|
50
52
|
false
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
54
|
-
|
56
|
+
exit __uspec_cli.exit_code
|
55
57
|
end
|
56
58
|
actual = $?.exitstatus
|
57
59
|
|
@@ -60,11 +62,15 @@ end
|
|
60
62
|
|
61
63
|
spec 'if more than 255 failures, exit status is 255' do
|
62
64
|
capture do
|
65
|
+
__uspec_stats.clear_results! # because we're forking, we will have a copy of the current results
|
66
|
+
|
63
67
|
500.times do
|
64
68
|
spec 'fail' do
|
65
69
|
false
|
66
70
|
end
|
67
71
|
end
|
72
|
+
|
73
|
+
exit __uspec_cli.exit_code
|
68
74
|
end
|
69
75
|
|
70
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.2
|
4
|
+
version: 1.0.2
|
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-05-04 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,12 +62,12 @@ executables:
|
|
48
62
|
extensions: []
|
49
63
|
extra_rdoc_files: []
|
50
64
|
files:
|
65
|
+
- ".circleci/config.yml"
|
51
66
|
- ".editorconfig"
|
52
67
|
- ".gitignore"
|
53
68
|
- ".rubocop.yml"
|
54
69
|
- ".ruby-gemset"
|
55
70
|
- ".ruby-version"
|
56
|
-
- ".travis.yml"
|
57
71
|
- Gemfile
|
58
72
|
- LICENSE.txt
|
59
73
|
- README.markdown
|
@@ -93,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
107
|
- !ruby/object:Gem::Version
|
94
108
|
version: '0'
|
95
109
|
requirements: []
|
96
|
-
rubygems_version: 3.
|
110
|
+
rubygems_version: 3.2.15
|
97
111
|
signing_key:
|
98
112
|
specification_version: 4
|
99
113
|
summary: a shiny little spec framework for your apps!
|
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
|