minitest-bonus-assertions 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: 34a1d4e2eb4c1707a301a7c716e5d8f39c961ff1
4
+ data.tar.gz: 7d72041f067772a9634b299c9cb9eecc7ba337f4
5
+ SHA512:
6
+ metadata.gz: 90691c38fede3f41b44f488646e67d3f5626c602361f775ecd3ae3423fe6e7381bb9c9ba5c53c1b8723ccba2460876c5dc3cb00369c9536b075a7ea12a898850
7
+ data.tar.gz: 17bd17bba6f87c5f128723eeb2932d3be938275c8a8ff478cf62a9d8c67faa8124cdb2eef3dc689bf5f3c109cd53e0385c799edb2774bb4cf4492f211c415810
@@ -0,0 +1,27 @@
1
+ # -*- ruby -*-
2
+
3
+ require "autotest/restart"
4
+
5
+ Autotest.add_hook :initialize do |at|
6
+ # .minitest.rb ensures that the gem version of minitest is used.
7
+ at.testlib = ".minitest.rb"
8
+ # at.testlib = "minitest/unit"
9
+ #
10
+ # at.extra_files << "../some/external/dependency.rb"
11
+ #
12
+ # at.libs << ":../some/external"
13
+ #
14
+ # at.add_exception "vendor"
15
+ #
16
+ # at.add_mapping(/dependency.rb/) do |f, _|
17
+ # at.files_matching(/test_.*rb$/)
18
+ # end
19
+ #
20
+ # %w(TestA TestB).each do |klass|
21
+ # at.extra_class_map[klass] = "test/test_misc.rb"
22
+ # end
23
+ end
24
+
25
+ # Autotest.add_hook :run_command do |at|
26
+ # system "rake build"
27
+ # end
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,2 @@
1
+ gem "minitest"
2
+ require "minitest/autorun"
@@ -0,0 +1,35 @@
1
+ ---
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.0
5
+ - 2.1.0
6
+ - 2.0.0
7
+ - 1.9.3
8
+ - ruby-head
9
+ - jruby-19mode
10
+ - jruby-head
11
+ - rbx-2
12
+ matrix:
13
+ allow_failures:
14
+ - rvm: rbx-2
15
+ - rvm: jruby-head
16
+ - rvm: ruby-head
17
+ gemfile:
18
+ - Gemfile
19
+ before_script:
20
+ - |
21
+ case "${TRAVIS_RUBY_VERSION}" in
22
+ rbx*)
23
+ gem install psych
24
+ ;;
25
+ esac
26
+ - rake travis:before -t
27
+ script: rake travis
28
+ after_script:
29
+ - rake travis:after -t
30
+ notifications:
31
+ email:
32
+ recipients:
33
+ - halostatue@gmail.com
34
+ on_success: change
35
+ on_failure: always
@@ -0,0 +1,5 @@
1
+ #! zsh
2
+
3
+ --workenv-tab --first
4
+ --workenv-tab --desc autotest autotest
5
+ --workenv-tab --desc documents "fswatch -o *.rdoc lib/**/*.rb| xargs -n1 -I{} rake docs"
@@ -0,0 +1,67 @@
1
+ == Contributing
2
+
3
+ I value any contribution to minitest-bonus-assertions you can provide: a bug
4
+ report, a feature request, or code contributions.
5
+
6
+ As minitest-bonus-assertions is a mature codebase, there are a few guidelines:
7
+
8
+ * Changes *will* *not* be accepted without tests. The test suite is written
9
+ with {Minitest}[https://github.com/seattlerb/minitest] (of course).
10
+ * Match my coding style.
11
+ * Use a thoughtfully-named topic branch that contains your change. Rebase your
12
+ commits into logical chunks as necessary.
13
+ * Use {quality commit messages}[http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html].
14
+ * Do not change the version number; when your patch is accepted and a release
15
+ is made, the version will be updated at that point.
16
+ * Submit a GitHub pull request with your changes.
17
+ * New behaviours require new or updated documentation.
18
+
19
+ === Test Dependencies
20
+
21
+ minitest-bonus-assertions uses Ryan Davis’s
22
+ {Hoe}[https://github.com/seattlerb/hoe] to manage the release process, and it
23
+ adds a number of rake tasks. You will mostly be interested in:
24
+
25
+ $ rake
26
+
27
+ which runs the tests the same way that:
28
+
29
+ $ rake test
30
+ $ rake travis
31
+
32
+ will do.
33
+
34
+ To assist with the installation of the development dependencies for
35
+ minitest-bonus-assertions, I have provided the simplest possible Gemfile
36
+ pointing to the (generated) +minitest-bonus-assertions.gemspec+ file. This will
37
+ permit you to do:
38
+
39
+ $ bundle install
40
+
41
+ to get the development dependencies. If you aleady have +hoe+ installed, you
42
+ can accomplish the same thing with:
43
+
44
+ $ rake newb
45
+
46
+ This task will install any missing dependencies, run the tests/specs, and
47
+ generate the RDoc.
48
+
49
+ === Workflow
50
+
51
+ Here's the most direct way to get your work merged into the project:
52
+
53
+ * Fork the project.
54
+ * Clone down your fork (<tt>git clone git://github.com/halostatue/minitest-bonus-assertions.git</tt>).
55
+ * Create a topic branch to contain your change (<tt>git checkout -b my\_awesome\_feature</tt>).
56
+ * Hack away, add tests. Not necessarily in that order.
57
+ * Make sure everything still passes by running +rake+.
58
+ * If necessary, rebase your commits into logical chunks, without errors.
59
+ * Push the branch up (<tt>git push origin my\_awesome\_feature</tt>).
60
+ * Create a pull request against halostatue/minitest-bonus-assertions and describe
61
+ what your change does and the why you think it should be merged.
62
+
63
+ === Contributors
64
+
65
+ * Austin Ziegler forked minitest-bonus-assertions.
66
+ * Ben Somers (@bensomers) created minitest-extra-assertions
67
+ * Justin George (@jaggederest) added assert_between.
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ # -*- ruby -*-
2
+
3
+ # NOTE: This file is present to keep Travis CI happy. Edits to it will not
4
+ # be accepted.
5
+
6
+ source "https://rubygems.org/"
7
+ gemspec
8
+
9
+ # vim: syntax=ruby
@@ -0,0 +1,5 @@
1
+ === 1.0 / 2015-03-05
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
@@ -0,0 +1,24 @@
1
+ == Licence
2
+
3
+ This software is available under an MIT-style licence.
4
+
5
+ * Copyright 2015 Austin Ziegler
6
+ * Copyright 2012 Ben Somers
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
9
+ this software and associated documentation files (the "Software"), to deal in
10
+ the Software without restriction, including without limitation the rights to
11
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12
+ of the Software, and to permit persons to whom the Software is furnished to do
13
+ so, subject to the following conditions.
14
+
15
+ The above copyright notice and this permission notice shall be included in all
16
+ copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.
@@ -0,0 +1,17 @@
1
+ .autotest
2
+ .document
3
+ .gemtest
4
+ .minitest.rb
5
+ .travis.yml
6
+ .workenv
7
+ Contributing.rdoc
8
+ Gemfile
9
+ History.rdoc
10
+ Licence.rdoc
11
+ Manifest.txt
12
+ README.rdoc
13
+ Rakefile
14
+ VERSION
15
+ lib/minitest-bonus-assertions.rb
16
+ test/minitest_config.rb
17
+ test/test_minitest-bonus-assertions.rb
@@ -0,0 +1,58 @@
1
+ = minitest-bonus-assertions
2
+
3
+ code :: https://github.com/halostatue/minitest-bonus-assertions
4
+ bugs :: https://github.com/halostatue/minitest-bonus-assertions/issues
5
+ continuous integration :: {<img src="https://travis-ci.org/halostatue/minitest-bonus-assertions.png" />}[https://travis-ci.org/halostatue/minitest-bonus-assertions]
6
+
7
+ == Description
8
+
9
+ Additional assertions for {Minitest}[https://github.com/seattlerb/minitest].
10
+
11
+ == Features
12
+
13
+ New assertions:
14
+
15
+ assert_false, must_be_false
16
+ assert_true, must_Be_true
17
+ assert_between, must_be_between
18
+ assert_has_keys, must_have_keys
19
+ assert_missing_keys, must_not_have_keys
20
+ assert_raises_with_message, must_raise_with_message
21
+
22
+ == Background
23
+
24
+ minitest-bonus-assertions started life as a patch to the assertions provided by
25
+ Ben Somer’s
26
+ {minitest-extra-assertions}[https://github.com/bensomers/minitest-extra-assertions].
27
+ There were some nice assertions included, but there were other changes that
28
+ needed to be made to bring it up to support Minitest 5. There was also an
29
+ override to the default +assert_match+ implementation meant to ease the
30
+ transition from Test::Unit (the main reason he wrote this assertion plugin for
31
+ Minitest in the first place). I do not believe this is sensible five major
32
+ versions in: I removed it.
33
+
34
+ Because Ben did not feel comfortable making this particular change, I felt that
35
+ the best way to provide the original assertions and my new assertions—without
36
+ the +assert_match+ override—was to fork this as a new project. I am indebted to
37
+ Ben for writing these assertions in the first place.
38
+
39
+ == Install
40
+
41
+ Add it to your Gemfile:
42
+
43
+ gem 'minitest-bonus-assertions', '~> 1.0'
44
+
45
+ Or manually install:
46
+
47
+ % gem install minitest-bonus-assertions
48
+
49
+ == minitest-bonus-assertions Semantic Versioning
50
+
51
+ minitest-bonus-assertions uses a {Semantic Versioning}[http://semver.org/]
52
+ scheme with one change:
53
+
54
+ * When PATCH is zero (+0+), it will be omitted from version references.
55
+
56
+ :include: Contributing.rdoc
57
+
58
+ :include: Licence.rdoc
@@ -0,0 +1,53 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require 'rake/clean'
6
+
7
+ Hoe.plugin :doofus
8
+ Hoe.plugin :gemspec2
9
+ Hoe.plugin :git
10
+ Hoe.plugin :minitest
11
+ Hoe.plugin :travis
12
+ Hoe.plugin :email unless ENV['CI'] or ENV['TRAVIS']
13
+
14
+ spec = Hoe.spec 'minitest-bonus-assertions' do
15
+ developer('Austin Ziegler', 'halostatue@gmail.com')
16
+
17
+ self.history_file = 'History.rdoc'
18
+ self.readme_file = 'README.rdoc'
19
+ self.extra_rdoc_files = FileList["*.rdoc"].to_a
20
+
21
+ license "MIT"
22
+
23
+ self.need_tar = true
24
+ self.require_ruby_version '>= 1.9.2'
25
+
26
+ self.extra_dev_deps << ['hoe-doofus', '~> 1.0']
27
+ self.extra_dev_deps << ['hoe-gemspec2', '~> 1.1']
28
+ self.extra_dev_deps << ['hoe-git', '~> 1.5']
29
+ self.extra_dev_deps << ['hoe-travis', '~> 1.2']
30
+ self.extra_dev_deps << ['minitest', '~> 5.4']
31
+ self.extra_dev_deps << ['minitest-around', '~> 0.3']
32
+ self.extra_dev_deps << ['minitest-autotest', '~> 1.0']
33
+ self.extra_dev_deps << ['minitest-bisect', '~> 1.2']
34
+ self.extra_dev_deps << ['minitest-focus', '~> 1.1']
35
+ self.extra_dev_deps << ['minitest-moar', '~> 0.0']
36
+ self.extra_dev_deps << ['minitest-pretty_diff', '~> 0.1']
37
+ self.extra_dev_deps << ['rake', '>= 10.0']
38
+ self.extra_dev_deps << ['simplecov', '~> 0.7']
39
+ end
40
+
41
+ namespace :test do
42
+ task :coverage do
43
+ spec.test_prelude = [
44
+ 'require "simplecov"',
45
+ 'SimpleCov.start("test_frameworks") { command_name "Minitest" }',
46
+ 'gem "minitest"'
47
+ ].join('; ')
48
+ Rake::Task['test'].execute
49
+ end
50
+ CLOBBER << 'coverage'
51
+ end
52
+
53
+ # vim: syntax=ruby
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.0
@@ -0,0 +1,134 @@
1
+ module Minitest
2
+ module BonusAssertions
3
+ VERSION = '1.0'
4
+ end
5
+ module Assertions
6
+ ##
7
+ # Fails unless +obj+ is literally +false+.
8
+
9
+ def assert_false obj, msg = nil
10
+ msg = message(msg) { "<false> expected but was #{mu_pp(obj)}" }
11
+ assert obj == false, msg
12
+ end
13
+
14
+ ##
15
+ # Fails unless +obj+ is literally +true+.
16
+
17
+ def assert_true obj, msg = nil
18
+ msg = message(msg) { "<true> expected but was #{mu_pp(obj)}" }
19
+ assert obj == true, msg
20
+ end
21
+
22
+ ##
23
+ # Fails unless +exp+ is between +lo+ and +hi+, or is in +range+.
24
+ #
25
+ # :call-seq:
26
+ # assert_between lo, hi, exp, msg = nil
27
+ # assert_between range, exp, msg = nil
28
+
29
+ def assert_between(*args)
30
+ lo, hi, exp, msg = if args.first.is_a?(Range)
31
+ [args.first.begin, args.first.end, args[1], args[2]]
32
+ else
33
+ args[0..3]
34
+ end
35
+ lo, hi = hi, lo if lo > hi
36
+ msg = message(msg) { "Expected #{mu_pp(exp)} to be between #{mu_pp(lo)} and #{mu_pp(hi)}" }
37
+ assert (lo < exp && exp < hi), msg
38
+ end
39
+
40
+ ##
41
+ # Fails unless +obj+ has all of the +keys+ listed.
42
+ def assert_has_keys obj, keys, msg = nil
43
+ keys = [ keys ] unless keys.is_a?(Array)
44
+ msg = message(msg) { "Expected #{mu_pp(obj)} to include all keys #{mu_pp(keys)}" }
45
+ keys.all? { |key| assert obj.key?(key), msg }
46
+ end
47
+ alias_method :refute_missing_keys, :assert_has_keys
48
+
49
+ ##
50
+ # Fails if +obj+ has any of the keys listed.
51
+ def assert_missing_keys obj, keys, msg = nil
52
+ keys = [ keys ] unless keys.is_a?(Array)
53
+ msg = message(msg) { "Expected #{mu_pp(obj)} not to include any of these keys #{mu_pp(keys)}" }
54
+ keys.none? { |key| refute obj.key?(key), msg }
55
+ end
56
+ alias_method :refute_has_keys, :assert_missing_keys
57
+
58
+ ##
59
+ # Fails unless the block raises +exp+ with the message +exp_msg+. Returns
60
+ # the exception matched so you can check other attributes.
61
+ def assert_raises_with_message exp, exp_msg, msg = nil
62
+ msg = message(msg) { "#{mu_pp(exp)} exception expected with message #{mu_pp(exp_msg)}" }
63
+
64
+ exception = assert_raises exp do
65
+ yield
66
+ end
67
+
68
+ assert_equal exp_msg, exception.message, msg
69
+ exception
70
+ end
71
+ end
72
+
73
+ module Expectations
74
+ ##
75
+ # See Minitest::Assertions#assert_false
76
+ #
77
+ # false.must_be_false
78
+ #
79
+ # :method: must_be_false
80
+
81
+ infect_an_assertion :assert_false, :must_be_false, :unary
82
+
83
+ ##
84
+ # See Minitest::Assertions#assert_true
85
+ #
86
+ # true.must_be_true
87
+ #
88
+ # :method: must_be_true
89
+
90
+ infect_an_assertion :assert_true, :must_be_true, :unary
91
+
92
+ ##
93
+ # See Minitest::Assertions#assert_between
94
+ #
95
+ # 2.must_be_between 1, 3
96
+ # 2.must_be_between 1..3
97
+
98
+ def must_be_between *args
99
+ hi, lo, msg = if args.first.is_a?(Range)
100
+ [args.first.begin, args.first.end, args[1]]
101
+ else
102
+ args[0..2]
103
+ end
104
+ assert_between lo, hi, self
105
+ end
106
+
107
+ ##
108
+ # See Minitest::Assertions#assert_has_keys
109
+ #
110
+ # hash.must_have_keys %w(a b c)
111
+ #
112
+ # :method: must_have_keys
113
+
114
+ infect_an_assertion :assert_has_keys, :must_have_keys, :unary
115
+
116
+ ##
117
+ # See Minitest::Assertions#assert_missing_keys
118
+ #
119
+ # hash.must_not_have_keys %w(a b c)
120
+ #
121
+ # :method: must_not_have_keys
122
+
123
+ infect_an_assertion :assert_missing_keys, :must_not_have_keys, :unary
124
+
125
+ ##
126
+ # See Minitest::Assertions#assert_raises_with_message
127
+ #
128
+ # proc { ... }.must_raise_with_message exception, message
129
+ #
130
+ # :method: must_raise_with_message
131
+
132
+ infect_an_assertion :assert_raises_with_message, :must_raise_with_message
133
+ end
134
+ end
@@ -0,0 +1,42 @@
1
+ gem 'minitest'
2
+ require 'minitest/autorun'
3
+ require 'minitest/pretty_diff'
4
+ require 'minitest/focus'
5
+ require 'minitest/moar'
6
+ require 'minitest/bisect'
7
+
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
@@ -0,0 +1,164 @@
1
+ # coding: utf-8
2
+
3
+ require 'minitest_config'
4
+
5
+ describe Minitest::BonusAssertions do
6
+ describe ".assert_true" do
7
+ it "return true for true" do
8
+ @assertion_count = 1
9
+
10
+ assert_equal true, @tc.assert_true(true), "returns true for true"
11
+ end
12
+
13
+ it "be triggered for false or nil" do
14
+ @assertion_count = 2
15
+
16
+ util_assert_triggered "<true> expected but was false." do
17
+ @tc.assert_true false
18
+ end
19
+ util_assert_triggered "<true> expected but was nil." do
20
+ @tc.assert_true nil
21
+ end
22
+ end
23
+
24
+ it "be triggered for things that aren't true but evaluate to true" do
25
+ @assertion_count = 1
26
+
27
+ util_assert_triggered "<true> expected but was Object." do
28
+ @tc.assert_true Object
29
+ end
30
+ end
31
+ end
32
+
33
+ describe ".assert_false" do
34
+ it "return true for false" do
35
+ @assertion_count = 1
36
+
37
+ assert_equal true, @tc.assert_false(false), "returns true for false"
38
+ end
39
+
40
+ it "be triggered for nil" do
41
+ @assertion_count = 1
42
+
43
+ util_assert_triggered "<false> expected but was nil." do
44
+ @tc.assert_false nil
45
+ end
46
+ end
47
+
48
+ it "be triggered for things that evalute to true" do
49
+ @assertion_count = 1
50
+
51
+ util_assert_triggered "<false> expected but was Object." do
52
+ @tc.assert_false Object
53
+ end
54
+ end
55
+ end
56
+
57
+ describe ".assert_between" do
58
+ it "return true for basic integers" do
59
+ @assertion_count = 1
60
+ assert_equal true, @tc.assert_between(1,10,5), "returns true for 1 to 10 and 5"
61
+ end
62
+
63
+ it "return true for the range case" do
64
+ @assertion_count = 1
65
+ assert_equal true, @tc.assert_between((1..10), 5), "returns true for 1..10 with 5"
66
+ end
67
+
68
+ it "handle the case where the hi part is first" do
69
+ @assertion_count = 1
70
+ assert_equal true, @tc.assert_between(10, 1, 5), "returns true for 10 to 1, with 5"
71
+ end
72
+
73
+ it "return false for values outside the bounds" do
74
+ @assertion_count = 1
75
+ util_assert_triggered "Expected 100 to be between 1 and 10." do
76
+ @tc.assert_between(1, 10, 100)
77
+ end
78
+ end
79
+
80
+ it "raise error for incompatible values" do
81
+ @assertion_count = 0
82
+ assert_raises ArgumentError do
83
+ @tc.assert_between(1, 10, Time.now)
84
+ end
85
+ end
86
+ end
87
+
88
+ describe ".assert_has_keys" do
89
+ it "return true if the keys are present" do
90
+ @assertion_count = 1
91
+ assert_equal true, @tc.assert_has_keys({ "a" => 1 }, "a"), %Q(returns true for key 'a' in {"a"=>1})
92
+ end
93
+
94
+ it "be triggered for a missing value" do
95
+ @assertion_count = 2
96
+ hash = { "a" => 1 }
97
+ keys = %w(a b)
98
+ util_assert_triggered %Q(Expected #{mu_pp(hash)} to include all keys #{mu_pp(keys)}.) do
99
+ @tc.assert_has_keys(hash, keys)
100
+ end
101
+ end
102
+
103
+ it "raise error for incompatible values" do
104
+ @assertion_count = 0
105
+ assert_raises NoMethodError do
106
+ @tc.assert_has_keys([], "a")
107
+ end
108
+ end
109
+ end
110
+
111
+ describe ".assert_missing_keys" do
112
+ it "return true if the keys are missing" do
113
+ @assertion_count = 1
114
+ assert_equal true, @tc.assert_missing_keys({ "a" => 1 }, "b"), "returns true for key 'b' missing from { 'a' => 1 }"
115
+ end
116
+
117
+ it "be triggered for a present value" do
118
+ @assertion_count = 1
119
+ hash = { "a" => 1 }
120
+ keys = %w(a b)
121
+ util_assert_triggered %Q(Expected #{mu_pp(hash)} not to include any of these keys #{mu_pp(keys)}.) do
122
+ @tc.assert_missing_keys(hash, keys)
123
+ end
124
+ end
125
+
126
+ it "raise error for incompatible values" do
127
+ @assertion_count = 0
128
+ assert_raises NoMethodError do
129
+ @tc.assert_missing_keys([], "a")
130
+ end
131
+ end
132
+ end
133
+
134
+ describe ".assert_raises_with_message" do
135
+ it "return the matched exception if the exception and message match" do
136
+ @assertion_count = 2
137
+
138
+ res = @tc.assert_raises_with_message(ArgumentError, "Don't have a cow, man!") do
139
+ raise ArgumentError, "Don't have a cow, man!"
140
+ end
141
+
142
+ assert_kind_of ArgumentError, res
143
+ end
144
+
145
+ it "is triggered with a different exception" do
146
+ @assertion_count = 1
147
+
148
+ util_assert_triggered %Q(#{mu_pp([ArgumentError])} exception expected, not\nClass: <NoMethodError>\nMessage: <"NoMethodError">\n---Backtrace---) do
149
+ @tc.assert_raises_with_message(ArgumentError, "Don’t have a cow, man!") do
150
+ raise NoMethodError
151
+ end
152
+ end
153
+ end
154
+
155
+ it "be triggered with a different message" do
156
+ @assertion_count = 2
157
+ util_assert_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
158
+ @tc.assert_raises_with_message(ArgumentError, "Don’t have a cow, man!") do
159
+ raise ArgumentError, "Have a cow, man!"
160
+ end
161
+ end
162
+ end
163
+ end
164
+ end
metadata ADDED
@@ -0,0 +1,278 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minitest-bonus-assertions
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ platform: ruby
6
+ authors:
7
+ - Austin Ziegler
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-05 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.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rdoc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: hoe-doofus
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: hoe-gemspec2
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: hoe-git
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.5'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.5'
83
+ - !ruby/object:Gem::Dependency
84
+ name: hoe-travis
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.2'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: minitest-around
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.3'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.3'
111
+ - !ruby/object:Gem::Dependency
112
+ name: minitest-autotest
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: minitest-bisect
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.2'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1.2'
139
+ - !ruby/object:Gem::Dependency
140
+ name: minitest-focus
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '1.1'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '1.1'
153
+ - !ruby/object:Gem::Dependency
154
+ name: minitest-moar
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: minitest-pretty_diff
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '0.1'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '0.1'
181
+ - !ruby/object:Gem::Dependency
182
+ name: rake
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '10.0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '10.0'
195
+ - !ruby/object:Gem::Dependency
196
+ name: simplecov
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: '0.7'
202
+ type: :development
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: '0.7'
209
+ - !ruby/object:Gem::Dependency
210
+ name: hoe
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: '3.13'
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: '3.13'
223
+ description: Additional assertions for {Minitest}[https://github.com/seattlerb/minitest].
224
+ email:
225
+ - halostatue@gmail.com
226
+ executables: []
227
+ extensions: []
228
+ extra_rdoc_files:
229
+ - Contributing.rdoc
230
+ - History.rdoc
231
+ - Licence.rdoc
232
+ - Manifest.txt
233
+ - README.rdoc
234
+ files:
235
+ - ".autotest"
236
+ - ".document"
237
+ - ".gemtest"
238
+ - ".minitest.rb"
239
+ - ".travis.yml"
240
+ - ".workenv"
241
+ - Contributing.rdoc
242
+ - Gemfile
243
+ - History.rdoc
244
+ - Licence.rdoc
245
+ - Manifest.txt
246
+ - README.rdoc
247
+ - Rakefile
248
+ - VERSION
249
+ - lib/minitest-bonus-assertions.rb
250
+ - test/minitest_config.rb
251
+ - test/test_minitest-bonus-assertions.rb
252
+ homepage: https://github.com/halostatue/minitest-bonus-assertions
253
+ licenses:
254
+ - MIT
255
+ metadata: {}
256
+ post_install_message:
257
+ rdoc_options:
258
+ - "--main"
259
+ - README.rdoc
260
+ require_paths:
261
+ - lib
262
+ required_ruby_version: !ruby/object:Gem::Requirement
263
+ requirements:
264
+ - - ">="
265
+ - !ruby/object:Gem::Version
266
+ version: 1.9.2
267
+ required_rubygems_version: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - ">="
270
+ - !ruby/object:Gem::Version
271
+ version: '0'
272
+ requirements: []
273
+ rubyforge_project:
274
+ rubygems_version: 2.2.2
275
+ signing_key:
276
+ specification_version: 4
277
+ summary: Additional assertions for {Minitest}[https://github.com/seattlerb/minitest].
278
+ test_files: []