minitest-assert_errors 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dd6934b7b881c8ceb902778b35428cc3b6f1206b
4
+ data.tar.gz: 735139536526e6d2edfed4811392a93e701cd8ae
5
+ SHA512:
6
+ metadata.gz: 16db2c540f82d238b7cb725ee866da51325412ff7a8d49367d99d4d4d68f550c65343a1552f950a48c8ec40f045a073aa08ba8089f1d69d973be9252a153fa30
7
+ data.tar.gz: 5d46a5cc75071995c2f7451c45955113069cd7830132378c50dd4867c936bfd1c8cc9a2ac7d541e501d73f437228f1a87a9816c3e3806b2c8091046149592401
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.10.3
@@ -0,0 +1,24 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute
4
+ through reporting issues, posting feature requests, updating documentation, submitting pull requests
5
+ or patches, and other activities.
6
+
7
+ We are committed to making participation in this project a harassment-free experience for everyone,
8
+ regardless of level of experience, gender, gender identity and expression, sexual orientation,
9
+ disability, personal appearance, body size, race, ethnicity, age, or religion.
10
+
11
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery,
12
+ derogatory comments or personal attacks, trolling, public or private harassment, insults, or other
13
+ unprofessional conduct.
14
+
15
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits,
16
+ code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct.
17
+ Project maintainers who do not follow the Code of Conduct may be removed from the project team.
18
+
19
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an
20
+ issue or contacting one or more of the project maintainers.
21
+
22
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org),
23
+ version 1.0.0, available at
24
+ [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in minitest-assert_errors.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Kematzy
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.
@@ -0,0 +1,193 @@
1
+ # Minitest::AssertErrors
2
+
3
+ Adds Minitest assertions to test for errors raised or not raised by Minitest itself. Most **useful
4
+ when testing other Minitest assertions** or as a shortcut to other tests.
5
+
6
+ **NOTE!!**
7
+
8
+ Currently adds the following methods:
9
+
10
+ ### Minitest::Assertions
11
+
12
+ * **`:assert_have_error(expected_msg, klass = Minitest::Assertion, &blk)`**
13
+
14
+ * **`:assert_no_error(&blk)`** also aliased as **`:refute_error()`**
15
+
16
+ ### Minitest::Expectations
17
+
18
+ * **actual.`must_have_error(expected_msg)`**
19
+
20
+ * **actual.`wont_have_error`**
21
+
22
+ <br>
23
+ ---
24
+
25
+ ## Installation
26
+
27
+ Add this line to your application's Gemfile:
28
+
29
+ ```ruby
30
+ gem 'minitest-assert_errors'
31
+ ```
32
+
33
+ And then execute:
34
+
35
+ $ bundle
36
+
37
+ Or install it yourself as:
38
+
39
+ $ gem install minitest-assert_errors
40
+
41
+ ## Usage
42
+
43
+ Add the gem to your **Gemfile** or **.gemspec** file and then load the gem in your
44
+ `(test|spec)_helper.rb` file as follows:
45
+
46
+ ```ruby
47
+ # <snip...>
48
+
49
+ require 'minitest/autorun'
50
+
51
+ require 'minitest/assert_errors'
52
+
53
+ # <snip...>
54
+ ```
55
+
56
+ Adding the above to your `spec_helper.rb` file automatically adds the key helper methods to the
57
+ `Minitest::Assertions` to test for Minitest errors raised or not raised within your tests.
58
+
59
+ <br>
60
+
61
+ ### `assert_have_error(expected_msg, klass = Minitest::Assertion, &blk)`
62
+ &nbsp; -- also aliased as: `assert_error_raised()`
63
+
64
+ Assertion method to test for an error raised by Minitest
65
+
66
+ ```ruby
67
+ assert_have_error('error message') { assert(false, 'error message') }
68
+
69
+ # or
70
+
71
+ proc {
72
+ assert(false, 'error message')
73
+ }.must_have_error('error message')
74
+
75
+ ```
76
+
77
+ Produces a longer error message, combining the given error message with the default error message,
78
+ when something is wrong.
79
+
80
+ **NOTE!** The expected error message can be a `String` or `Regexp`.
81
+
82
+ ```ruby
83
+ assert_have_error(/error message.+Actual:\s+\"b\"/m) do
84
+ assert_equal('a','b', 'error message')
85
+ end
86
+
87
+ # or
88
+
89
+ proc {
90
+ assert_equal('a','b', 'error message')
91
+ }.must_have_error(/error message.+Actual:\s+\"b\"/m)
92
+ ```
93
+
94
+ <br>
95
+
96
+ ### `assert_no_error(&blk)`
97
+ &nbsp; -- also aliased as: `refute_error()` or `refute_error_raised()` or `assert_no_error_raised()`
98
+
99
+
100
+ Assertion method to test for no error being raised by Minitest test.
101
+
102
+ ```ruby
103
+ assert_no_error() { assert(true, 'error message') }
104
+
105
+ # or
106
+
107
+ proc { assert(true) }.wont_have_error
108
+ ```
109
+
110
+ Produces a longer error message, combining the given error message with the default error message,
111
+ when something is wrong.
112
+
113
+ **NOTE!** The expected error message can be a `String` or `Regexp`.
114
+
115
+ ```ruby
116
+ assert_no_error { assert_equal('a', :a, 'error message') }
117
+
118
+ #=> "error message.\nExpected: \"a\"\n Actual: :a"
119
+
120
+ proc {
121
+ assert_equal('a', :a, 'error message')
122
+ }.wont_have_error
123
+
124
+ #=> "error message.\nExpected: \"a\"\n Actual: :a"
125
+ ```
126
+
127
+ <br>
128
+ ---
129
+
130
+ ## Dependencies
131
+
132
+ This Gem depends upon the following:
133
+
134
+ ### Runtime:
135
+
136
+ * minitest
137
+
138
+ ### Development & Tests:
139
+
140
+ * bundler (~> 1.10)
141
+ * rake (~> 10.0)
142
+ * minitest-rg
143
+
144
+ * simplecov [optional]
145
+ * rubocop [optional]
146
+
147
+ <br>
148
+
149
+
150
+
151
+ ## Contributing
152
+
153
+ Bug reports and pull requests are welcome on [GitHub](https://github.com/kematzy/minitest-have_tag).
154
+
155
+ This project is intended to be a safe, welcoming space for collaboration, and contributors are
156
+ expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
157
+
158
+ <br>
159
+
160
+
161
+ ## Note on Patches/Pull Requests
162
+
163
+ * Fork the project.
164
+ * Make your feature addition or bug fix in a separate branch.
165
+ * Add spec tests for it. This is important so I don't break it in a future version unintentionally.
166
+ * Commit, do not mess with Rakefile, version, or history.
167
+ * (if you want to have your own version, that is fine but bump version in a commit by itself
168
+ I can ignore when I pull)
169
+ * Send me a pull request. Bonus points for topic branches.
170
+
171
+
172
+ <br>
173
+
174
+ ## Development
175
+
176
+ After checking out the repo, run `bundle install` to install dependencies. Then, run
177
+ `bundle exec rake spec` to run the tests.
178
+
179
+ To install this gem onto your local machine, run `bundle exec rake install`.
180
+
181
+ To release a new version, update the version number in `version.rb`, and then run
182
+ `bundle exec rake release`, which will create a git tag for the version, push git commits and tags,
183
+ and push the `.gem` file to [rubygems.org](https://rubygems.org).
184
+
185
+ <br>
186
+
187
+
188
+ ## Copyright
189
+
190
+ Copyright (c) 2015 Kematzy
191
+
192
+ Released under the MIT License. See LICENSE for further details.
193
+
@@ -0,0 +1,23 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:spec) do |t|
5
+ t.libs << 'spec'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['spec/**/*_spec.rb']
8
+ end
9
+
10
+ task :default => :spec
11
+
12
+ desc 'Run specs with coverage'
13
+ task :coverage do
14
+ ENV['COVERAGE'] = '1'
15
+ Rake::Task['spec'].invoke
16
+ # `open coverage/index.html` # if OSX
17
+ end
18
+
19
+ desc 'Run Rubocop report'
20
+ task :rubocop do
21
+ `rubocop -f html -o ./Rubocop-report.html lib/`
22
+ # `open Rubocop-report.html` # if OSX
23
+ end
@@ -0,0 +1,76 @@
1
+ require 'minitest'
2
+ require 'minitest/assert_errors/version'
3
+
4
+ # reopening to add additional functionality
5
+ module Minitest::Assertions
6
+
7
+ # Assertion method to test for an error raised by Minitest
8
+ #
9
+ # assert_have_error('error message') { assert(false, 'error message') }
10
+ #
11
+ # proc { assert(false, 'error message') }.must_have_error('error message')
12
+ #
13
+ #
14
+ # Produces an extensive error message, combining the given error message with the default error
15
+ # message, when something is wrong.
16
+ #
17
+ # <b>NOTE!</b> The expected error message can be a +String+ or +Regexp+.
18
+ #
19
+ # assert_have_error(/error message.+Actual:\s+\"b\"/m) do
20
+ # assert_equal('a','b', 'error message')
21
+ # end
22
+ #
23
+ # # or
24
+ #
25
+ # proc {
26
+ # assert_equal('a','b', 'error message')
27
+ # }.must_have_error(/error message.+Actual:\s+\"b\"/m)
28
+ #
29
+ #
30
+ def assert_have_error(expected_msg, klass = Minitest::Assertion, &blk)
31
+ e = assert_raises(klass) do
32
+ yield(blk) if block_given?
33
+ end
34
+ assert_match(expected_msg, e.message) if expected_msg.is_a?(Regexp)
35
+ assert_equal(expected_msg, e.message) if expected_msg.is_a?(String)
36
+ end
37
+ alias_method :assert_error_raised, :assert_have_error
38
+ # backwards compat. DO NOT USE!
39
+ alias_method :assert_returns_error, :assert_have_error
40
+
41
+
42
+ # Assertion method to test for no error being raised by Minitest
43
+ #
44
+ # assert_no_error() { assert(true, 'error message') }
45
+ #
46
+ # proc { assert(true) }.wont_have_error
47
+ #
48
+ # Produces an extensive error message, combining the given error message with the default error
49
+ # message, when something is wrong.
50
+ #
51
+ # <b>NOTE!</b> The expected error message can be a +String+ or +Regexp+.
52
+ #
53
+ # assert_no_error { assert_equal('a', :a, 'error message') }
54
+ # #=> "error message.\nExpected: \"a\"\n Actual: :a"
55
+ #
56
+ # proc {
57
+ # assert_equal('a', :a, 'error message')
58
+ # }.wont_have_error
59
+ # #=> "error message.\nExpected: \"a\"\n Actual: :a"
60
+ #
61
+ def assert_no_error(&blk)
62
+ e = assert_silent do
63
+ yield(blk) if block_given?
64
+ end
65
+ end
66
+ alias_method :refute_error, :assert_no_error
67
+ alias_method :refute_error_raised, :assert_no_error
68
+ alias_method :assert_no_error_raised, :assert_no_error
69
+
70
+ end
71
+
72
+ # add support for Spec syntax
73
+ module Minitest::Expectations
74
+ infect_an_assertion :assert_have_error, :must_have_error, :block
75
+ infect_an_assertion :assert_no_error, :wont_have_error, :block
76
+ end
@@ -0,0 +1,8 @@
1
+
2
+ module Minitest
3
+
4
+ module AssertErrors
5
+ VERSION = '0.1.0'
6
+ end
7
+
8
+ end
@@ -0,0 +1,41 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'minitest/assert_errors/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'minitest-assert_errors'
8
+ spec.version = Minitest::AssertErrors::VERSION
9
+ spec.authors = ['Kematzy']
10
+ spec.email = ['kematzy@gmail.com']
11
+
12
+ spec.summary = %q{Adds Minitest assertions to test for errors raised or not raised by Minitest itself}
13
+ spec.description = %q{Adds Minitest assertions to test for errors raised or not raised by Minitest itself. Most useful when testing other Minitest assertions.}
14
+ spec.homepage = 'https://github.com/kematzy/minitest-assert_errors'
15
+ spec.license = 'MIT'
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ # end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec|features)/}) }
26
+ spec.bindir = 'exe'
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ['lib']
29
+
30
+ spec.add_runtime_dependency 'minitest'
31
+
32
+
33
+ spec.add_development_dependency 'bundler', '~> 1.10'
34
+ spec.add_development_dependency 'rake', '~> 10.0'
35
+ # spec.add_development_dependency 'minitest'
36
+ spec.add_development_dependency 'minitest-rg'
37
+
38
+ spec.add_development_dependency 'simplecov'
39
+ spec.add_development_dependency 'rubocop'
40
+
41
+ end
metadata ADDED
@@ -0,0 +1,140 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minitest-assert_errors
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kematzy
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-11-26 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: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest-rg
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Adds Minitest assertions to test for errors raised or not raised by Minitest
98
+ itself. Most useful when testing other Minitest assertions.
99
+ email:
100
+ - kematzy@gmail.com
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".travis.yml"
107
+ - CODE_OF_CONDUCT.md
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - lib/minitest/assert_errors.rb
113
+ - lib/minitest/assert_errors/version.rb
114
+ - minitest-assert_errors.gemspec
115
+ homepage: https://github.com/kematzy/minitest-assert_errors
116
+ licenses:
117
+ - MIT
118
+ metadata: {}
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 2.4.5
136
+ signing_key:
137
+ specification_version: 4
138
+ summary: Adds Minitest assertions to test for errors raised or not raised by Minitest
139
+ itself
140
+ test_files: []