minitest-bonus-assertions 1.0 → 2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -4
- data/Code-of-Conduct.rdoc +41 -0
- data/History.rdoc +30 -0
- data/Manifest.txt +2 -1
- data/README.rdoc +33 -16
- data/Rakefile +3 -2
- data/lib/minitest-bonus-assertions.rb +64 -9
- data/lib/minitest/assertion_tests.rb +56 -0
- data/test/minitest_config.rb +1 -34
- data/test/test_minitest-bonus-assertions.rb +155 -90
- metadata +15 -10
- data/VERSION +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bb8c4387ba54e4575d49e45cd8103bc70b1ea4c
|
4
|
+
data.tar.gz: 6cd36802e22704ea0e698352589392d19d140c6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 587007bba2f0d47fed2ab3559b0a244cc2077c2c502a3c9a38fdd1fa756ec00d58f28713421138f84affdc89a52ec1cd65da72dde93cbd695666e80bbfd1dec7
|
7
|
+
data.tar.gz: b6773e5c6bb397bc4299864f3781a2b74a12232de8d43d3c25b4be3f0bc5655983439f0ddc527a9053021020b430abd81c6c1b8e83c463207dd47da62314bec6
|
data/.travis.yml
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
---
|
2
2
|
language: ruby
|
3
3
|
rvm:
|
4
|
-
- 2.2.
|
5
|
-
- 2.1.
|
6
|
-
- 2.0.0
|
7
|
-
- 1.9.3
|
4
|
+
- 2.2.3
|
5
|
+
- 2.1.7
|
6
|
+
- 2.0.0-p647
|
8
7
|
- ruby-head
|
8
|
+
- jruby-9.0
|
9
9
|
- jruby-19mode
|
10
10
|
- jruby-head
|
11
11
|
- rbx-2
|
12
12
|
matrix:
|
13
13
|
allow_failures:
|
14
|
+
- rvm: 1.9.3
|
14
15
|
- rvm: rbx-2
|
15
16
|
- rvm: jruby-head
|
16
17
|
- rvm: ruby-head
|
@@ -33,3 +34,4 @@ notifications:
|
|
33
34
|
- halostatue@gmail.com
|
34
35
|
on_success: change
|
35
36
|
on_failure: always
|
37
|
+
sudo: false
|
@@ -0,0 +1,41 @@
|
|
1
|
+
== Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct.
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct. By adopting this Code of Conduct,
|
26
|
+
project maintainers commit themselves to fairly and consistently applying these
|
27
|
+
principles to every aspect of managing this project. Project maintainers who do
|
28
|
+
not follow or enforce the Code of Conduct may be permanently removed from the
|
29
|
+
project team.
|
30
|
+
|
31
|
+
This code of conduct applies both within project spaces and in public spaces
|
32
|
+
when an individual is representing the project or its community.
|
33
|
+
|
34
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
35
|
+
reported by opening an issue or contacting one or more of the project
|
36
|
+
maintainers.
|
37
|
+
|
38
|
+
This Code of Conduct is adapted from the
|
39
|
+
{Contributor Covenant}[http://contributor-covenant.org], version 1.2.0,
|
40
|
+
available at
|
41
|
+
{http://contributor-covenant.org/version/1/2/0/}[http://contributor-covenant.org/version/1/2/0/].
|
data/History.rdoc
CHANGED
@@ -1,3 +1,33 @@
|
|
1
|
+
=== 2.0 / 2015-10-19
|
2
|
+
|
3
|
+
* 1 major enhancement
|
4
|
+
|
5
|
+
* Added Minitest::AssertionTests to assist with testing newly added
|
6
|
+
assertions, even for other gems. Previously, a variant of what is provided
|
7
|
+
was present in +test/minitest_config.rb+.
|
8
|
+
|
9
|
+
* 2 minor enhancements
|
10
|
+
|
11
|
+
* Made the expectation +must_be_between+ ready for the next version of
|
12
|
+
Minitest by calling +assert_between+ on the test context (+ctx+) rather
|
13
|
+
than on the bare object under test. Because of this change,
|
14
|
+
minitest-bonus-assertions is now tested for compatibility only with
|
15
|
+
minitest 5.8 or higher.
|
16
|
+
|
17
|
+
* Added +assert_set_equal+ and +refute_set_equal+ (with expectation forms of
|
18
|
+
+must_equal_set+ and +must_not_equal_set+) to test enumerable values for
|
19
|
+
set equality.
|
20
|
+
|
21
|
+
* 1 minor bugfix
|
22
|
+
|
23
|
+
* The documentation for +assert_between+ was unclear; it is a
|
24
|
+
boundary-exclusive test, not a boundary-inclusive test. That is, it is
|
25
|
+
<tt>lo < exp < hi</tt>, not <tt>lo <= exp <= hi</tt>.
|
26
|
+
|
27
|
+
* 1 governance change
|
28
|
+
|
29
|
+
* This project now has a {Code of Conduct}[Code-of-Conduct_rdoc.html]
|
30
|
+
|
1
31
|
=== 1.0 / 2015-03-05
|
2
32
|
|
3
33
|
* 1 major enhancement
|
data/Manifest.txt
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
.minitest.rb
|
5
5
|
.travis.yml
|
6
6
|
.workenv
|
7
|
+
Code-of-Conduct.rdoc
|
7
8
|
Contributing.rdoc
|
8
9
|
Gemfile
|
9
10
|
History.rdoc
|
@@ -11,7 +12,7 @@ Licence.rdoc
|
|
11
12
|
Manifest.txt
|
12
13
|
README.rdoc
|
13
14
|
Rakefile
|
14
|
-
VERSION
|
15
15
|
lib/minitest-bonus-assertions.rb
|
16
|
+
lib/minitest/assertion_tests.rb
|
16
17
|
test/minitest_config.rb
|
17
18
|
test/test_minitest-bonus-assertions.rb
|
data/README.rdoc
CHANGED
@@ -6,41 +6,56 @@ continuous integration :: {<img src="https://travis-ci.org/halostatue/minitest-b
|
|
6
6
|
|
7
7
|
== Description
|
8
8
|
|
9
|
-
|
9
|
+
Bonus assertions for {Minitest}[https://github.com/seattlerb/minitest],
|
10
|
+
providing assertions I use frequently.
|
10
11
|
|
11
12
|
== Features
|
12
13
|
|
13
14
|
New assertions:
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
* +assert_false+: requires that the value be exactly +false+. (+must_be_false+)
|
17
|
+
* +assert_true+: requires that the value be exactly +true+. (+must_be_true+)
|
18
|
+
* +assert_between+: requires that the value be strictly between the low and
|
19
|
+
high values provided, or the range (this test is boundary-exclusive).
|
20
|
+
(+must_be_between+)
|
21
|
+
* +assert_has_keys+/+refute_missing_keys+: requires that the object contains all
|
22
|
+
of the keys expected. (+must_have_keys+)
|
23
|
+
* +assert_missing_keys+/+refute_has_keys+: requires that the object *not* have
|
24
|
+
any of the keys expected. (+must_not_have_keys+)
|
25
|
+
* +assert_raises_with_message+: requires that the exception raised in the
|
26
|
+
provided block has a specific message (tested with +assert_equal+).
|
27
|
+
(+must_raise_with_message+)
|
28
|
+
* +assert_set_equal+: requires that the actual enumerable have the same values
|
29
|
+
as the expected enumerable, without regard to order and ignoring duplicate
|
30
|
+
values. (+must_equal_set+)
|
31
|
+
* +refute_set_equal+: requires that the actual enumerable *not* have the same
|
32
|
+
values as the expected enumerable. (+must_not_equal_set+)
|
33
|
+
|
34
|
+
I am also providing the Minitest-tester code I use as something that can be
|
35
|
+
required by other developers. This should *only* be used to test Minitest
|
36
|
+
assertions and extensions. For more information on Minitest::AssertionTests,
|
37
|
+
see its documentation.
|
21
38
|
|
22
39
|
== Background
|
23
40
|
|
24
|
-
minitest-bonus-assertions started life as a patch to
|
25
|
-
Ben Somer’s
|
41
|
+
minitest-bonus-assertions started life as a patch to Ben Somer’s
|
26
42
|
{minitest-extra-assertions}[https://github.com/bensomers/minitest-extra-assertions].
|
27
43
|
There were some nice assertions included, but there were other changes that
|
28
44
|
needed to be made to bring it up to support Minitest 5. There was also an
|
29
45
|
override to the default +assert_match+ implementation meant to ease the
|
30
46
|
transition from Test::Unit (the main reason he wrote this assertion plugin for
|
31
47
|
Minitest in the first place). I do not believe this is sensible five major
|
32
|
-
versions
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
Ben for writing these assertions in the first place.
|
48
|
+
versions into Minitest: I removed it. Ben did not feel comfortable making this
|
49
|
+
particular change, so I felt that the best way to provide the original
|
50
|
+
assertions and my new assertions—without the +assert_match+ override—was to
|
51
|
+
fork this as a new project. I am indebted to Ben and his contributors for
|
52
|
+
writing these assertions in the first place.
|
38
53
|
|
39
54
|
== Install
|
40
55
|
|
41
56
|
Add it to your Gemfile:
|
42
57
|
|
43
|
-
gem 'minitest-bonus-assertions', '~> 1.
|
58
|
+
gem 'minitest-bonus-assertions', '~> 1.1'
|
44
59
|
|
45
60
|
Or manually install:
|
46
61
|
|
@@ -53,6 +68,8 @@ scheme with one change:
|
|
53
68
|
|
54
69
|
* When PATCH is zero (+0+), it will be omitted from version references.
|
55
70
|
|
71
|
+
:include: Code-of-Conduct.rdoc
|
72
|
+
|
56
73
|
:include: Contributing.rdoc
|
57
74
|
|
58
75
|
:include: Licence.rdoc
|
data/Rakefile
CHANGED
@@ -16,7 +16,8 @@ spec = Hoe.spec 'minitest-bonus-assertions' do
|
|
16
16
|
|
17
17
|
self.history_file = 'History.rdoc'
|
18
18
|
self.readme_file = 'README.rdoc'
|
19
|
-
self.extra_rdoc_files = FileList["*.rdoc"].to_a
|
19
|
+
self.extra_rdoc_files = FileList["*.rdoc"].to_a -
|
20
|
+
%w(History.rdoc README.rdoc)
|
20
21
|
|
21
22
|
license "MIT"
|
22
23
|
|
@@ -27,7 +28,7 @@ spec = Hoe.spec 'minitest-bonus-assertions' do
|
|
27
28
|
self.extra_dev_deps << ['hoe-gemspec2', '~> 1.1']
|
28
29
|
self.extra_dev_deps << ['hoe-git', '~> 1.5']
|
29
30
|
self.extra_dev_deps << ['hoe-travis', '~> 1.2']
|
30
|
-
self.extra_dev_deps << ['minitest', '~> 5.
|
31
|
+
self.extra_dev_deps << ['minitest', '~> 5.8']
|
31
32
|
self.extra_dev_deps << ['minitest-around', '~> 0.3']
|
32
33
|
self.extra_dev_deps << ['minitest-autotest', '~> 1.0']
|
33
34
|
self.extra_dev_deps << ['minitest-bisect', '~> 1.2']
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module Minitest
|
2
|
-
module BonusAssertions
|
3
|
-
VERSION = '
|
2
|
+
module BonusAssertions # :nodoc:
|
3
|
+
VERSION = '2.0' # :nodoc:
|
4
4
|
end
|
5
|
+
|
5
6
|
module Assertions
|
6
7
|
##
|
7
8
|
# Fails unless +obj+ is literally +false+.
|
@@ -20,14 +21,23 @@ module Minitest
|
|
20
21
|
end
|
21
22
|
|
22
23
|
##
|
23
|
-
# Fails unless +exp+ is between +lo+ and +hi+, or is in +range+.
|
24
|
+
# Fails unless +exp+ is between +lo+ and +hi+, or is in +range+. This test
|
25
|
+
# is exclusive of the boundaries. That is:
|
26
|
+
#
|
27
|
+
# assert_between 1, 10, 1
|
28
|
+
#
|
29
|
+
# will return false, but:
|
30
|
+
#
|
31
|
+
# assert_between 0.99, 10.1, 1
|
32
|
+
#
|
33
|
+
# will return true.
|
24
34
|
#
|
25
35
|
# :call-seq:
|
26
36
|
# assert_between lo, hi, exp, msg = nil
|
27
37
|
# assert_between range, exp, msg = nil
|
28
38
|
|
29
39
|
def assert_between(*args)
|
30
|
-
lo, hi, exp, msg = if args.first.
|
40
|
+
lo, hi, exp, msg = if args.first.kind_of?(Range)
|
31
41
|
[args.first.begin, args.first.end, args[1], args[2]]
|
32
42
|
else
|
33
43
|
args[0..3]
|
@@ -39,8 +49,9 @@ module Minitest
|
|
39
49
|
|
40
50
|
##
|
41
51
|
# Fails unless +obj+ has all of the +keys+ listed.
|
52
|
+
|
42
53
|
def assert_has_keys obj, keys, msg = nil
|
43
|
-
keys = [ keys ] unless keys.
|
54
|
+
keys = [ keys ] unless keys.kind_of?(Array)
|
44
55
|
msg = message(msg) { "Expected #{mu_pp(obj)} to include all keys #{mu_pp(keys)}" }
|
45
56
|
keys.all? { |key| assert obj.key?(key), msg }
|
46
57
|
end
|
@@ -48,9 +59,12 @@ module Minitest
|
|
48
59
|
|
49
60
|
##
|
50
61
|
# Fails if +obj+ has any of the keys listed.
|
62
|
+
|
51
63
|
def assert_missing_keys obj, keys, msg = nil
|
52
|
-
keys = [ keys ] unless keys.
|
53
|
-
msg = message(msg) {
|
64
|
+
keys = [ keys ] unless keys.kind_of?(Array)
|
65
|
+
msg = message(msg) {
|
66
|
+
"Expected #{mu_pp(obj)} not to include any of these keys #{mu_pp(keys)}"
|
67
|
+
}
|
54
68
|
keys.none? { |key| refute obj.key?(key), msg }
|
55
69
|
end
|
56
70
|
alias_method :refute_has_keys, :assert_missing_keys
|
@@ -58,6 +72,7 @@ module Minitest
|
|
58
72
|
##
|
59
73
|
# Fails unless the block raises +exp+ with the message +exp_msg+. Returns
|
60
74
|
# the exception matched so you can check other attributes.
|
75
|
+
|
61
76
|
def assert_raises_with_message exp, exp_msg, msg = nil
|
62
77
|
msg = message(msg) { "#{mu_pp(exp)} exception expected with message #{mu_pp(exp_msg)}" }
|
63
78
|
|
@@ -68,6 +83,28 @@ module Minitest
|
|
68
83
|
assert_equal exp_msg, exception.message, msg
|
69
84
|
exception
|
70
85
|
end
|
86
|
+
|
87
|
+
##
|
88
|
+
# Fails unless the set from +actual+ matches the set from +exp+.
|
89
|
+
|
90
|
+
def assert_set_equal expected, actual, msg = nil
|
91
|
+
require 'set'
|
92
|
+
msg = message(msg) {
|
93
|
+
"Expected #{mu_pp(actual)} to be set equivalent to #{mu_pp(expected)}"
|
94
|
+
}
|
95
|
+
assert_equal Set.new(expected), Set.new(actual), msg
|
96
|
+
end
|
97
|
+
|
98
|
+
##
|
99
|
+
# Fails unless the set from +actual+ differs from the set from +exp+.
|
100
|
+
|
101
|
+
def refute_set_equal expected, actual, msg = nil
|
102
|
+
require 'set'
|
103
|
+
msg = message(msg) {
|
104
|
+
"Expected #{mu_pp(actual)} not to be set equivalent to #{mu_pp(expected)}"
|
105
|
+
}
|
106
|
+
refute_equal Set.new(expected), Set.new(actual), msg
|
107
|
+
end
|
71
108
|
end
|
72
109
|
|
73
110
|
module Expectations
|
@@ -96,12 +133,12 @@ module Minitest
|
|
96
133
|
# 2.must_be_between 1..3
|
97
134
|
|
98
135
|
def must_be_between *args
|
99
|
-
hi, lo, msg = if args.first.
|
136
|
+
hi, lo, msg = if args.first.kind_of?(Range)
|
100
137
|
[args.first.begin, args.first.end, args[1]]
|
101
138
|
else
|
102
139
|
args[0..2]
|
103
140
|
end
|
104
|
-
assert_between lo, hi,
|
141
|
+
ctx.assert_between lo, hi, target, msg
|
105
142
|
end
|
106
143
|
|
107
144
|
##
|
@@ -130,5 +167,23 @@ module Minitest
|
|
130
167
|
# :method: must_raise_with_message
|
131
168
|
|
132
169
|
infect_an_assertion :assert_raises_with_message, :must_raise_with_message
|
170
|
+
|
171
|
+
##
|
172
|
+
# See Minitest::Assertions#assert_set_equal
|
173
|
+
#
|
174
|
+
# %w(a b c).must_equal_set %(c b a)
|
175
|
+
#
|
176
|
+
# :method: must_equal_set
|
177
|
+
|
178
|
+
infect_an_assertion :assert_set_equal, :must_equal_set, :unary
|
179
|
+
|
180
|
+
##
|
181
|
+
# See Minitest::refuteions#refute_set_equal
|
182
|
+
#
|
183
|
+
# %w(a b c).must_equal_set %(c b a)
|
184
|
+
#
|
185
|
+
# :method: must_equal_set
|
186
|
+
|
187
|
+
infect_an_assertion :refute_set_equal, :must_not_equal_set, :unary
|
133
188
|
end
|
134
189
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
##
|
2
|
+
# Use Minitest::AssertionTests to test assertions for Minitest.
|
3
|
+
#
|
4
|
+
# describe Minitest::BonusAssertions do
|
5
|
+
# include Minitest::AssertionTests
|
6
|
+
#
|
7
|
+
# it 'be triggered for false or nil' do
|
8
|
+
# assert_expected_assertions 2 do
|
9
|
+
# assert_assertion_triggered '<true> expected but was false.' do
|
10
|
+
# tc.assert_true false
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# assert_assertion_triggered '<true> expected but was nil.' do
|
14
|
+
# tc.assert_true nil
|
15
|
+
# end
|
16
|
+
# end
|
17
|
+
# end
|
18
|
+
# end
|
19
|
+
module Minitest::AssertionTests
|
20
|
+
# The test case to use for the assertion under test.
|
21
|
+
attr_reader :tc
|
22
|
+
# The test spec to use for the expectation under test.
|
23
|
+
attr_reader :spec
|
24
|
+
|
25
|
+
def setup # :nodoc:
|
26
|
+
super
|
27
|
+
|
28
|
+
Minitest::Test.reset
|
29
|
+
|
30
|
+
@tc = Minitest::Test.new 'fake test case'
|
31
|
+
@spec = Minitest::Spec.new 'fake test spec'
|
32
|
+
end
|
33
|
+
|
34
|
+
# Specify the number of assertions that should be called during the test
|
35
|
+
# under this block. Most tests should be wrapped in this assertion.
|
36
|
+
def assert_expected_assertions expected = 1
|
37
|
+
yield
|
38
|
+
ensure
|
39
|
+
actual = tc.assertions + spec.assertions
|
40
|
+
assert_equal expected, actual, "expected #{expected} assertions to be " +
|
41
|
+
"fired during the test, not #{actual}"
|
42
|
+
end
|
43
|
+
|
44
|
+
# Specify that the assertion was expected to fail with the resulting message.
|
45
|
+
def assert_assertion_triggered expected, klass = Minitest::Assertion
|
46
|
+
e = assert_raises(klass) do
|
47
|
+
yield
|
48
|
+
end
|
49
|
+
|
50
|
+
msg = e.message.sub(/(---Backtrace---).*/m, '\1')
|
51
|
+
msg.gsub!(/\(oid=[-0-9]+\)/, '(oid=N)')
|
52
|
+
msg.gsub!(/(\d\.\d{6})\d+/, '\1xxx') # normalize: ruby version, impl, platform
|
53
|
+
|
54
|
+
assert_equal expected, msg
|
55
|
+
end
|
56
|
+
end
|
data/test/minitest_config.rb
CHANGED
@@ -6,37 +6,4 @@ require 'minitest/moar'
|
|
6
6
|
require 'minitest/bisect'
|
7
7
|
|
8
8
|
require 'minitest-bonus-assertions'
|
9
|
-
|
10
|
-
module Minitest::AssertionTester
|
11
|
-
def setup
|
12
|
-
super
|
13
|
-
|
14
|
-
Minitest::Test.reset
|
15
|
-
|
16
|
-
@tc = Minitest::Test.new 'fake tc'
|
17
|
-
@zomg = "zomg ponies!"
|
18
|
-
@assertion_count = 1
|
19
|
-
end
|
20
|
-
|
21
|
-
def teardown
|
22
|
-
if @tc.assertions
|
23
|
-
assert_equal @assertion_count, @tc.assertions,
|
24
|
-
"expected #{@assertion_count} assertions to be fired during the test, not #{@tc.assertions}"
|
25
|
-
end
|
26
|
-
Object.send(:remove_const, :ATestCase) if defined? ATestCase
|
27
|
-
end
|
28
|
-
|
29
|
-
def util_assert_triggered expected, klass = Minitest::Assertion
|
30
|
-
e = assert_raises(klass) do
|
31
|
-
yield
|
32
|
-
end
|
33
|
-
|
34
|
-
msg = e.message.sub(/(---Backtrace---).*/m, '\1')
|
35
|
-
msg.gsub!(/\(oid=[-0-9]+\)/, '(oid=N)')
|
36
|
-
msg.gsub!(/(\d\.\d{6})\d+/, '\1xxx') # normalize: ruby version, impl, platform
|
37
|
-
|
38
|
-
assert_equal expected, msg
|
39
|
-
end
|
40
|
-
|
41
|
-
Minitest::Test.send(:include, self)
|
42
|
-
end
|
9
|
+
require 'minitest/assertion_tests'
|
@@ -3,160 +3,225 @@
|
|
3
3
|
require 'minitest_config'
|
4
4
|
|
5
5
|
describe Minitest::BonusAssertions do
|
6
|
-
|
7
|
-
it "return true for true" do
|
8
|
-
@assertion_count = 1
|
6
|
+
include Minitest::AssertionTests
|
9
7
|
|
10
|
-
|
8
|
+
describe '.assert_true' do
|
9
|
+
it 'return true for true' do
|
10
|
+
assert_expected_assertions do
|
11
|
+
assert_equal true, tc.assert_true(true), 'returns true for true'
|
12
|
+
end
|
11
13
|
end
|
12
14
|
|
13
|
-
it
|
14
|
-
|
15
|
+
it 'be triggered for false or nil' do
|
16
|
+
assert_expected_assertions 2 do
|
17
|
+
assert_assertion_triggered '<true> expected but was false.' do
|
18
|
+
tc.assert_true false
|
19
|
+
end
|
15
20
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
util_assert_triggered "<true> expected but was nil." do
|
20
|
-
@tc.assert_true nil
|
21
|
+
assert_assertion_triggered '<true> expected but was nil.' do
|
22
|
+
tc.assert_true nil
|
23
|
+
end
|
21
24
|
end
|
22
25
|
end
|
23
26
|
|
24
|
-
it
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
it %q(be triggered for things that aren't true but evaluate to true) do
|
28
|
+
assert_expected_assertions do
|
29
|
+
assert_assertion_triggered '<true> expected but was Object.' do
|
30
|
+
tc.assert_true Object
|
31
|
+
end
|
29
32
|
end
|
30
33
|
end
|
31
34
|
end
|
32
35
|
|
33
|
-
describe
|
34
|
-
it
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
describe '.assert_false' do
|
37
|
+
it 'return true for false' do
|
38
|
+
assert_expected_assertions do
|
39
|
+
assert_equal true, tc.assert_false(false), 'returns true for false'
|
40
|
+
end
|
38
41
|
end
|
39
42
|
|
40
|
-
it
|
41
|
-
|
43
|
+
it 'be triggered for nil' do
|
44
|
+
assert_expected_assertions do
|
45
|
+
assert_assertion_triggered '<false> expected but was nil.' do
|
46
|
+
tc.assert_false nil
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
42
50
|
|
43
|
-
|
44
|
-
|
51
|
+
it 'be triggered for things that evalute to true' do
|
52
|
+
assert_expected_assertions do
|
53
|
+
assert_assertion_triggered '<false> expected but was Object.' do
|
54
|
+
tc.assert_false Object
|
55
|
+
end
|
45
56
|
end
|
46
57
|
end
|
58
|
+
end
|
47
59
|
|
48
|
-
|
49
|
-
|
60
|
+
describe '.assert_between' do
|
61
|
+
it 'return true for basic integers' do
|
62
|
+
assert_expected_assertions do
|
63
|
+
assert_equal true, tc.assert_between(1, 10, 5), 'returns true for 1 to 10 and 5'
|
64
|
+
end
|
65
|
+
end
|
50
66
|
|
51
|
-
|
52
|
-
|
67
|
+
it 'return true for the range case' do
|
68
|
+
assert_expected_assertions do
|
69
|
+
assert_equal true, tc.assert_between((1..10), 5), 'returns true for 1..10 with 5'
|
53
70
|
end
|
54
71
|
end
|
55
|
-
end
|
56
72
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
73
|
+
it 'handle the case where the hi part is first' do
|
74
|
+
assert_expected_assertions do
|
75
|
+
assert_equal true, tc.assert_between(10, 1, 5), 'returns true for 10 to 1, with 5'
|
76
|
+
end
|
61
77
|
end
|
62
78
|
|
63
|
-
it
|
64
|
-
|
65
|
-
|
79
|
+
it 'return false for values outside the bounds' do
|
80
|
+
assert_expected_assertions do
|
81
|
+
assert_assertion_triggered 'Expected 100 to be between 1 and 10.' do
|
82
|
+
tc.assert_between(1, 10, 100)
|
83
|
+
end
|
84
|
+
end
|
66
85
|
end
|
67
86
|
|
68
|
-
it
|
69
|
-
|
70
|
-
|
87
|
+
it 'returns false for values strictly on the bounds' do
|
88
|
+
assert_expected_assertions do
|
89
|
+
assert_assertion_triggered 'Expected 1 to be between 1 and 10.' do
|
90
|
+
tc.assert_between(1, 10, 1)
|
91
|
+
end
|
92
|
+
end
|
71
93
|
end
|
72
94
|
|
73
|
-
it
|
74
|
-
|
75
|
-
|
76
|
-
|
95
|
+
it 'raise error for incompatible values' do
|
96
|
+
assert_expected_assertions 0 do
|
97
|
+
assert_raises ArgumentError do
|
98
|
+
tc.assert_between(1, 10, Time.now)
|
99
|
+
end
|
77
100
|
end
|
78
101
|
end
|
79
102
|
|
80
|
-
it
|
81
|
-
|
82
|
-
|
83
|
-
@tc.assert_between(1, 10, Time.now)
|
103
|
+
it 'works correctly with the new expectation format' do
|
104
|
+
assert_expected_assertions do
|
105
|
+
assert_equal true, spec._(5).must_be_between(1, 10)
|
84
106
|
end
|
85
107
|
end
|
86
108
|
end
|
87
109
|
|
88
|
-
describe
|
89
|
-
it
|
90
|
-
|
91
|
-
|
110
|
+
describe '.assert_has_keys' do
|
111
|
+
it 'return true if the keys are present' do
|
112
|
+
assert_expected_assertions do
|
113
|
+
assert_equal true, tc.assert_has_keys({ 'a' => 1 }, 'a'),
|
114
|
+
%q(returns true for key 'a' in { 'a' => 1 })
|
115
|
+
end
|
92
116
|
end
|
93
117
|
|
94
|
-
it
|
95
|
-
|
96
|
-
hash = { "a" => 1 }
|
118
|
+
it 'be triggered for a missing value' do
|
119
|
+
hash = { 'a' => 1 }
|
97
120
|
keys = %w(a b)
|
98
|
-
|
99
|
-
|
121
|
+
assert_expected_assertions 2 do
|
122
|
+
assert_assertion_triggered %Q(Expected #{mu_pp(hash)} to include all keys #{mu_pp(keys)}.) do
|
123
|
+
tc.assert_has_keys(hash, keys)
|
124
|
+
end
|
100
125
|
end
|
101
126
|
end
|
102
127
|
|
103
|
-
it
|
104
|
-
|
105
|
-
|
106
|
-
|
128
|
+
it 'raise error for incompatible values' do
|
129
|
+
assert_expected_assertions 0 do
|
130
|
+
assert_raises NoMethodError do
|
131
|
+
tc.assert_has_keys([], 'a')
|
132
|
+
end
|
107
133
|
end
|
108
134
|
end
|
109
135
|
end
|
110
136
|
|
111
|
-
describe
|
112
|
-
it
|
113
|
-
|
114
|
-
|
137
|
+
describe '.assert_missing_keys' do
|
138
|
+
it 'return true if the keys are missing' do
|
139
|
+
assert_expected_assertions do
|
140
|
+
assert_equal true, tc.assert_missing_keys({ 'a' => 1 }, 'b'),
|
141
|
+
%q(returns true for key 'b' missing from { 'a' => 1 })
|
142
|
+
end
|
115
143
|
end
|
116
144
|
|
117
|
-
it
|
118
|
-
|
119
|
-
hash = { "a" => 1 }
|
145
|
+
it 'be triggered for a present value' do
|
146
|
+
hash = { 'a' => 1 }
|
120
147
|
keys = %w(a b)
|
121
|
-
|
122
|
-
|
148
|
+
assert_expected_assertions do
|
149
|
+
assert_assertion_triggered %Q(Expected #{mu_pp(hash)} not to include any of these keys #{mu_pp(keys)}.) do
|
150
|
+
tc.assert_missing_keys(hash, keys)
|
151
|
+
end
|
123
152
|
end
|
124
153
|
end
|
125
154
|
|
126
|
-
it
|
127
|
-
|
128
|
-
|
129
|
-
|
155
|
+
it 'raise error for incompatible values' do
|
156
|
+
assert_expected_assertions 0 do
|
157
|
+
assert_raises NoMethodError do
|
158
|
+
tc.assert_missing_keys([], 'a')
|
159
|
+
end
|
130
160
|
end
|
131
161
|
end
|
132
162
|
end
|
133
163
|
|
134
|
-
describe
|
135
|
-
it
|
136
|
-
|
164
|
+
describe '.assert_raises_with_message' do
|
165
|
+
it 'return the matched exception if the exception and message match' do
|
166
|
+
assert_expected_assertions 2 do
|
167
|
+
res = tc.assert_raises_with_message(ArgumentError, %q(Don't have a cow, man!)) do
|
168
|
+
raise ArgumentError, %q(Don't have a cow, man!)
|
169
|
+
end
|
137
170
|
|
138
|
-
|
139
|
-
raise ArgumentError, "Don't have a cow, man!"
|
171
|
+
assert_kind_of ArgumentError, res
|
140
172
|
end
|
173
|
+
end
|
141
174
|
|
142
|
-
|
175
|
+
it 'is triggered with a different exception' do
|
176
|
+
assert_expected_assertions do
|
177
|
+
assert_assertion_triggered %Q(#{mu_pp([ArgumentError])} exception expected, not\nClass: <NoMethodError>\nMessage: <"NoMethodError">\n---Backtrace---) do
|
178
|
+
tc.assert_raises_with_message(ArgumentError, 'Don’t have a cow, man!') do
|
179
|
+
raise NoMethodError
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
143
183
|
end
|
144
184
|
|
145
|
-
it
|
146
|
-
|
185
|
+
it 'be triggered with a different message' do
|
186
|
+
assert_expected_assertions 2 do
|
187
|
+
assert_assertion_triggered %Q(ArgumentError exception expected with message "Don’t have a cow, man!".\nExpected: "Don’t have a cow, man!"\n Actual: "Have a cow, man!") do
|
188
|
+
tc.assert_raises_with_message(ArgumentError, 'Don’t have a cow, man!') do
|
189
|
+
raise ArgumentError, 'Have a cow, man!'
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
describe '.assert_set_equal' do
|
197
|
+
it 'return true if the sets are equal' do
|
198
|
+
assert_expected_assertions do
|
199
|
+
assert_equal true, tc.assert_set_equal(%w(a b c), %w(c b a)),
|
200
|
+
%q(returns true for sets %w(a b c) and %w(c b a))
|
201
|
+
end
|
202
|
+
end
|
147
203
|
|
148
|
-
|
149
|
-
|
150
|
-
|
204
|
+
it 'is triggered if they are not equal' do
|
205
|
+
assert_expected_assertions do
|
206
|
+
assert_assertion_triggered %Q(Expected [\n \"c\",\n \"b\"\n] to be set equivalent to [\n \"a\",\n \"b\",\n \"c\"\n].\nExpected: #<Set: {\"a\", \"b\", \"c\"}>\n Actual: #<Set: {\"c\", \"b\"}>) do
|
207
|
+
tc.assert_set_equal %w(a b c), %w(c b)
|
151
208
|
end
|
152
209
|
end
|
153
210
|
end
|
211
|
+
end
|
212
|
+
|
213
|
+
describe '.refute_set_equal' do
|
214
|
+
it 'return true if the sets are not equal' do
|
215
|
+
assert_expected_assertions do
|
216
|
+
assert_equal false, tc.refute_set_equal(%w(a b c), %w(c b)),
|
217
|
+
%q(returns true for sets %w(a b c) and %w(c b))
|
218
|
+
end
|
219
|
+
end
|
154
220
|
|
155
|
-
it
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
raise ArgumentError, "Have a cow, man!"
|
221
|
+
it 'is triggered if they are not equal' do
|
222
|
+
assert_expected_assertions do
|
223
|
+
assert_assertion_triggered %Q(Expected [\n \"c\",\n \"b\",\n \"a\"\n] not to be set equivalent to [\n \"a\",\n \"b\",\n \"c\"\n].\nExpected #<Set: {\"c\", \"b\", \"a\"}> to not be equal to #<Set: {\"a\", \"b\", \"c\"}>.) do
|
224
|
+
tc.refute_set_equal %w(a b c), %w(c b a)
|
160
225
|
end
|
161
226
|
end
|
162
227
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-bonus-assertions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '
|
4
|
+
version: '2.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Austin Ziegler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '5.
|
19
|
+
version: '5.8'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '5.
|
26
|
+
version: '5.8'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rdoc
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -212,20 +212,23 @@ dependencies:
|
|
212
212
|
requirements:
|
213
213
|
- - "~>"
|
214
214
|
- !ruby/object:Gem::Version
|
215
|
-
version: '3.
|
215
|
+
version: '3.14'
|
216
216
|
type: :development
|
217
217
|
prerelease: false
|
218
218
|
version_requirements: !ruby/object:Gem::Requirement
|
219
219
|
requirements:
|
220
220
|
- - "~>"
|
221
221
|
- !ruby/object:Gem::Version
|
222
|
-
version: '3.
|
223
|
-
description:
|
222
|
+
version: '3.14'
|
223
|
+
description: |-
|
224
|
+
Bonus assertions for {Minitest}[https://github.com/seattlerb/minitest],
|
225
|
+
providing assertions I use frequently.
|
224
226
|
email:
|
225
227
|
- halostatue@gmail.com
|
226
228
|
executables: []
|
227
229
|
extensions: []
|
228
230
|
extra_rdoc_files:
|
231
|
+
- Code-of-Conduct.rdoc
|
229
232
|
- Contributing.rdoc
|
230
233
|
- History.rdoc
|
231
234
|
- Licence.rdoc
|
@@ -238,6 +241,7 @@ files:
|
|
238
241
|
- ".minitest.rb"
|
239
242
|
- ".travis.yml"
|
240
243
|
- ".workenv"
|
244
|
+
- Code-of-Conduct.rdoc
|
241
245
|
- Contributing.rdoc
|
242
246
|
- Gemfile
|
243
247
|
- History.rdoc
|
@@ -245,8 +249,8 @@ files:
|
|
245
249
|
- Manifest.txt
|
246
250
|
- README.rdoc
|
247
251
|
- Rakefile
|
248
|
-
- VERSION
|
249
252
|
- lib/minitest-bonus-assertions.rb
|
253
|
+
- lib/minitest/assertion_tests.rb
|
250
254
|
- test/minitest_config.rb
|
251
255
|
- test/test_minitest-bonus-assertions.rb
|
252
256
|
homepage: https://github.com/halostatue/minitest-bonus-assertions
|
@@ -271,8 +275,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
271
275
|
version: '0'
|
272
276
|
requirements: []
|
273
277
|
rubyforge_project:
|
274
|
-
rubygems_version: 2.
|
278
|
+
rubygems_version: 2.4.5.1
|
275
279
|
signing_key:
|
276
280
|
specification_version: 4
|
277
|
-
summary:
|
281
|
+
summary: Bonus assertions for {Minitest}[https://github.com/seattlerb/minitest], providing
|
282
|
+
assertions I use frequently.
|
278
283
|
test_files: []
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.2.0
|