minitest-candy 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 +7 -0
- data/.github/workflows/ci.yml +29 -0
- data/.gitignore +9 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +91 -0
- data/Rakefile +11 -0
- data/lib/minitest/candy/assertions.rb +51 -0
- data/lib/minitest/candy/callbacks.rb +59 -0
- data/lib/minitest/candy/declarative.rb +28 -0
- data/lib/minitest/candy/version.rb +5 -0
- data/lib/minitest/candy.rb +27 -0
- data/minitest-candy.gemspec +24 -0
- data/test/candy_test.rb +31 -0
- data/test/test_helper.rb +4 -0
- metadata +76 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5c47c24552004733e311fb281724958f311787ae88b3fd938d241a5e0bc7d013
|
4
|
+
data.tar.gz: 76617ceaf124064e4b73cb3d380be02948e4ad19b080aff18285dc4d2106e82e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6b95bf869d8bd92bbb7e068a61ca842c9015526028d324fb0a4d6bb83755b91ad504b1eef4aa7be6b517052388c0b90ae5294bd20f828d2f1d0b1cd9dd212fd0
|
7
|
+
data.tar.gz: 1fc572626856a6c1dc97984d778f38be1c15db1c859882b47fabc9e2ffde3917c4274cfdc8d8107364d68b48bd3f0e081a94a88df663fa9ec59f4f7ea118b3e6
|
@@ -0,0 +1,29 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [main]
|
6
|
+
pull_request:
|
7
|
+
branches: [main]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
ruby-version: ['3.0']
|
15
|
+
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v2
|
18
|
+
|
19
|
+
- name: Set up Ruby
|
20
|
+
uses: ruby/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: ${{ matrix.ruby-version }}
|
23
|
+
bundler-cache: true
|
24
|
+
|
25
|
+
- name: Run tests
|
26
|
+
run: bundle exec rake test
|
27
|
+
|
28
|
+
- name: Run linter
|
29
|
+
run: bundle exec rake standard
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Francesco Rodríguez
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
minitest-candy 
|
2
|
+
==============
|
3
|
+
|
4
|
+
Useful helpers for Minitest 5+.
|
5
|
+
|
6
|
+
Installation
|
7
|
+
------------
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem "minitest-candy"
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
```
|
18
|
+
$ bundle
|
19
|
+
```
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
```
|
24
|
+
$ gem install minitest-candy
|
25
|
+
```
|
26
|
+
|
27
|
+
Usage
|
28
|
+
-----
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
require "minitest/autorun"
|
32
|
+
require "minitest/candy"
|
33
|
+
|
34
|
+
class TruthTest < Minitest::Test
|
35
|
+
# Adds support for `setup` and `teardown` callbacks:
|
36
|
+
setup do
|
37
|
+
@truth = true
|
38
|
+
end
|
39
|
+
|
40
|
+
teardown do
|
41
|
+
@truth = nil
|
42
|
+
end
|
43
|
+
|
44
|
+
# Define a test method using a String. Instead of
|
45
|
+
# `def test_assert_the_truth`, do:
|
46
|
+
test "assert the truth" do
|
47
|
+
assert @truth
|
48
|
+
end
|
49
|
+
|
50
|
+
# Includes extra assertions:
|
51
|
+
test "better assertions" do
|
52
|
+
assert_not false
|
53
|
+
assert_not_equal "1", "2"
|
54
|
+
assert_not_empty [1, 2, 3]
|
55
|
+
assert_nothing_raised do
|
56
|
+
super_secure_method()
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
```
|
61
|
+
|
62
|
+
Contributing
|
63
|
+
------------
|
64
|
+
|
65
|
+
Fork the project with:
|
66
|
+
|
67
|
+
```
|
68
|
+
$ git clone git@github.com:frodsan/minitest-candy.git
|
69
|
+
```
|
70
|
+
|
71
|
+
To install dependencies, use:
|
72
|
+
|
73
|
+
```
|
74
|
+
$ bundle install
|
75
|
+
```
|
76
|
+
|
77
|
+
To run the test suite, do:
|
78
|
+
|
79
|
+
```
|
80
|
+
$ rake test
|
81
|
+
```
|
82
|
+
|
83
|
+
For bug reports and pull requests use [GitHub][issues].
|
84
|
+
|
85
|
+
License
|
86
|
+
-------
|
87
|
+
|
88
|
+
This gem is released under the [MIT License][mit].
|
89
|
+
|
90
|
+
[mit]: http://www.opensource.org/licenses/MIT
|
91
|
+
[issues]: https://github.com/frodsan/minitest-candy/issues
|
data/Rakefile
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
module Minitest
|
2
|
+
module Candy
|
3
|
+
module Assertions
|
4
|
+
# Public: Asserts that an expression is not truthy. Passes if <tt>object</tt> is
|
5
|
+
# +nil+ or +false+. "Truthy" means "considered true in a conditional" like <tt>if foo</tt>.
|
6
|
+
#
|
7
|
+
# Examples
|
8
|
+
#
|
9
|
+
# require "minitest/autorun"
|
10
|
+
# require "minitest/candy"
|
11
|
+
#
|
12
|
+
# class AssertNotTest < Minitest::Test
|
13
|
+
# test "assert not" do
|
14
|
+
# assert_not nil # => true
|
15
|
+
# assert_not false # => true
|
16
|
+
# assert_not 'foo' # => Expected "foo" to be nil or false
|
17
|
+
# end
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# An error message can be specified.
|
21
|
+
#
|
22
|
+
# assert_not foo, 'foo should be false'
|
23
|
+
#
|
24
|
+
def assert_not(object, message = nil)
|
25
|
+
message ||= "Expected #{mu_pp(object)} to be nil or false"
|
26
|
+
assert !object, message
|
27
|
+
end
|
28
|
+
|
29
|
+
# Public: Asserts that the given block does not raise an exception.
|
30
|
+
#
|
31
|
+
# Examples
|
32
|
+
#
|
33
|
+
# require "minitest/autorun"
|
34
|
+
# require "minitest/candy"
|
35
|
+
#
|
36
|
+
# class AssertNotTest < Minitest::Test
|
37
|
+
# test "should not raise an exception" do
|
38
|
+
# assert_nothing_raised do
|
39
|
+
# perform_safe_operation()
|
40
|
+
# end
|
41
|
+
# end
|
42
|
+
# end
|
43
|
+
#
|
44
|
+
def assert_nothing_raised
|
45
|
+
yield
|
46
|
+
rescue => error
|
47
|
+
raise Minitest::UnexpectedError.new(error)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Minitest
|
2
|
+
module Candy
|
3
|
+
module Callbacks
|
4
|
+
# Public: Helper to define a +setup+ method.
|
5
|
+
#
|
6
|
+
# Examples
|
7
|
+
#
|
8
|
+
# require "minitest/autorun"
|
9
|
+
# require "minitest/candy"
|
10
|
+
#
|
11
|
+
# class TruthTest < Minitest::Test
|
12
|
+
# setup do
|
13
|
+
# @truth = true
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# test "assert the truth" do
|
17
|
+
# assert @truth
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
def setup(&block)
|
22
|
+
define_method(:setup) do
|
23
|
+
super()
|
24
|
+
|
25
|
+
instance_exec(&block)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Public: Helper to define a +teardown+ method.
|
30
|
+
#
|
31
|
+
# Examples
|
32
|
+
#
|
33
|
+
# require "minitest/autorun"
|
34
|
+
# require "minitest/candy"
|
35
|
+
#
|
36
|
+
# class TruthTest < Minitest::Test
|
37
|
+
# setup do
|
38
|
+
# @truth = true
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# teardown do
|
42
|
+
# @truth = nil
|
43
|
+
# end
|
44
|
+
#
|
45
|
+
# test "assert the truth" do
|
46
|
+
# assert @truth
|
47
|
+
# end
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
def teardown(&block)
|
51
|
+
define_method(:teardown) do
|
52
|
+
instance_exec(&block)
|
53
|
+
|
54
|
+
super()
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Minitest
|
2
|
+
module Candy
|
3
|
+
module Declarative
|
4
|
+
# Public: Helper to define a test method using a String.
|
5
|
+
#
|
6
|
+
# Examples
|
7
|
+
#
|
8
|
+
# require "minitest/autorun"
|
9
|
+
# require "minitest/candy"
|
10
|
+
#
|
11
|
+
# class TruthTest < Minitest::Test
|
12
|
+
# test "assert the truth" do
|
13
|
+
# assert true
|
14
|
+
# end
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
def test(name, &block)
|
18
|
+
test_name = sprintf("test_%s", name.gsub(/\s+/, "_"))
|
19
|
+
|
20
|
+
if method_defined?(test_name)
|
21
|
+
raise "#{ test_name } is already defined in #{ self }"
|
22
|
+
end
|
23
|
+
|
24
|
+
define_method(test_name, &block)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative "candy/declarative"
|
2
|
+
require_relative "candy/callbacks"
|
3
|
+
require_relative "candy/assertions"
|
4
|
+
|
5
|
+
module Minitest
|
6
|
+
class Test
|
7
|
+
extend Minitest::Candy::Declarative
|
8
|
+
extend Minitest::Candy::Callbacks
|
9
|
+
include Minitest::Candy::Assertions
|
10
|
+
|
11
|
+
# Prefer `assert_not_*`` than `refute_*``:
|
12
|
+
alias :assert_raise :assert_raises
|
13
|
+
alias :assert_not_empty :refute_empty
|
14
|
+
alias :assert_not_equal :refute_equal
|
15
|
+
alias :assert_not_in_delta :refute_in_delta
|
16
|
+
alias :assert_not_in_epsilon :refute_in_epsilon
|
17
|
+
alias :assert_not_includes :refute_includes
|
18
|
+
alias :assert_not_instance_of :refute_instance_of
|
19
|
+
alias :assert_not_kind_of :refute_kind_of
|
20
|
+
alias :assert_no_match :refute_match
|
21
|
+
alias :assert_not_nil :refute_nil
|
22
|
+
alias :assert_not_operator :refute_operator
|
23
|
+
alias :assert_not_predicate :refute_predicate
|
24
|
+
alias :assert_not_respond_to :refute_respond_to
|
25
|
+
alias :assert_not_same :refute_same
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require_relative "lib/minitest/candy/version"
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "minitest-candy"
|
5
|
+
spec.version = Minitest::Candy::VERSION
|
6
|
+
spec.authors = ["Francesco Rodriguez"]
|
7
|
+
spec.email = ["frodsan@me.com"]
|
8
|
+
|
9
|
+
spec.summary = "Enough sugar for your minitest diet"
|
10
|
+
spec.description = spec.summary
|
11
|
+
spec.homepage = "https://github.com/frodsan/vipps"
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
15
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
16
|
+
spec.metadata["changelog_uri"] = spec.homepage
|
17
|
+
|
18
|
+
spec.files = `git ls-files`.split("\n")
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}).map { |f| File.basename(f) }
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_dependency "minitest", ">= 5.0"
|
24
|
+
end
|
data/test/candy_test.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative "test_helper"
|
2
|
+
|
3
|
+
class MinitestCandyTest < Minitest::Test
|
4
|
+
setup do
|
5
|
+
@bar = "bar"
|
6
|
+
end
|
7
|
+
|
8
|
+
test "defines a friendly human description" do
|
9
|
+
assert true
|
10
|
+
end
|
11
|
+
|
12
|
+
test "raises if the name is already taken" do
|
13
|
+
self.class.test("name") {}
|
14
|
+
|
15
|
+
assert_raises(RuntimeError) do
|
16
|
+
self.class.test("name") {}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
test "assertions" do
|
21
|
+
assert_nothing_raised do
|
22
|
+
assert_not nil
|
23
|
+
assert_not false
|
24
|
+
assert_not_equal "1", "2"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
teardown do
|
29
|
+
assert_equal("bar", @bar)
|
30
|
+
end
|
31
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: minitest-candy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Francesco Rodriguez
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-09-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: minitest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.0'
|
27
|
+
description: Enough sugar for your minitest diet
|
28
|
+
email:
|
29
|
+
- frodsan@me.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".github/workflows/ci.yml"
|
35
|
+
- ".gitignore"
|
36
|
+
- Gemfile
|
37
|
+
- LICENSE.txt
|
38
|
+
- README.md
|
39
|
+
- Rakefile
|
40
|
+
- lib/minitest/candy.rb
|
41
|
+
- lib/minitest/candy/assertions.rb
|
42
|
+
- lib/minitest/candy/callbacks.rb
|
43
|
+
- lib/minitest/candy/declarative.rb
|
44
|
+
- lib/minitest/candy/version.rb
|
45
|
+
- minitest-candy.gemspec
|
46
|
+
- test/candy_test.rb
|
47
|
+
- test/test_helper.rb
|
48
|
+
homepage: https://github.com/frodsan/vipps
|
49
|
+
licenses:
|
50
|
+
- MIT
|
51
|
+
metadata:
|
52
|
+
homepage_uri: https://github.com/frodsan/vipps
|
53
|
+
source_code_uri: https://github.com/frodsan/vipps
|
54
|
+
changelog_uri: https://github.com/frodsan/vipps
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
requirements: []
|
70
|
+
rubygems_version: 3.2.26
|
71
|
+
signing_key:
|
72
|
+
specification_version: 4
|
73
|
+
summary: Enough sugar for your minitest diet
|
74
|
+
test_files:
|
75
|
+
- test/candy_test.rb
|
76
|
+
- test/test_helper.rb
|