abstract_class 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -2
- data/lib/abstract_class/test_helper.rb +19 -6
- data/lib/abstract_class/version.rb +1 -1
- data/test/abstract_class_test.rb +1 -1
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -50,8 +50,8 @@ Then you can use <tt>assert_abstract_class</tt> or <tt>assert_not_abstract_class
|
|
50
50
|
assert_abstract_class AbstractClass
|
51
51
|
end
|
52
52
|
|
53
|
-
def
|
54
|
-
|
53
|
+
def test_should_not_be_abstract_classes
|
54
|
+
assert_not_abstract_classes NormalClass, Hash
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -1,14 +1,27 @@
|
|
1
1
|
module AbstractClass
|
2
2
|
# Contains abstract class testing assertions to include in your test framework
|
3
3
|
module TestHelper
|
4
|
-
# Asserts that the specified <tt>
|
5
|
-
def
|
6
|
-
|
4
|
+
# Asserts that the specified <tt>classes</tt> have been declared as abstract
|
5
|
+
def assert_abstract_classes(*classes)
|
6
|
+
result, message = abstract_class_test(classes.flatten, true)
|
7
|
+
assert_block(message) { result }
|
7
8
|
end
|
9
|
+
alias_method :assert_abstract_class, :assert_abstract_classes
|
8
10
|
|
9
|
-
# Asserts that the specified <tt>
|
10
|
-
def
|
11
|
-
|
11
|
+
# Asserts that the specified <tt>classes</tt> have not been declared as abstract
|
12
|
+
def assert_not_abstract_classes(*classes)
|
13
|
+
result, message = abstract_class_test(classes.flatten, false)
|
14
|
+
assert_block(message) { result }
|
12
15
|
end
|
16
|
+
alias_method :assert_not_abstract_class, :assert_not_abstract_classes
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def abstract_class_test(classes, abstract) # :nodoc:
|
21
|
+
failed_classes = classes.send(abstract ? :reject : :select) { |klass| klass.abstract? }
|
22
|
+
class_names = failed_classes.join(', ')
|
23
|
+
message = failed_classes.size > 1 ? 'were' : 'was' and (message << ' not' unless abstract)
|
24
|
+
[failed_classes.empty?, "#{class_names} #{message} expected to be abstract"]
|
25
|
+
end
|
13
26
|
end
|
14
27
|
end
|
data/test/abstract_class_test.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abstract_class
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sean Huber
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-11 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|