minitest-matchers 1.3.0 → 1.4.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/.gitignore +3 -0
- data/.minitest.rb +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +18 -0
- data/History.txt +6 -0
- data/README.md +2 -0
- data/Rakefile +7 -13
- data/VERSION +1 -0
- data/lib/minitest/matchers.rb +7 -11
- data/lib/minitest/matchers/version.rb +5 -0
- data/minitest-matchers.gemspec +24 -0
- data/test/minitest/matchers_test.rb +104 -0
- metadata +30 -61
- data/.gemtest +0 -0
- data/test/test_minitest_matchers.rb +0 -112
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 04328c2aed579ded2c63a31fc655f9fc9041afba
|
4
|
+
data.tar.gz: be3a91572aa420491f46d78c2aae43902f9fcab4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 095af4786ee8fccee061ee04065d4583e12bcc888d86eef590bcb56617695726bdefc6cb3326f9b8963b1095b0cf7cd40828a63db2c5c966babe32f22e83d24b
|
7
|
+
data.tar.gz: f76d87843da18bc853e6080ea0561167b87beaf4c5cfd96466c956281ee70c09ebb6ccf701adcc5fe3f4a758650e4989234a28e1ea2bdb929e0aa9080a26cc1b
|
data/.gitignore
ADDED
data/.minitest.rb
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/History.txt
CHANGED
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
http://github.com/wojtekmach/minitest-matchers
|
4
4
|
|
5
|
+
[](http://travis-ci.org/wojtekmach/minitest-matchers)
|
6
|
+
|
5
7
|
## Warning
|
6
8
|
|
7
9
|
Don't use it! Writing simple assertions (and Minitest way of transforming them to expectations) is almost always a better idea anyway. Work with your favourite library authors to start with assertions and add matchers for convenience and not the other way around. Keep it simple.
|
data/Rakefile
CHANGED
@@ -1,16 +1,10 @@
|
|
1
|
-
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
Hoe.plugin :gemspec
|
8
|
-
|
9
|
-
Hoe.spec "minitest-matchers" do
|
10
|
-
developer "Ryan Davis", "ryand-ruby@zenspider.com"
|
11
|
-
developer "Wojciech Mach", "wojtek@wojtekmach.pl"
|
12
|
-
|
13
|
-
dependency "minitest", "~> 4.7"
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
5
|
+
t.libs << 'lib'
|
6
|
+
t.pattern = 'test/**/*_test.rb'
|
7
|
+
t.verbose = false
|
14
8
|
end
|
15
9
|
|
16
|
-
|
10
|
+
task :default => :test
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.4.0
|
data/lib/minitest/matchers.rb
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
require "minitest/spec"
|
2
2
|
|
3
|
-
module MiniTest::Matchers
|
4
|
-
VERSION = "1.3.0" # :nodoc:
|
5
|
-
end
|
6
|
-
|
7
3
|
module MiniTest
|
8
4
|
module Assertions
|
9
5
|
##
|
@@ -57,7 +53,7 @@ module MiniTest
|
|
57
53
|
|
58
54
|
module Expectations
|
59
55
|
##
|
60
|
-
# See
|
56
|
+
# See Minitest::Assertions#assert_must
|
61
57
|
#
|
62
58
|
# user.must have_valid(:email).when("user@example.com")
|
63
59
|
#
|
@@ -66,7 +62,7 @@ module MiniTest
|
|
66
62
|
infect_an_assertion :assert_must, :must
|
67
63
|
|
68
64
|
##
|
69
|
-
# See
|
65
|
+
# See Minitest::Assertions#assert_wont
|
70
66
|
#
|
71
67
|
# user.wont have_valid(:email).when("bad@email")
|
72
68
|
#
|
@@ -76,7 +72,7 @@ module MiniTest
|
|
76
72
|
end
|
77
73
|
end
|
78
74
|
|
79
|
-
class
|
75
|
+
class Minitest::Spec
|
80
76
|
##
|
81
77
|
# Expects that matcher matches the subject
|
82
78
|
#
|
@@ -136,7 +132,7 @@ class MiniTest::Spec
|
|
136
132
|
end
|
137
133
|
end
|
138
134
|
|
139
|
-
class
|
135
|
+
class Minitest::Test
|
140
136
|
##
|
141
137
|
# Defines assert_* assertion and must_* expectation for a matcher
|
142
138
|
#
|
@@ -148,7 +144,7 @@ class MiniTest::Unit::TestCase
|
|
148
144
|
# # ...
|
149
145
|
# end
|
150
146
|
#
|
151
|
-
#
|
147
|
+
# Minitest::Unit::TestCase.register_matcher HaveContent, :have_content
|
152
148
|
#
|
153
149
|
# class MyTest < Test::Unit::TestCase
|
154
150
|
# def test_index
|
@@ -201,6 +197,6 @@ class MiniTest::Unit::TestCase
|
|
201
197
|
end
|
202
198
|
end
|
203
199
|
|
204
|
-
class
|
205
|
-
include
|
200
|
+
class Minitest::Spec # :nodoc:
|
201
|
+
include Minitest::Matchers
|
206
202
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "minitest/matchers/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "minitest-matchers"
|
7
|
+
s.version = Minitest::Matchers::VERSION
|
8
|
+
s.authors = ["Wojciech Mach", "Ryan Davis"]
|
9
|
+
s.email = ["wojtek@wojtekmach.pl", "ryand-ruby@zenspider.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Adds support for RSpec-style matchers}
|
12
|
+
s.description = s.summary
|
13
|
+
|
14
|
+
s.rubyforge_project = "minitest-matchers"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_dependency "minitest", "~> 5.0"
|
22
|
+
|
23
|
+
s.add_development_dependency "rake"
|
24
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
gem "minitest"
|
2
|
+
require "minitest/autorun"
|
3
|
+
require "minitest/matchers"
|
4
|
+
|
5
|
+
class BadMatcher; end
|
6
|
+
|
7
|
+
class KindOfMatcher
|
8
|
+
def initialize klass
|
9
|
+
@klass = klass
|
10
|
+
end
|
11
|
+
|
12
|
+
def description
|
13
|
+
"be kind of #{@klass}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def matches? subject
|
17
|
+
subject.kind_of? @klass
|
18
|
+
end
|
19
|
+
|
20
|
+
def failure_message_for_should
|
21
|
+
"expected to " + description
|
22
|
+
end
|
23
|
+
|
24
|
+
def failure_message_for_should_not
|
25
|
+
"expected not to " + description
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def be_kind_of klass
|
30
|
+
KindOfMatcher.new klass
|
31
|
+
end
|
32
|
+
|
33
|
+
describe Minitest::Test do
|
34
|
+
it "needs to verify assert_must" do
|
35
|
+
assert_must(be_kind_of(Array), []).must_equal true
|
36
|
+
proc { assert_must be_kind_of(String), [] }.must_raise Minitest::Assertion
|
37
|
+
end
|
38
|
+
|
39
|
+
it "needs to verify assert_wont" do
|
40
|
+
assert_wont(be_kind_of(String), []).must_equal false
|
41
|
+
proc { assert_wont be_kind_of(Array), [] }.must_raise Minitest::Assertion
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe Minitest::Test, :register_matcher do
|
46
|
+
Minitest::Test.register_matcher KindOfMatcher, :my_kind_of, :be_my_kind_of
|
47
|
+
Minitest::Test.register_matcher :be_kind_of, :meth_kind_of, :meth_my_kind_of
|
48
|
+
|
49
|
+
it "needs to verify assert_<matcher>" do
|
50
|
+
assert_my_kind_of("", String).must_equal true
|
51
|
+
proc { assert_my_kind_of [], String }.must_raise Minitest::Assertion
|
52
|
+
end
|
53
|
+
|
54
|
+
it "needs to verify must_<matcher>" do
|
55
|
+
"".must_be_my_kind_of(String).must_equal true
|
56
|
+
proc { [].must_be_my_kind_of String }.must_raise Minitest::Assertion
|
57
|
+
end
|
58
|
+
|
59
|
+
it "needs to verify refute_<matcher>" do
|
60
|
+
refute_my_kind_of("", Array).must_equal false
|
61
|
+
proc { refute_my_kind_of [], Array }.must_raise Minitest::Assertion
|
62
|
+
end
|
63
|
+
|
64
|
+
it "needs to verify wont<matcher>" do
|
65
|
+
"".wont_be_my_kind_of(Array).must_equal false
|
66
|
+
proc { [].wont_be_my_kind_of(Array) }.must_raise Minitest::Assertion
|
67
|
+
end
|
68
|
+
|
69
|
+
it "accepts method as matcher" do
|
70
|
+
assert_meth_kind_of("", String).must_equal true
|
71
|
+
proc { assert_meth_kind_of [], String }.must_raise Minitest::Assertion
|
72
|
+
refute_meth_kind_of("", Array).must_equal false
|
73
|
+
proc { refute_my_kind_of [], Array }.must_raise Minitest::Assertion
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe Minitest::Spec do
|
78
|
+
it "needs to verify must" do
|
79
|
+
[].must(be_kind_of(Array)).must_equal true
|
80
|
+
proc { [].must be_kind_of(String) }.must_raise Minitest::Assertion
|
81
|
+
end
|
82
|
+
|
83
|
+
it "needs to verify wont" do
|
84
|
+
[].wont(be_kind_of(String)).must_equal false
|
85
|
+
proc { [].wont be_kind_of(Array) }.must_raise Minitest::Assertion
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "implicit subject" do
|
89
|
+
subject { [1, 2, 3] }
|
90
|
+
|
91
|
+
must { be_kind_of(Array) }
|
92
|
+
wont { be_kind_of(String) }
|
93
|
+
|
94
|
+
it "verifies must" do
|
95
|
+
must be_kind_of(Array)
|
96
|
+
proc { must be_kind_of(String) }.must_raise Minitest::Assertion
|
97
|
+
end
|
98
|
+
|
99
|
+
it "verifies wont" do
|
100
|
+
wont be_kind_of(String)
|
101
|
+
proc { wont be_kind_of(Array) }.must_raise Minitest::Assertion
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
metadata
CHANGED
@@ -1,121 +1,90 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.4.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
|
-
- Ryan Davis
|
9
7
|
- Wojciech Mach
|
8
|
+
- Ryan Davis
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date: 2013-
|
12
|
+
date: 2013-06-30 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: minitest
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
17
|
requirements:
|
20
18
|
- - ~>
|
21
19
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
20
|
+
version: '5.0'
|
23
21
|
type: :runtime
|
24
22
|
prerelease: false
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
|
-
requirements:
|
28
|
-
- - ~>
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
version: '4.7'
|
31
|
-
- !ruby/object:Gem::Dependency
|
32
|
-
name: rdoc
|
33
|
-
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
|
-
requirements:
|
36
|
-
- - ~>
|
37
|
-
- !ruby/object:Gem::Version
|
38
|
-
version: '3.10'
|
39
|
-
type: :development
|
40
|
-
prerelease: false
|
41
|
-
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
24
|
requirements:
|
44
25
|
- - ~>
|
45
26
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
27
|
+
version: '5.0'
|
47
28
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
29
|
+
name: rake
|
49
30
|
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
31
|
requirements:
|
52
|
-
- -
|
32
|
+
- - '>='
|
53
33
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
34
|
+
version: '0'
|
55
35
|
type: :development
|
56
36
|
prerelease: false
|
57
37
|
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
38
|
requirements:
|
60
|
-
- -
|
39
|
+
- - '>='
|
61
40
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
63
|
-
description:
|
64
|
-
minitest-matchers adds support for RSpec/Shoulda-style matchers to
|
65
|
-
minitest/unit and minitest/spec.
|
66
|
-
|
67
|
-
More information about matchers can be found here:
|
68
|
-
|
69
|
-
* https://www.relishapp.com/rspec/rspec-expectations
|
70
|
-
* http://railscasts.com/episodes/157-rspec-matchers-macros
|
71
|
-
|
72
|
-
For use with Rails check out (ValidAttribute + Capybara):
|
73
|
-
|
74
|
-
* https://github.com/wojtekmach/minitest-rails-example
|
41
|
+
version: '0'
|
42
|
+
description: Adds support for RSpec-style matchers
|
75
43
|
email:
|
76
|
-
- ryand-ruby@zenspider.com
|
77
44
|
- wojtek@wojtekmach.pl
|
45
|
+
- ryand-ruby@zenspider.com
|
78
46
|
executables: []
|
79
47
|
extensions: []
|
80
|
-
extra_rdoc_files:
|
81
|
-
- History.txt
|
82
|
-
- Manifest.txt
|
48
|
+
extra_rdoc_files: []
|
83
49
|
files:
|
84
50
|
- .autotest
|
51
|
+
- .gitignore
|
52
|
+
- .minitest.rb
|
53
|
+
- .travis.yml
|
54
|
+
- Gemfile
|
55
|
+
- Gemfile.lock
|
85
56
|
- History.txt
|
86
57
|
- Manifest.txt
|
87
58
|
- README.md
|
88
59
|
- Rakefile
|
89
|
-
-
|
60
|
+
- VERSION
|
90
61
|
- lib/minitest-matchers.rb
|
91
|
-
-
|
92
|
-
- .
|
93
|
-
|
62
|
+
- lib/minitest/matchers.rb
|
63
|
+
- lib/minitest/matchers/version.rb
|
64
|
+
- minitest-matchers.gemspec
|
65
|
+
- test/minitest/matchers_test.rb
|
66
|
+
homepage: ''
|
94
67
|
licenses: []
|
68
|
+
metadata: {}
|
95
69
|
post_install_message:
|
96
|
-
rdoc_options:
|
97
|
-
- --main
|
98
|
-
- README.md
|
70
|
+
rdoc_options: []
|
99
71
|
require_paths:
|
100
72
|
- lib
|
101
73
|
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
-
none: false
|
103
74
|
requirements:
|
104
75
|
- - '>='
|
105
76
|
- !ruby/object:Gem::Version
|
106
77
|
version: '0'
|
107
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
-
none: false
|
109
79
|
requirements:
|
110
80
|
- - '>='
|
111
81
|
- !ruby/object:Gem::Version
|
112
82
|
version: '0'
|
113
83
|
requirements: []
|
114
84
|
rubyforge_project: minitest-matchers
|
115
|
-
rubygems_version:
|
85
|
+
rubygems_version: 2.0.3
|
116
86
|
signing_key:
|
117
|
-
specification_version:
|
118
|
-
summary:
|
119
|
-
and minitest/spec
|
87
|
+
specification_version: 4
|
88
|
+
summary: Adds support for RSpec-style matchers
|
120
89
|
test_files:
|
121
|
-
- test/
|
90
|
+
- test/minitest/matchers_test.rb
|
data/.gemtest
DELETED
File without changes
|
@@ -1,112 +0,0 @@
|
|
1
|
-
gem "minitest"
|
2
|
-
require "minitest/spec"
|
3
|
-
require "minitest/autorun"
|
4
|
-
require "minitest/matchers"
|
5
|
-
|
6
|
-
class BadMatcher; end
|
7
|
-
|
8
|
-
class KindOfMatcher
|
9
|
-
def initialize klass
|
10
|
-
@klass = klass
|
11
|
-
end
|
12
|
-
|
13
|
-
def description
|
14
|
-
"be kind of #{@klass}"
|
15
|
-
end
|
16
|
-
|
17
|
-
def matches? subject
|
18
|
-
subject.kind_of? @klass
|
19
|
-
end
|
20
|
-
|
21
|
-
def failure_message_for_should
|
22
|
-
"expected to " + description
|
23
|
-
end
|
24
|
-
|
25
|
-
def failure_message_for_should_not
|
26
|
-
"expected not to " + description
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def be_kind_of klass
|
31
|
-
KindOfMatcher.new klass
|
32
|
-
end
|
33
|
-
|
34
|
-
describe MiniTest::Unit::TestCase do
|
35
|
-
it "needs to verify assert_must" do
|
36
|
-
assert_must(be_kind_of(Array), []).must_equal true
|
37
|
-
proc { assert_must be_kind_of(String), [] }.must_raise MiniTest::Assertion
|
38
|
-
end
|
39
|
-
|
40
|
-
it "needs to verify assert_wont" do
|
41
|
-
assert_wont(be_kind_of(String), []).must_equal false
|
42
|
-
proc { assert_wont be_kind_of(Array), [] }.must_raise MiniTest::Assertion
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe MiniTest::Unit::TestCase, :register_matcher do
|
47
|
-
MiniTest::Unit::TestCase.register_matcher KindOfMatcher, :my_kind_of, :be_my_kind_of
|
48
|
-
MiniTest::Unit::TestCase.register_matcher :be_kind_of, :meth_kind_of, :meth_my_kind_of
|
49
|
-
|
50
|
-
it "needs to verify assert_<matcher>" do
|
51
|
-
assert_my_kind_of("", String).must_equal true
|
52
|
-
proc { assert_my_kind_of [], String }.must_raise MiniTest::Assertion
|
53
|
-
end
|
54
|
-
|
55
|
-
it "needs to verify must_<matcher>" do
|
56
|
-
"".must_be_my_kind_of(String).must_equal true
|
57
|
-
proc { [].must_be_my_kind_of String }.must_raise MiniTest::Assertion
|
58
|
-
end
|
59
|
-
|
60
|
-
it "needs to verify refute_<matcher>" do
|
61
|
-
refute_my_kind_of("", Array).must_equal false
|
62
|
-
proc { refute_my_kind_of [], Array }.must_raise MiniTest::Assertion
|
63
|
-
end
|
64
|
-
|
65
|
-
it "needs to verify wont<matcher>" do
|
66
|
-
"".wont_be_my_kind_of(Array).must_equal false
|
67
|
-
proc { [].wont_be_my_kind_of(Array) }.must_raise MiniTest::Assertion
|
68
|
-
end
|
69
|
-
|
70
|
-
it "accepts method as matcher" do
|
71
|
-
assert_meth_kind_of("", String).must_equal true
|
72
|
-
proc { assert_meth_kind_of [], String }.must_raise MiniTest::Assertion
|
73
|
-
refute_meth_kind_of("", Array).must_equal false
|
74
|
-
proc { refute_my_kind_of [], Array }.must_raise MiniTest::Assertion
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe MiniTest::Spec do
|
79
|
-
it "needs to verify must" do
|
80
|
-
[].must(be_kind_of(Array)).must_equal true
|
81
|
-
proc { [].must be_kind_of(String) }.must_raise MiniTest::Assertion
|
82
|
-
end
|
83
|
-
|
84
|
-
it "needs to verify wont" do
|
85
|
-
[].wont(be_kind_of(String)).must_equal false
|
86
|
-
proc { [].wont be_kind_of(Array) }.must_raise MiniTest::Assertion
|
87
|
-
end
|
88
|
-
|
89
|
-
it "needs to verify must with implicit subject" do
|
90
|
-
spec_class = Class.new(MiniTest::Spec) do
|
91
|
-
subject { [1, 2, 3] }
|
92
|
-
|
93
|
-
it { must be_kind_of(String) }
|
94
|
-
end
|
95
|
-
|
96
|
-
spec = spec_class.new("A spec")
|
97
|
-
|
98
|
-
proc { spec.send spec_class.test_methods.first}.must_raise MiniTest::Assertion
|
99
|
-
end
|
100
|
-
|
101
|
-
it "needs to verify wont with implicit subject" do
|
102
|
-
spec_class = Class.new(MiniTest::Spec) do
|
103
|
-
subject { [1, 2, 3] }
|
104
|
-
|
105
|
-
it { wont be_kind_of(Array) }
|
106
|
-
end
|
107
|
-
|
108
|
-
spec = spec_class.new("A spec")
|
109
|
-
|
110
|
-
proc { spec.send spec_class.test_methods.first}.must_raise MiniTest::Assertion
|
111
|
-
end
|
112
|
-
end
|