minitest-extra-assertions 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +29 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +23 -0
- data/Rakefile +45 -0
- data/VERSION +1 -0
- data/lib/minitest-extra-assertions.rb +22 -0
- data/test/helper.rb +18 -0
- data/test/test_minitest-extra-assertions.rb +90 -0
- metadata +116 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "minitest", "~> 2.0"
|
10
|
+
gem "shoulda", ">= 0"
|
11
|
+
gem "rdoc", "~> 3.12"
|
12
|
+
gem "bundler", "~> 1.0"
|
13
|
+
gem "jeweler", "~> 1.8.3"
|
14
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
git (1.2.5)
|
5
|
+
jeweler (1.8.3)
|
6
|
+
bundler (~> 1.0)
|
7
|
+
git (>= 1.2.5)
|
8
|
+
rake
|
9
|
+
rdoc
|
10
|
+
json (1.6.6)
|
11
|
+
minitest (2.12.1)
|
12
|
+
rake (0.9.2.2)
|
13
|
+
rdoc (3.12)
|
14
|
+
json (~> 1.4)
|
15
|
+
shoulda (3.0.1)
|
16
|
+
shoulda-context (~> 1.0.0)
|
17
|
+
shoulda-matchers (~> 1.0.0)
|
18
|
+
shoulda-context (1.0.0)
|
19
|
+
shoulda-matchers (1.0.0)
|
20
|
+
|
21
|
+
PLATFORMS
|
22
|
+
ruby
|
23
|
+
|
24
|
+
DEPENDENCIES
|
25
|
+
bundler (~> 1.0)
|
26
|
+
jeweler (~> 1.8.3)
|
27
|
+
minitest (~> 2.0)
|
28
|
+
rdoc (~> 3.12)
|
29
|
+
shoulda
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Ben Somers
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
= minitest-extra-assertions
|
2
|
+
|
3
|
+
Additional assertions for seattlerb's popular MiniTest framework: https://github.com/seattlerb/minitest. Mostly
|
4
|
+
aimed around improving compatibility with test-unit. Still not intended
|
5
|
+
to provide a full drop-in replacement for test-unit; but this should
|
6
|
+
salve the headaches involved in switching.
|
7
|
+
|
8
|
+
== Installing minitest-extra-assertions
|
9
|
+
1. Add it to your Gemfile.
|
10
|
+
|
11
|
+
== Contributing to minitest-extra-assertions
|
12
|
+
|
13
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
14
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
15
|
+
* Fork the project.
|
16
|
+
* Start a feature/bugfix branch.
|
17
|
+
* Commit and push until you are happy with your contribution.
|
18
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
19
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
20
|
+
|
21
|
+
== Copyright
|
22
|
+
|
23
|
+
Copyright (c) 2012 Ben Somers. See LICENSE.txt for further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "minitest-extra-assertions"
|
18
|
+
gem.homepage = "http://github.com/bensomers/minitest-extra-assertions"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Extra assertions for MiniTest}
|
21
|
+
gem.description = %Q{Additional assertions for seattlerb's popular MiniTest framework. Mostly aimed around improving compatibility with test-unit.}
|
22
|
+
gem.email = "somers.ben@gmail.com"
|
23
|
+
gem.authors = ["Ben Somers"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
task :default => :test
|
36
|
+
|
37
|
+
require 'rdoc/task'
|
38
|
+
Rake::RDocTask.new do |rdoc|
|
39
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
40
|
+
|
41
|
+
rdoc.rdoc_dir = 'rdoc'
|
42
|
+
rdoc.title = "minitest-extra-assertions #{version}"
|
43
|
+
rdoc.rdoc_files.include('README*')
|
44
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
45
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module MiniTest
|
2
|
+
module Assertions
|
3
|
+
def assert_false obj, msg = nil
|
4
|
+
msg = message(msg) { "<false> expected but was #{mu_pp(obj)}" }
|
5
|
+
assert obj == false, msg
|
6
|
+
end
|
7
|
+
|
8
|
+
def assert_true obj, msg = nil
|
9
|
+
msg = message(msg) { "<true> expected but was #{mu_pp(obj)}" }
|
10
|
+
assert obj == true, msg
|
11
|
+
end
|
12
|
+
|
13
|
+
# This is pull-requested for minitest proper, hopefully will be merged soon
|
14
|
+
def assert_match exp, act, msg = nil
|
15
|
+
msg = message(msg) { "Expected #{mu_pp(exp)} to match #{mu_pp(act)}" }
|
16
|
+
assert_respond_to act, "=~"
|
17
|
+
exp = Regexp.new(Regexp.escape(exp)) if String === exp
|
18
|
+
assert act =~ exp, msg
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'minitest-extra-assertions'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestMinitestExtraAssertions < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
|
7
|
+
MiniTest::Unit::TestCase.reset
|
8
|
+
|
9
|
+
@tc = MiniTest::Unit::TestCase.new 'fake tc'
|
10
|
+
@zomg = "zomg ponies!"
|
11
|
+
@assertion_count = 1
|
12
|
+
end
|
13
|
+
|
14
|
+
def teardown
|
15
|
+
assert_equal(@assertion_count, @tc._assertions,
|
16
|
+
"expected #{@assertion_count} assertions to be fired during the test, not #{@tc._assertions}") if @tc._assertions
|
17
|
+
Object.send :remove_const, :ATestCase if defined? ATestCase
|
18
|
+
end
|
19
|
+
|
20
|
+
def util_assert_triggered expected, klass = MiniTest::Assertion
|
21
|
+
e = assert_raises(klass) do
|
22
|
+
yield
|
23
|
+
end
|
24
|
+
|
25
|
+
msg = e.message.sub(/(---Backtrace---).*/m, '\1')
|
26
|
+
msg.gsub!(/\(oid=[-0-9]+\)/, '(oid=N)')
|
27
|
+
|
28
|
+
assert_equal expected, msg
|
29
|
+
end
|
30
|
+
|
31
|
+
context ".assert_true" do
|
32
|
+
should "return true for true" do
|
33
|
+
@assertion_count = 1
|
34
|
+
|
35
|
+
assert_equal true, @tc.assert_true(true), "returns true for true"
|
36
|
+
end
|
37
|
+
|
38
|
+
should "be triggered for false or nil" do
|
39
|
+
@assertion_count = 2
|
40
|
+
|
41
|
+
util_assert_triggered "<true> expected but was false." do
|
42
|
+
@tc.assert_true false
|
43
|
+
end
|
44
|
+
util_assert_triggered "<true> expected but was nil." do
|
45
|
+
@tc.assert_true nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
should "be triggered for things that aren't true but evaluate to true" do
|
50
|
+
@assertion_count = 1
|
51
|
+
|
52
|
+
util_assert_triggered "<true> expected but was Object." do
|
53
|
+
@tc.assert_true Object
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context ".assert_false" do
|
59
|
+
should "return true for false" do
|
60
|
+
@assertion_count = 1
|
61
|
+
|
62
|
+
assert_equal true, @tc.assert_false(false), "returns true for false"
|
63
|
+
end
|
64
|
+
|
65
|
+
should "be triggered for nil" do
|
66
|
+
@assertion_count = 1
|
67
|
+
|
68
|
+
util_assert_triggered "<false> expected but was nil." do
|
69
|
+
@tc.assert_false nil
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
should "be triggered for things that evalute to true" do
|
74
|
+
@assertion_count = 1
|
75
|
+
|
76
|
+
util_assert_triggered "<false> expected but was Object." do
|
77
|
+
@tc.assert_false Object
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# This is pull-requested for minitest proper, hopefully will be merged soon
|
83
|
+
def test_assert_match_unusual_object
|
84
|
+
@assertion_count = 2
|
85
|
+
unusual_object = Object.new
|
86
|
+
def unusual_object.=~(other) true end
|
87
|
+
@tc.assert_match /pattern/, unusual_object
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: minitest-extra-assertions
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ben Somers
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: minitest
|
16
|
+
requirement: &70244354802520 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '2.0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70244354802520
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: shoulda
|
27
|
+
requirement: &70244354817600 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70244354817600
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rdoc
|
38
|
+
requirement: &70244354816100 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '3.12'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70244354816100
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: bundler
|
49
|
+
requirement: &70244354813680 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70244354813680
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: jeweler
|
60
|
+
requirement: &70244354812480 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 1.8.3
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70244354812480
|
69
|
+
description: Additional assertions for seattlerb's popular MiniTest framework. Mostly
|
70
|
+
aimed around improving compatibility with test-unit.
|
71
|
+
email: somers.ben@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files:
|
75
|
+
- LICENSE.txt
|
76
|
+
- README.rdoc
|
77
|
+
files:
|
78
|
+
- .document
|
79
|
+
- Gemfile
|
80
|
+
- Gemfile.lock
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.rdoc
|
83
|
+
- Rakefile
|
84
|
+
- VERSION
|
85
|
+
- lib/minitest-extra-assertions.rb
|
86
|
+
- test/helper.rb
|
87
|
+
- test/test_minitest-extra-assertions.rb
|
88
|
+
homepage: http://github.com/bensomers/minitest-extra-assertions
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ! '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
segments:
|
102
|
+
- 0
|
103
|
+
hash: 4398898394209274623
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 1.8.17
|
113
|
+
signing_key:
|
114
|
+
specification_version: 3
|
115
|
+
summary: Extra assertions for MiniTest
|
116
|
+
test_files: []
|