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 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 test_should_not_be_abstract_class
54
- assert_not_abstract_class NormalClass
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>klass</tt> has been declared as abstract
5
- def assert_abstract_class(klass)
6
- assert klass.abstract?, "#{klass} was expected to be abstract"
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>klass</tt> has not been declared as abstract
10
- def assert_not_abstract_class(klass)
11
- assert !klass.abstract?, "#{klass} was not expected to be abstract"
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
@@ -3,7 +3,7 @@ module AbstractClass
3
3
  module Version
4
4
  MAJOR = 0
5
5
  MINOR = 0
6
- PATCH = 1
6
+ PATCH = 2
7
7
 
8
8
  # Returns a version string by joining <tt>MAJOR</tt>, <tt>MINOR</tt>, and <tt>PATCH</tt> with <tt>'.'</tt>
9
9
  #
@@ -4,7 +4,7 @@ class BaseClass
4
4
  abstract
5
5
  end
6
6
 
7
- class DerivedClass
7
+ class DerivedClass < BaseClass
8
8
  end
9
9
 
10
10
  class AbstractClassTest < Test::Unit::TestCase
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: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
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-10 00:00:00 -08:00
18
+ date: 2011-02-11 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies: []
21
21