minitest-matchers 1.2.0 → 1.3.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.
- data/History.txt +19 -0
- data/Manifest.txt +1 -1
- data/README.md +145 -0
- data/Rakefile +1 -1
- data/lib/minitest/matchers.rb +2 -2
- metadata +35 -24
- data/README.txt +0 -126
data/History.txt
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
=== HEAD
|
2
|
+
|
3
|
+
=== 1.3.0 / 2013-04-22
|
4
|
+
|
5
|
+
* 2 major enhancements
|
6
|
+
|
7
|
+
* New home: github.com/wojtekmach/minitest-matchers
|
8
|
+
* Depend on minitest ~> 4.7
|
9
|
+
|
10
|
+
=== 1.1.3 / 2011-12-18
|
11
|
+
|
12
|
+
* 1 major enhancement
|
13
|
+
|
14
|
+
* Add ::register_matcher
|
15
|
+
|
16
|
+
* 1 minor enhancement
|
17
|
+
|
18
|
+
* First check for Matcher#failure_message_for_should
|
19
|
+
|
1
20
|
=== 1.1.3 / 2011-12-18
|
2
21
|
|
3
22
|
* 1 minor enhancement
|
data/Manifest.txt
CHANGED
data/README.md
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
# minitest-matchers
|
2
|
+
|
3
|
+
http://github.com/wojtekmach/minitest-matchers
|
4
|
+
|
5
|
+
## Warning
|
6
|
+
|
7
|
+
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.
|
8
|
+
|
9
|
+
## Description
|
10
|
+
|
11
|
+
minitest-matchers adds support for RSpec/Shoulda-style matchers to
|
12
|
+
minitest/unit and minitest/spec.
|
13
|
+
|
14
|
+
More information about matchers can be found here:
|
15
|
+
|
16
|
+
* https://www.relishapp.com/rspec/rspec-expectations
|
17
|
+
* http://railscasts.com/episodes/157-rspec-matchers-macros
|
18
|
+
|
19
|
+
For use with Rails check out (ValidAttribute + Capybara):
|
20
|
+
|
21
|
+
* https://github.com/wojtekmach/minitest-rails-example
|
22
|
+
|
23
|
+
## Features/Problems
|
24
|
+
|
25
|
+
* Enables you to use existing matcher classes from projects like
|
26
|
+
valid\_attribute and capybara
|
27
|
+
* Can be used both in MiniTest::Unit::TestCase & MiniTest::Spec
|
28
|
+
|
29
|
+
## Synopsis
|
30
|
+
|
31
|
+
see example matcher: [matcher.rb](https://github.com/bcardarella/valid_attribute/blob/master/lib/valid_attribute/matcher.rb)
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
require "minitest/matchers"
|
35
|
+
require "minitest/autorun"
|
36
|
+
require "valid_attribute"
|
37
|
+
require "active_model"
|
38
|
+
|
39
|
+
class Post
|
40
|
+
include ActiveModel::Validations
|
41
|
+
attr_accessor :title
|
42
|
+
validates :title, :presence => true, :length => 4..20
|
43
|
+
end
|
44
|
+
|
45
|
+
# Using minitest/unit
|
46
|
+
|
47
|
+
class PostTest < MiniTest::Unit::TestCase
|
48
|
+
include ValidAttribute::Method
|
49
|
+
|
50
|
+
def test_validations
|
51
|
+
post = Post.new
|
52
|
+
|
53
|
+
assert_must have_valid(:title).when("Good"), post
|
54
|
+
assert_wont have_valid(:title).when(""), post
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# Using minitest/spec
|
59
|
+
|
60
|
+
describe Post do
|
61
|
+
include ValidAttribute::Method
|
62
|
+
|
63
|
+
it "should have validations" do
|
64
|
+
post = Post.new
|
65
|
+
|
66
|
+
post.must have_valid(:title).when("Good")
|
67
|
+
post.wont have_valid(:title).when("")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# Using minitest/spec with subject
|
72
|
+
|
73
|
+
describe Post do
|
74
|
+
subject { Post.new }
|
75
|
+
|
76
|
+
it { must have_valid(:title).when("Hello") }
|
77
|
+
it { wont have_valid(:title).when("", nil, "Bad") }
|
78
|
+
end
|
79
|
+
|
80
|
+
# or
|
81
|
+
|
82
|
+
describe Post do
|
83
|
+
subject { Post.new }
|
84
|
+
|
85
|
+
must { have_valid(:title).when("Hello") }
|
86
|
+
wont { have_valid(:title).when("", nil, "Bad") }
|
87
|
+
end
|
88
|
+
```
|
89
|
+
|
90
|
+
You can also register matcher so that it works similar to built-in
|
91
|
+
assertions and expectations. Note subject must be the first argument in assertion.
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
MiniTest::Unit::TestCase.register_matcher HaveContent, :have_content
|
95
|
+
MiniTest::Unit::TestCase.register_matcher :have_selector, :have_selector
|
96
|
+
|
97
|
+
assert_have_content page, "Hello"
|
98
|
+
assert_have_selector page, :xpath, "//table/tr"
|
99
|
+
|
100
|
+
page.must_have_content "Hello"
|
101
|
+
page.must_have_selector :xpath, "//table/tr"
|
102
|
+
```
|
103
|
+
|
104
|
+
## Requirements
|
105
|
+
|
106
|
+
* `minitest >= 2.7.0`
|
107
|
+
|
108
|
+
## Install
|
109
|
+
|
110
|
+
```
|
111
|
+
gem install minitest-matchers
|
112
|
+
```
|
113
|
+
|
114
|
+
or add to Gemfile:
|
115
|
+
|
116
|
+
```ruby
|
117
|
+
group :test do
|
118
|
+
gem 'minitest-matchers'
|
119
|
+
end
|
120
|
+
```
|
121
|
+
|
122
|
+
## License
|
123
|
+
|
124
|
+
(The MIT License)
|
125
|
+
|
126
|
+
Copyright (c) Ryan Davis, seattle.rb, Wojciech Mach
|
127
|
+
|
128
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
129
|
+
a copy of this software and associated documentation files (the
|
130
|
+
'Software'), to deal in the Software without restriction, including
|
131
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
132
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
133
|
+
permit persons to whom the Software is furnished to do so, subject to
|
134
|
+
the following conditions:
|
135
|
+
|
136
|
+
The above copyright notice and this permission notice shall be
|
137
|
+
included in all copies or substantial portions of the Software.
|
138
|
+
|
139
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
140
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
141
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
142
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
143
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
144
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
145
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
CHANGED
data/lib/minitest/matchers.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "minitest/spec"
|
2
2
|
|
3
3
|
module MiniTest::Matchers
|
4
|
-
VERSION = "1.
|
4
|
+
VERSION = "1.3.0" # :nodoc:
|
5
5
|
end
|
6
6
|
|
7
7
|
module MiniTest
|
@@ -138,7 +138,7 @@ end
|
|
138
138
|
|
139
139
|
class MiniTest::Unit::TestCase
|
140
140
|
##
|
141
|
-
# Defines assert_*
|
141
|
+
# Defines assert_* assertion and must_* expectation for a matcher
|
142
142
|
#
|
143
143
|
# Example:
|
144
144
|
#
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minitest-matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,22 +10,27 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2013-04-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: minitest
|
17
|
-
requirement:
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
|
-
- -
|
20
|
+
- - ~>
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
22
|
+
version: '4.7'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements:
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '4.7'
|
26
31
|
- !ruby/object:Gem::Dependency
|
27
32
|
name: rdoc
|
28
|
-
requirement:
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
29
34
|
none: false
|
30
35
|
requirements:
|
31
36
|
- - ~>
|
@@ -33,33 +38,40 @@ dependencies:
|
|
33
38
|
version: '3.10'
|
34
39
|
type: :development
|
35
40
|
prerelease: false
|
36
|
-
version_requirements:
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '3.10'
|
37
47
|
- !ruby/object:Gem::Dependency
|
38
48
|
name: hoe
|
39
|
-
requirement:
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
40
50
|
none: false
|
41
51
|
requirements:
|
42
52
|
- - ~>
|
43
53
|
- !ruby/object:Gem::Version
|
44
|
-
version: '
|
54
|
+
version: '3.5'
|
45
55
|
type: :development
|
46
56
|
prerelease: false
|
47
|
-
version_requirements:
|
48
|
-
|
49
|
-
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3.5'
|
63
|
+
description: |-
|
64
|
+
minitest-matchers adds support for RSpec/Shoulda-style matchers to
|
50
65
|
minitest/unit and minitest/spec.
|
51
66
|
|
52
|
-
|
53
67
|
More information about matchers can be found here:
|
54
68
|
|
55
69
|
* https://www.relishapp.com/rspec/rspec-expectations
|
56
|
-
|
57
70
|
* http://railscasts.com/episodes/157-rspec-matchers-macros
|
58
71
|
|
59
|
-
|
60
72
|
For use with Rails check out (ValidAttribute + Capybara):
|
61
73
|
|
62
|
-
* https://github.com/wojtekmach/minitest-rails-example
|
74
|
+
* https://github.com/wojtekmach/minitest-rails-example
|
63
75
|
email:
|
64
76
|
- ryand-ruby@zenspider.com
|
65
77
|
- wojtek@wojtekmach.pl
|
@@ -68,40 +80,39 @@ extensions: []
|
|
68
80
|
extra_rdoc_files:
|
69
81
|
- History.txt
|
70
82
|
- Manifest.txt
|
71
|
-
- README.txt
|
72
83
|
files:
|
73
84
|
- .autotest
|
74
85
|
- History.txt
|
75
86
|
- Manifest.txt
|
76
|
-
- README.
|
87
|
+
- README.md
|
77
88
|
- Rakefile
|
78
89
|
- lib/minitest/matchers.rb
|
79
90
|
- lib/minitest-matchers.rb
|
80
91
|
- test/test_minitest_matchers.rb
|
81
92
|
- .gemtest
|
82
|
-
homepage: http://github.com/
|
93
|
+
homepage: http://github.com/wojtekmach/minitest-matchers
|
83
94
|
licenses: []
|
84
95
|
post_install_message:
|
85
96
|
rdoc_options:
|
86
97
|
- --main
|
87
|
-
- README.
|
98
|
+
- README.md
|
88
99
|
require_paths:
|
89
100
|
- lib
|
90
101
|
required_ruby_version: !ruby/object:Gem::Requirement
|
91
102
|
none: false
|
92
103
|
requirements:
|
93
|
-
- -
|
104
|
+
- - '>='
|
94
105
|
- !ruby/object:Gem::Version
|
95
106
|
version: '0'
|
96
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
108
|
none: false
|
98
109
|
requirements:
|
99
|
-
- -
|
110
|
+
- - '>='
|
100
111
|
- !ruby/object:Gem::Version
|
101
112
|
version: '0'
|
102
113
|
requirements: []
|
103
114
|
rubyforge_project: minitest-matchers
|
104
|
-
rubygems_version: 1.8.
|
115
|
+
rubygems_version: 1.8.25
|
105
116
|
signing_key:
|
106
117
|
specification_version: 3
|
107
118
|
summary: minitest-matchers adds support for RSpec/Shoulda-style matchers to minitest/unit
|
data/README.txt
DELETED
@@ -1,126 +0,0 @@
|
|
1
|
-
= minitest-matchers
|
2
|
-
|
3
|
-
* http://github.com/zenspider/minitest-matchers
|
4
|
-
|
5
|
-
== DESCRIPTION:
|
6
|
-
|
7
|
-
minitest-matchers adds support for RSpec/Shoulda-style matchers to
|
8
|
-
minitest/unit and minitest/spec.
|
9
|
-
|
10
|
-
More information about matchers can be found here:
|
11
|
-
* https://www.relishapp.com/rspec/rspec-expectations
|
12
|
-
* http://railscasts.com/episodes/157-rspec-matchers-macros
|
13
|
-
|
14
|
-
For use with Rails check out (ValidAttribute + Capybara):
|
15
|
-
* https://github.com/wojtekmach/minitest-rails-example
|
16
|
-
|
17
|
-
== FEATURES/PROBLEMS:
|
18
|
-
|
19
|
-
* Enables you to use existing matcher classes from projects like
|
20
|
-
valid_attribute and in the future shoulda-matchers and maybe even remarkable.
|
21
|
-
* Can be used both in MiniTest::Unit::TestCase & MiniTest::Spec
|
22
|
-
|
23
|
-
== SYNOPSIS:
|
24
|
-
|
25
|
-
* see example matcher: https://github.com/bcardarella/valid_attribute/blob/master/lib/valid_attribute/matcher.rb
|
26
|
-
|
27
|
-
gem "minitest"
|
28
|
-
require "minitest/matchers"
|
29
|
-
require "minitest/autorun"
|
30
|
-
require "valid_attribute"
|
31
|
-
require "active_model"
|
32
|
-
|
33
|
-
class Post
|
34
|
-
include ActiveModel::Validations
|
35
|
-
attr_accessor :title
|
36
|
-
validates :title, :presence => true, :length => 4..20
|
37
|
-
end
|
38
|
-
|
39
|
-
# Using minitest/unit
|
40
|
-
|
41
|
-
class PostTest < MiniTest::Unit::TestCase
|
42
|
-
include ValidAttribute::Method
|
43
|
-
|
44
|
-
def test_validations
|
45
|
-
post = Post.new
|
46
|
-
|
47
|
-
assert_must have_valid(:title).when("Good"), post
|
48
|
-
assert_wont have_valid(:title).when(""), post
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
# Using minitest/spec
|
53
|
-
|
54
|
-
describe Post do
|
55
|
-
include ValidAttribute::Method
|
56
|
-
|
57
|
-
it "should have validations" do
|
58
|
-
post = Post.new
|
59
|
-
|
60
|
-
post.must have_valid(:title).when("Good")
|
61
|
-
post.wont have_valid(:title).when("")
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
# Using minitest/spec with subject
|
66
|
-
|
67
|
-
describe Post do
|
68
|
-
subject { Post.new }
|
69
|
-
|
70
|
-
it { must have_valid(:title).when("Hello") }
|
71
|
-
it { wont have_valid(:title).when("", nil, "Bad") }
|
72
|
-
end
|
73
|
-
|
74
|
-
# or
|
75
|
-
|
76
|
-
describe Post do
|
77
|
-
subject { Post.new }
|
78
|
-
|
79
|
-
must { have_valid(:title).when("Hello") }
|
80
|
-
wont { have_valid(:title).when("", nil, "Bad") }
|
81
|
-
end
|
82
|
-
|
83
|
-
You can also register matcher so that it works similar to built-in
|
84
|
-
assertions and expectations. Note subject must be the first argument in assertion.
|
85
|
-
|
86
|
-
MiniTest::Unit::TestCase.register_matcher HaveContent, :have_content
|
87
|
-
MiniTest::Unit::TestCase.register_matcher :have_selector, :have_selector
|
88
|
-
|
89
|
-
assert_have_content page, "Hello"
|
90
|
-
assert_Have_selector page, :xpath, "//table/tr"
|
91
|
-
|
92
|
-
page.must_have_content "Hello"
|
93
|
-
page.must_Have_selector :xpath, "//table/tr"
|
94
|
-
|
95
|
-
== REQUIREMENTS:
|
96
|
-
|
97
|
-
* minitest >= 2.7.0
|
98
|
-
|
99
|
-
== INSTALL:
|
100
|
-
|
101
|
-
* sudo gem install minitest-matchers
|
102
|
-
|
103
|
-
== LICENSE:
|
104
|
-
|
105
|
-
(The MIT License)
|
106
|
-
|
107
|
-
Copyright (c) Ryan Davis, seattle.rb, Wojciech Mach
|
108
|
-
|
109
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
110
|
-
a copy of this software and associated documentation files (the
|
111
|
-
'Software'), to deal in the Software without restriction, including
|
112
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
113
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
114
|
-
permit persons to whom the Software is furnished to do so, subject to
|
115
|
-
the following conditions:
|
116
|
-
|
117
|
-
The above copyright notice and this permission notice shall be
|
118
|
-
included in all copies or substantial portions of the Software.
|
119
|
-
|
120
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
121
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
122
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
123
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
124
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
125
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
126
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|