uspec 0.3.0 → 1.0.0
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/README.markdown +1 -1
- 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 +20 -2
- data/lib/uspec/stats.rb +27 -21
- data/lib/uspec/version.rb +1 -1
- data/uspec/cli_spec.rb +2 -2
- data/uspec/uspec_spec.rb +5 -3
- metadata +2 -2
- 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: adfc4745c3e11f9afa82923366d86c5515745666b98606ded26418cb520b9bb9
|
4
|
+
data.tar.gz: b62be6efc2f67ba658c2701b6984764d7fdb36e0acc79f1e20378efeef1c534c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b89e9ab10352cbe0d18278c1d5aa823b72d3d9c40dbf49d0c2791b6f92748841d2018e6ac1ddee04016fa40c6353a76c94d8c6c7bfe11c7197a60606e38180b5
|
7
|
+
data.tar.gz: 51dc3f357ffff68b6e7ffc3d1a81376ad2755813490a2749e55bbcef6142ae3432f92076b7dcd5599625f55fb77ce6a8f099612972119bf90f24315e30d7f688
|
@@ -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/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?
|
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
|
+
self.class.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
@@ -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,
|
@@ -53,9 +55,9 @@ module Uspec
|
|
53
55
|
# Attempts to inspect an object
|
54
56
|
def inspector
|
55
57
|
if String === raw && raw.include?(?\n) then
|
56
|
-
# if object is a multiline string, display it
|
58
|
+
# if object is a multiline string, display it unescaped
|
57
59
|
[
|
58
|
-
|
60
|
+
vspace,
|
59
61
|
hspace, yellow('"""'), newline,
|
60
62
|
raw, normal, newline,
|
61
63
|
hspace, yellow('"""')
|
@@ -86,6 +88,22 @@ module Uspec
|
|
86
88
|
MSG
|
87
89
|
end
|
88
90
|
|
91
|
+
def success?
|
92
|
+
raw == true
|
93
|
+
end
|
94
|
+
|
95
|
+
def failure?
|
96
|
+
raw != true && !@pending
|
97
|
+
end
|
98
|
+
|
99
|
+
def pending?
|
100
|
+
!!@pending
|
101
|
+
end
|
102
|
+
|
103
|
+
def pending!
|
104
|
+
@pending = true
|
105
|
+
end
|
106
|
+
|
89
107
|
def inspect
|
90
108
|
"#{self.class} for `#{spec}` -> #{pretty}"
|
91
109
|
end
|
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/cli_spec.rb
CHANGED
@@ -12,7 +12,7 @@ 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
18
|
output.include?('I love passing tests') || output
|
@@ -21,7 +21,7 @@ end
|
|
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
27
|
output.include?('I love passing tests') || output
|
data/uspec/uspec_spec.rb
CHANGED
@@ -45,7 +45,7 @@ end
|
|
45
45
|
spec 'exit code is the number of failures' do
|
46
46
|
expected = 50
|
47
47
|
output = capture do
|
48
|
-
|
48
|
+
__uspec_stats.clear_results! # because we're forking, we will have a copy of the current results
|
49
49
|
|
50
50
|
expected.times do |count|
|
51
51
|
spec "fail ##{count + 1}" do
|
@@ -53,7 +53,7 @@ spec 'exit code is the number of failures' do
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
|
56
|
+
exit __uspec_cli.exit_code
|
57
57
|
end
|
58
58
|
actual = $?.exitstatus
|
59
59
|
|
@@ -62,13 +62,15 @@ end
|
|
62
62
|
|
63
63
|
spec 'if more than 255 failures, exit status is 255' do
|
64
64
|
capture do
|
65
|
-
|
65
|
+
__uspec_stats.clear_results! # because we're forking, we will have a copy of the current results
|
66
66
|
|
67
67
|
500.times do
|
68
68
|
spec 'fail' do
|
69
69
|
false
|
70
70
|
end
|
71
71
|
end
|
72
|
+
|
73
|
+
exit __uspec_cli.exit_code
|
72
74
|
end
|
73
75
|
|
74
76
|
$?.exitstatus == 255 || $?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uspec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony M. Cook
|
@@ -62,12 +62,12 @@ executables:
|
|
62
62
|
extensions: []
|
63
63
|
extra_rdoc_files: []
|
64
64
|
files:
|
65
|
+
- ".circleci/config.yml"
|
65
66
|
- ".editorconfig"
|
66
67
|
- ".gitignore"
|
67
68
|
- ".rubocop.yml"
|
68
69
|
- ".ruby-gemset"
|
69
70
|
- ".ruby-version"
|
70
|
-
- ".travis.yml"
|
71
71
|
- Gemfile
|
72
72
|
- LICENSE.txt
|
73
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
|