assertions-eb 1.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/History.txt +25 -0
- data/LICENSE +22 -0
- data/Manifest.txt +8 -0
- data/README.rdoc +129 -0
- data/README.txt +129 -0
- data/Rakefile +10 -0
- data/assertions.gemspec +20 -0
- data/examples/example.rb +69 -0
- data/lib/assertions/version.rb +3 -0
- data/lib/assertions.rb +376 -0
- data/test/assert_between_test.rb +46 -0
- data/test/assert_fail_test.rb +22 -0
- data/test/assert_greater_than_or_equal_to_test.rb +16 -0
- data/test/assert_greater_than_test.rb +16 -0
- data/test/assert_less_than_test.rb +16 -0
- data/test/assert_less_than_test_or_equal_to_test.rb +16 -0
- data/test/assert_negative_test.rb +24 -0
- data/test/assert_not_test.rb +20 -0
- data/test/assert_positive_test.rb +24 -0
- data/test/assert_raise_message_test.rb +32 -0
- data/test/assert_sorted_by_desc_test.rb +71 -0
- data/test/assert_sorted_by_test.rb +71 -0
- data/test/assert_sorted_desc_test.rb +26 -0
- data/test/assert_sorted_test.rb +26 -0
- data/test/foo.rb +7 -0
- data/test/seahawk.rb +6 -0
- data/test/test_helper.rb +12 -0
- metadata +95 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/History.txt
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
=== 1.4.1 / 2010-01-15
|
2
|
+
A couple minor changes were made.
|
3
|
+
* Changes to gem specification.
|
4
|
+
* Version can be accessed programmatcally from gem.
|
5
|
+
|
6
|
+
=== 1.4.0 / 2008-06-27
|
7
|
+
Add an Test::Unit::Assertions#assert_not method that verifies that a value is
|
8
|
+
false or nil (opposite of the Test::Unit::Assertions#assert method).
|
9
|
+
|
10
|
+
=== 1.3.0 / 2008-06-25
|
11
|
+
Include an example program.
|
12
|
+
|
13
|
+
=== 1.2.0 / 2008-06-12
|
14
|
+
Documentation changes.
|
15
|
+
|
16
|
+
=== 1.1.0 / 2008-06-08
|
17
|
+
Make the failure message when an exception does not have the expected message
|
18
|
+
display the expected message and the actual message on top of each other, for
|
19
|
+
easy comparisons.
|
20
|
+
|
21
|
+
=== 1.0.0 / 2008-06-06
|
22
|
+
First production release of assertions; full documentation is provided.
|
23
|
+
|
24
|
+
=== 0.9.0 / 2008-06-06
|
25
|
+
Initial release of assertions.
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) Designing Patterns, Expected Behavior
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
= assertions
|
2
|
+
* Project Page: http://rubyforge.org/projects/assertions/
|
3
|
+
|
4
|
+
== DESCRIPTION:
|
5
|
+
This package adds some additional assertions to Test::Unit::Assertions,
|
6
|
+
including:
|
7
|
+
* Assertions for all of the comparison operators
|
8
|
+
(Test::Unit::Assertions#assert_greater_than,
|
9
|
+
Test::Unit::Assertions#assert_less_than_or_equal_to,
|
10
|
+
etc.). Shorter aliases also are provided for these
|
11
|
+
(Test::Unit::Assertions#assert_gt, Test::Unit::Assertions#assert_le, etc.).
|
12
|
+
* An assertion that verifies that a given block raises a specified exception
|
13
|
+
with a specified message (Test::Unit::Assertions#assert_raise_message).
|
14
|
+
This allows full testing of error messages.
|
15
|
+
* An assertion that verifies that a given block contains an assertion that
|
16
|
+
fails (Test::Unit::Assertions#assert_fail), which can be used to test new
|
17
|
+
assertions.
|
18
|
+
* An assertion that verifies that a given value is false or nil
|
19
|
+
(Test::Unit::Assertions#assert_not)
|
20
|
+
* Assertions that verify enumerables are sorted
|
21
|
+
(Test::Unit::Assertions#assert_sorted, Test::Unit::Assertions#assert_sorted_desc,
|
22
|
+
Test::Unit::Assertions#assert_sorted_by, Test::Unit::Assertions#assert_sorted_by_desc)
|
23
|
+
* An assertion that verifies x1 < y < x2
|
24
|
+
(Test::Unit::Assertion#assert_between)
|
25
|
+
|
26
|
+
== PROBLEMS:
|
27
|
+
None (known).
|
28
|
+
|
29
|
+
== SYNOPSIS:
|
30
|
+
======<tt>examples/example.rb</tt>:
|
31
|
+
#!/usr/bin/env ruby
|
32
|
+
require 'rubygems'
|
33
|
+
require 'assertions'
|
34
|
+
|
35
|
+
require 'test/unit'
|
36
|
+
|
37
|
+
class Tests < Test::Unit::TestCase
|
38
|
+
def test_assertions
|
39
|
+
#
|
40
|
+
# Verify that 4 > 5 is false.
|
41
|
+
#
|
42
|
+
assert_not(4 > 5)
|
43
|
+
|
44
|
+
#
|
45
|
+
# Verify that 4 < 5
|
46
|
+
#
|
47
|
+
assert_less_than(4, 5)
|
48
|
+
|
49
|
+
#
|
50
|
+
# Verify that 4 < 5 again, but this time with the
|
51
|
+
# shorter alias.
|
52
|
+
#
|
53
|
+
assert_lt(4, 5)
|
54
|
+
|
55
|
+
#
|
56
|
+
# Verify that 5 >= 5
|
57
|
+
#
|
58
|
+
assert_ge(5, 5)
|
59
|
+
|
60
|
+
#
|
61
|
+
# Verify that the specified exception is raised.
|
62
|
+
#
|
63
|
+
assert_raise_message("Hello, exception!", RuntimeError) do
|
64
|
+
raise "Hello, exception!"
|
65
|
+
end
|
66
|
+
|
67
|
+
#
|
68
|
+
# Verify that an assertion failed.
|
69
|
+
#
|
70
|
+
assert_fail do
|
71
|
+
assert_equal(5, 4)
|
72
|
+
end
|
73
|
+
|
74
|
+
#
|
75
|
+
# Verify an enumerable is sorted
|
76
|
+
#
|
77
|
+
assert_sorted([1,2,3])
|
78
|
+
|
79
|
+
#
|
80
|
+
# Verify an enumerable is sorted descending
|
81
|
+
#
|
82
|
+
assert_sorted_desc([3,2,1])
|
83
|
+
|
84
|
+
#
|
85
|
+
# Verify an enumerable is sorted based on a key
|
86
|
+
#
|
87
|
+
assert_sorted_by(:key, [{:key => 1}, {:key => 2}])
|
88
|
+
|
89
|
+
#
|
90
|
+
# Verify an enumerable is sorted descending based on a key
|
91
|
+
#
|
92
|
+
assert_sorted_by(:key, [{:key => 2}, {:key => 1}])
|
93
|
+
|
94
|
+
#
|
95
|
+
# Verify a thing is between two other things
|
96
|
+
#
|
97
|
+
assert_between(1, 3, 2)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
== INSTALL:
|
103
|
+
gem install assertions
|
104
|
+
|
105
|
+
== AUTHORS:
|
106
|
+
=== Designing Patterns
|
107
|
+
* Homepage: http://www.designingpatterns.com
|
108
|
+
* Blogs: http://blogs.designingpatterns.com
|
109
|
+
=== Expected Behavior
|
110
|
+
* http://www.expectedbehavior.com
|
111
|
+
|
112
|
+
== Contributing
|
113
|
+
|
114
|
+
1. Fork it
|
115
|
+
1. Create your feature branch (`git checkout -b my-new-feature`)
|
116
|
+
1. Run the tests until they all pass (`rake test`)
|
117
|
+
1. Commit your changes (`git commit -am 'Added some feature'`)
|
118
|
+
1. Push to the branch (`git push origin my-new-feature`)
|
119
|
+
1. Create new Pull Request
|
120
|
+
|
121
|
+
== Meta
|
122
|
+
|
123
|
+
Originally Created by Designing Patterns
|
124
|
+
|
125
|
+
Maintained by Expected Behavior
|
126
|
+
|
127
|
+
Released under the MIT license. http://github.com/expected-behavior/assertions
|
128
|
+
|
129
|
+
== SHARE AND ENJOY!
|
data/README.txt
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
= assertions
|
2
|
+
* Project Page: http://rubyforge.org/projects/assertions/
|
3
|
+
|
4
|
+
== DESCRIPTION:
|
5
|
+
This package adds some additional assertions to Test::Unit::Assertions,
|
6
|
+
including:
|
7
|
+
* Assertions for all of the comparison operators
|
8
|
+
(Test::Unit::Assertions#assert_greater_than,
|
9
|
+
Test::Unit::Assertions#assert_less_than_or_equal_to,
|
10
|
+
etc.). Shorter aliases also are provided for these
|
11
|
+
(Test::Unit::Assertions#assert_gt, Test::Unit::Assertions#assert_le, etc.).
|
12
|
+
* An assertion that verifies that a given block raises a specified exception
|
13
|
+
with a specified message (Test::Unit::Assertions#assert_raise_message).
|
14
|
+
This allows full testing of error messages.
|
15
|
+
* An assertion that verifies that a given block contains an assertion that
|
16
|
+
fails (Test::Unit::Assertions#assert_fail), which can be used to test new
|
17
|
+
assertions.
|
18
|
+
* An assertion that verifies that a given value is false or nil
|
19
|
+
(Test::Unit::Assertions#assert_not)
|
20
|
+
* Assertions that verify enumerables are sorted
|
21
|
+
(Test::Unit::Assertions#assert_sorted, Test::Unit::Assertions#assert_sorted_desc,
|
22
|
+
Test::Unit::Assertions#assert_sorted_by, Test::Unit::Assertions#assert_sorted_by_desc)
|
23
|
+
* An assertion that verifies x1 < y < x2
|
24
|
+
(Test::Unit::Assertion#assert_between)
|
25
|
+
|
26
|
+
== PROBLEMS:
|
27
|
+
None (known).
|
28
|
+
|
29
|
+
== SYNOPSIS:
|
30
|
+
======<tt>examples/example.rb</tt>:
|
31
|
+
#!/usr/bin/env ruby
|
32
|
+
require 'rubygems'
|
33
|
+
require 'assertions'
|
34
|
+
|
35
|
+
require 'test/unit'
|
36
|
+
|
37
|
+
class Tests < Test::Unit::TestCase
|
38
|
+
def test_assertions
|
39
|
+
#
|
40
|
+
# Verify that 4 > 5 is false.
|
41
|
+
#
|
42
|
+
assert_not(4 > 5)
|
43
|
+
|
44
|
+
#
|
45
|
+
# Verify that 4 < 5
|
46
|
+
#
|
47
|
+
assert_less_than(4, 5)
|
48
|
+
|
49
|
+
#
|
50
|
+
# Verify that 4 < 5 again, but this time with the
|
51
|
+
# shorter alias.
|
52
|
+
#
|
53
|
+
assert_lt(4, 5)
|
54
|
+
|
55
|
+
#
|
56
|
+
# Verify that 5 >= 5
|
57
|
+
#
|
58
|
+
assert_ge(5, 5)
|
59
|
+
|
60
|
+
#
|
61
|
+
# Verify that the specified exception is raised.
|
62
|
+
#
|
63
|
+
assert_raise_message("Hello, exception!", RuntimeError) do
|
64
|
+
raise "Hello, exception!"
|
65
|
+
end
|
66
|
+
|
67
|
+
#
|
68
|
+
# Verify that an assertion failed.
|
69
|
+
#
|
70
|
+
assert_fail do
|
71
|
+
assert_equal(5, 4)
|
72
|
+
end
|
73
|
+
|
74
|
+
#
|
75
|
+
# Verify an enumerable is sorted
|
76
|
+
#
|
77
|
+
assert_sorted([1,2,3])
|
78
|
+
|
79
|
+
#
|
80
|
+
# Verify an enumerable is sorted descending
|
81
|
+
#
|
82
|
+
assert_sorted_desc([3,2,1])
|
83
|
+
|
84
|
+
#
|
85
|
+
# Verify an enumerable is sorted based on a key
|
86
|
+
#
|
87
|
+
assert_sorted_by(:key, [{:key => 1}, {:key => 2}])
|
88
|
+
|
89
|
+
#
|
90
|
+
# Verify an enumerable is sorted descending based on a key
|
91
|
+
#
|
92
|
+
assert_sorted_by(:key, [{:key => 2}, {:key => 1}])
|
93
|
+
|
94
|
+
#
|
95
|
+
# Verify a thing is between two other things
|
96
|
+
#
|
97
|
+
assert_between(1, 3, 2)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
== INSTALL:
|
103
|
+
gem install assertions
|
104
|
+
|
105
|
+
== AUTHORS:
|
106
|
+
=== Designing Patterns
|
107
|
+
* Homepage: http://www.designingpatterns.com
|
108
|
+
* Blogs: http://blogs.designingpatterns.com
|
109
|
+
=== Expected Behavior
|
110
|
+
* http://www.expectedbehavior.com
|
111
|
+
|
112
|
+
== Contributing
|
113
|
+
|
114
|
+
1. Fork it
|
115
|
+
1. Create your feature branch (`git checkout -b my-new-feature`)
|
116
|
+
1. Run the tests until they all pass (`rake test`)
|
117
|
+
1. Commit your changes (`git commit -am 'Added some feature'`)
|
118
|
+
1. Push to the branch (`git push origin my-new-feature`)
|
119
|
+
1. Create new Pull Request
|
120
|
+
|
121
|
+
== Meta
|
122
|
+
|
123
|
+
Originally Created by Designing Patterns
|
124
|
+
|
125
|
+
Maintained by Expected Behavior
|
126
|
+
|
127
|
+
Released under the MIT license. http://github.com/expected-behavior/assertions
|
128
|
+
|
129
|
+
== SHARE AND ENJOY!
|
data/Rakefile
ADDED
data/assertions.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$LOAD_PATH.push(File.expand_path "../lib", __FILE__)
|
3
|
+
require "assertions/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.authors = ["DesigningPatterns", "Expected Behavior"]
|
7
|
+
gem.email = ["technical.inquiries@designingpatterns.com",
|
8
|
+
"joel@expectedbehavior.com",
|
9
|
+
"chris@monoclesoftware.com"]
|
10
|
+
gem.description = %{This project adds some additional assertions to Test::Unit::Assertions, including assert_raise_message (allowing verification of error messages) and assert_greater_than.}
|
11
|
+
gem.summary = "More Assertions for Test::Unit::Assertions"
|
12
|
+
gem.homepage = "http://www.expectedbehavior.com"
|
13
|
+
|
14
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
15
|
+
gem.files = `git ls-files`.split("\n")
|
16
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
gem.name = "assertions-eb"
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
gem.version = Assertions::VERSION
|
20
|
+
end
|
data/examples/example.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'assertions'
|
4
|
+
|
5
|
+
require 'test/unit'
|
6
|
+
|
7
|
+
class Tests < Test::Unit::TestCase
|
8
|
+
def test_assertions
|
9
|
+
#
|
10
|
+
# Verify that 4 > 5 is false.
|
11
|
+
#
|
12
|
+
assert_not(4 > 5)
|
13
|
+
|
14
|
+
#
|
15
|
+
# Verify that 4 < 5
|
16
|
+
#
|
17
|
+
assert_less_than(4, 5)
|
18
|
+
|
19
|
+
#
|
20
|
+
# Verify that 4 < 5 again, but this time with the
|
21
|
+
# shorter alias.
|
22
|
+
#
|
23
|
+
assert_lt(4, 5)
|
24
|
+
|
25
|
+
#
|
26
|
+
# Verify that 5 >= 5
|
27
|
+
#
|
28
|
+
assert_ge(5, 5)
|
29
|
+
|
30
|
+
#
|
31
|
+
# Verify that the specified exception is raised.
|
32
|
+
#
|
33
|
+
assert_raise_message("Hello, exception!", RuntimeError) do
|
34
|
+
raise "Hello, exception!"
|
35
|
+
end
|
36
|
+
|
37
|
+
#
|
38
|
+
# Verify that an assertion failed.
|
39
|
+
#
|
40
|
+
assert_fail do
|
41
|
+
assert_equal(5, 4)
|
42
|
+
end
|
43
|
+
|
44
|
+
#
|
45
|
+
# Verify an enumerable is sorted
|
46
|
+
#
|
47
|
+
assert_sorted([1, 2, 3])
|
48
|
+
|
49
|
+
#
|
50
|
+
# Verify an enumerable is sorted descending
|
51
|
+
#
|
52
|
+
assert_sorted_desc([3, 2, 1])
|
53
|
+
|
54
|
+
#
|
55
|
+
# Verify an enumerable is sorted based on a key
|
56
|
+
#
|
57
|
+
assert_sorted_by(:key, [{:key => 1}, {:key => 2}])
|
58
|
+
|
59
|
+
#
|
60
|
+
# Verify an enumerable is sorted descending based on a key
|
61
|
+
#
|
62
|
+
assert_sorted_by(:key, [{:key => 2}, {:key => 1}])
|
63
|
+
|
64
|
+
#
|
65
|
+
# Verify a thing is between two other things
|
66
|
+
#
|
67
|
+
assert_between(1, 3, 2)
|
68
|
+
end
|
69
|
+
end
|