uspec 0.2.3 → 0.3.0

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
  SHA256:
3
- metadata.gz: 37c36554e93d2f086beaa00114b033946c8d7fd059ad2436b08677321087e522
4
- data.tar.gz: 7b3fad4db3c6b602a338d29d98ffdfeb35b8a1f7bdf254595cb336900a623e0d
3
+ metadata.gz: 641541f23b26b9c14b11950c55f9161aa89142aa41b8627a9f2dcbe54ac11584
4
+ data.tar.gz: a02353485421133ac4fa3eb639a7942992152faee3db2f484da4da56917014d6
5
5
  SHA512:
6
- metadata.gz: 79f67326d2973ecf2a29868d9630cfae54d1cbd0f8f69458d2794e695b85a40db2876331b71a14a648235e7f0b5581a93249d0b4bfa8c8acfab899112655f4ae
7
- data.tar.gz: 8b4c7102bdfd0093b01c8a23bb8afd0fb098b74411d3aa9172a0c2515186456a9a925db16d51fe653a9955f1353b075b5cce5886e89df80da3ecde1a349f3b5d
6
+ metadata.gz: 1776508a0bc6ca4da5e90167072244305b9994b407d75fce53048bda6cad1a439adee75ecb0ddf534728f6ab6ad268a44588013a57f225df74f38a0e1c85a5c8
7
+ data.tar.gz: 1b39cb64033e21f466ee0a8edaea706e20589f92b3cbae80eb41e624c3dca9f24f1c376f277a7c5061f8b5d20608ea49cf1de71b9014409d4d5bc28b6d1ad702
data/README.markdown CHANGED
@@ -62,12 +62,12 @@ Or install it directly with:
62
62
  Quickstart
63
63
  ----------
64
64
 
65
- 0. Create a `spec` (or `uspec`) directory to keep your specs in.
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'` in their tests for shared code between tests.
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 `spec` and `uspec` directories and load any `*_spec.rb` files inside them.
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,7 +86,7 @@ usage: uspec [<file_or_path>...]
86
86
  Output
87
87
  ------
88
88
 
89
- Wonder what Uspec looks like?
89
+ A brief explanation of `uspec`'s output to show you what it can do!
90
90
 
91
91
  ### Success
92
92
 
@@ -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 reference documentation to look at, so here are some ideas to get you going!
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,6 +201,11 @@ 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
+ 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
+
204
209
  Assertions & Debugging
205
210
  ----------------------
206
211
 
@@ -224,7 +229,8 @@ end
224
229
  MyFoo.new.assert
225
230
  ```
226
231
 
227
- If there are any specs that fail, your application will exit with an error code equal to the number of failures.
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.
228
234
 
229
235
  ```
230
236
  $ ruby foo.rb
@@ -251,4 +257,4 @@ Contributing
251
257
  Author
252
258
  ------
253
259
 
254
- > Anthony M. Cook 2013-2019
260
+ > Anthony M. Cook 2013-2020
data/lib/uspec/result.rb CHANGED
@@ -28,7 +28,7 @@ module Uspec
28
28
  ].join
29
29
  else
30
30
  [
31
- red('Unknown Result'), vspace,
31
+ red('Failed'), vspace,
32
32
  hspace, 'Spec did not return a boolean value ', newline,
33
33
  hspace, 'in spec at ', source.first, vspace,
34
34
  hspace, red(subklassinfo), inspector, newline
@@ -52,7 +52,17 @@ module Uspec
52
52
 
53
53
  # Attempts to inspect an object
54
54
  def inspector
55
- handler.inspector!
55
+ if String === raw && raw.include?(?\n) then
56
+ # if object is a multiline string, display it escaped and unescaped
57
+ [
58
+ handler.inspector!, vspace,
59
+ hspace, yellow('"""'), newline,
60
+ raw, normal, newline,
61
+ hspace, yellow('"""')
62
+ ].join
63
+ else
64
+ handler.inspector!
65
+ end
56
66
  rescue Exception => error
57
67
  return handler.simple_inspector if error.message.include? handler.get_id
58
68
 
data/lib/uspec/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Uspec
2
- VERSION = '0.2.3'
2
+ VERSION = '0.3.0'
3
3
  end
data/uspec/cli_spec.rb CHANGED
@@ -15,7 +15,7 @@ spec 'runs a path of specs' do
15
15
  Uspec::CLI.run_specs Array(path)
16
16
  end
17
17
 
18
- output.include? 'I love passing tests'
18
+ output.include?('I love passing tests') || output
19
19
  end
20
20
 
21
21
  spec 'runs an individual spec' do
@@ -24,7 +24,7 @@ spec 'runs an individual spec' do
24
24
  Uspec::CLI.run_specs Array(path)
25
25
  end
26
26
 
27
- output.include? 'I love passing tests'
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
@@ -17,7 +17,29 @@ spec "ensure BasicObject subclasses work" do
17
17
  result = Uspec::Result.new "BasicObject Subclass Result", obj, []
18
18
  expected = "#<BasicObject/TestObject:"
19
19
  actual = result.pretty
20
- actual.include?(expected) || result.inspector
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]
@@ -38,3 +60,11 @@ spec "display a useful error message when a user-defined inspect method fails" d
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
@@ -27,7 +27,7 @@ spec 'complains when spec block returns non boolean' do
27
27
  end
28
28
  end
29
29
 
30
- output.include? 'Unknown Result'
30
+ output.include? 'Failed'
31
31
  end
32
32
 
33
33
  spec 'marks test as pending when no block supplied' do
@@ -45,6 +45,8 @@ 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
@@ -60,6 +62,8 @@ 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
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
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: 2019-06-19 00:00:00.000000000 Z
11
+ date: 2021-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: that_object_is_so_basic