aquarium 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,62 +2,84 @@ require File.dirname(__FILE__) + '/../spec_helper'
2
2
  require 'aquarium/utils/type_utils'
3
3
  require File.dirname(__FILE__) + '/../utils/type_utils_sample_classes'
4
4
 
5
- describe Aquarium::Utils::TypeUtils, ".is_type?" do
5
+ include Aquarium::Utils
6
+
7
+ describe TypeUtils, ".is_type?" do
6
8
  it "should be true for a class" do
7
- Aquarium::Utils::TypeUtils.is_type?(String).should be_true
9
+ TypeUtils.is_type?(String).should be_true
8
10
  end
9
11
 
10
12
  it "should be true for a Module" do
11
- Aquarium::Utils::TypeUtils.is_type?(Kernel).should be_true
13
+ TypeUtils.is_type?(Kernel).should be_true
12
14
  end
13
15
 
14
16
  it "should be false for an Object" do
15
- Aquarium::Utils::TypeUtils.is_type?("Object").should be_false
17
+ TypeUtils.is_type?("Object").should be_false
16
18
  end
17
19
  end
18
20
 
19
21
  # We don't compare the sizes, because RSpec will add some classes that we don't care about...
20
22
  def check_descendent_array clazz, expected
21
- actual = Aquarium::Utils::TypeUtils.descendents(clazz)
23
+ actual = TypeUtils.descendents(clazz)
22
24
  expected.each {|c| actual.should include(c)}
23
25
  end
24
26
 
25
- describe Aquarium::Utils::TypeUtils, ".descendents called with a class" do
27
+ describe TypeUtils, ".descendents called with a class" do
26
28
  it "should return the class itself in the result" do
27
- Aquarium::Utils::TypeUtils.descendents(BaseForDescendents).should include(BaseForDescendents)
29
+ TypeUtils.descendents(BaseForDescendents).should include(BaseForDescendents)
28
30
  end
29
31
 
30
32
  it "should return just the class if it has no descendents" do
31
- Aquarium::Utils::TypeUtils.descendents(D11ForDescendents).should eql([D11ForDescendents])
32
- Aquarium::Utils::TypeUtils.descendents(D2ForDescendents).should eql([D2ForDescendents])
33
- Aquarium::Utils::TypeUtils.descendents(Aquarium::ForDescendents::NestedD11ForDescendents).should eql([Aquarium::ForDescendents::NestedD11ForDescendents])
34
- Aquarium::Utils::TypeUtils.descendents(Aquarium::ForDescendents::NestedD2ForDescendents).should eql([Aquarium::ForDescendents::NestedD2ForDescendents])
35
- Aquarium::Utils::TypeUtils.descendents(Aquarium::ForDescendents::NestedD3ForDescendents).should eql([Aquarium::ForDescendents::NestedD3ForDescendents])
36
- Aquarium::Utils::TypeUtils.descendents(Aquarium::ForDescendents::NestedD4ForDescendents).should eql([Aquarium::ForDescendents::NestedD4ForDescendents])
37
- Aquarium::Utils::TypeUtils.descendents(Aquarium::ForDescendents::NestedD31ForDescendents).should eql([Aquarium::ForDescendents::NestedD31ForDescendents])
33
+ TypeUtils.descendents(D11ForDescendents).should eql([D11ForDescendents])
34
+ TypeUtils.descendents(D2ForDescendents).should eql([D2ForDescendents])
35
+ TypeUtils.descendents(Aquarium::ForDescendents::NestedD11ForDescendents).should eql([Aquarium::ForDescendents::NestedD11ForDescendents])
36
+ TypeUtils.descendents(Aquarium::ForDescendents::NestedD2ForDescendents).should eql([Aquarium::ForDescendents::NestedD2ForDescendents])
37
+ TypeUtils.descendents(Aquarium::ForDescendents::NestedD3ForDescendents).should eql([Aquarium::ForDescendents::NestedD3ForDescendents])
38
+ TypeUtils.descendents(Aquarium::ForDescendents::NestedD4ForDescendents).should eql([Aquarium::ForDescendents::NestedD4ForDescendents])
39
+ TypeUtils.descendents(Aquarium::ForDescendents::NestedD31ForDescendents).should eql([Aquarium::ForDescendents::NestedD31ForDescendents])
38
40
  end
39
41
 
40
42
  it "should return all classes and their descendents that derive from a class" do
41
- Aquarium::Utils::TypeUtils.sample_classes.each do |t|
42
- check_descendent_array t, Aquarium::Utils::TypeUtils.sample_classes_descendents[t]
43
+ TypeUtils.sample_classes.each do |t|
44
+ check_descendent_array t, TypeUtils.sample_classes_descendents[t]
43
45
  end
44
46
  end
45
47
  end
46
48
 
47
- describe Aquarium::Utils::TypeUtils, ".descendents called with a module" do
49
+ describe TypeUtils, ".descendents called with a module" do
48
50
  it "should return the module itself in the result" do
49
- Aquarium::Utils::TypeUtils.descendents(ModuleForDescendents).should include(ModuleForDescendents)
50
- Aquarium::Utils::TypeUtils.descendents(Aquarium::ForDescendents::NestedModuleForDescendents).should include(Aquarium::ForDescendents::NestedModuleForDescendents)
51
+ TypeUtils.descendents(ModuleForDescendents).should include(ModuleForDescendents)
52
+ TypeUtils.descendents(Aquarium::ForDescendents::NestedModuleForDescendents).should include(Aquarium::ForDescendents::NestedModuleForDescendents)
51
53
  end
52
54
 
53
55
  it "should return all classes and their descendents that include a module" do
54
- Aquarium::Utils::TypeUtils.sample_modules.each do |t|
55
- check_descendent_array t, Aquarium::Utils::TypeUtils.sample_modules_descendents[t]
56
+ TypeUtils.sample_modules.each do |t|
57
+ check_descendent_array t, TypeUtils.sample_modules_descendents[t]
56
58
  end
57
59
  end
58
60
 
59
61
  it "should return all modules that include a module" do
60
- Aquarium::Utils::TypeUtils.descendents(ModuleForDescendents).should include(ModuleForDescendents)
61
- Aquarium::Utils::TypeUtils.descendents(ModuleForDescendents).should include(Aquarium::ForDescendents::Nested2ModuleForDescendents)
62
+ TypeUtils.descendents(ModuleForDescendents).should include(ModuleForDescendents)
63
+ TypeUtils.descendents(ModuleForDescendents).should include(Aquarium::ForDescendents::Nested2ModuleForDescendents)
64
+ end
65
+ end
66
+
67
+ module FakeJRubyWrapperModule
68
+ %w[ancestors constants const_get].each do |method_name|
69
+ module_eval(<<-EOF, __FILE__, __LINE__)
70
+ def self.__#{method_name}__(*args)
71
+ self.#{method_name}(*args)
72
+ end
73
+ EOF
74
+ end
75
+ end
76
+ class FakeJRubyWrapperClass
77
+ include FakeJRubyWrapperModule
78
+ end
79
+
80
+ # See the separate JRuby spec suite for exhaustive tests of JRuby support. This example really exists solely to ensure 100% coverage.
81
+ describe TypeUtils, ".descendents applied to JRuby-wrapped Java classes" do
82
+ it "should properly determine descendents" do
83
+ TypeUtils.descendents(FakeJRubyWrapperModule).should include(FakeJRubyWrapperClass)
62
84
  end
63
85
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aquarium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aquarium Development Team
@@ -9,7 +9,7 @@ autorequire: aquarium
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-01-29 00:00:00 -06:00
12
+ date: 2008-02-25 00:00:00 -06:00
13
13
  default_executable: ""
14
14
  dependencies: []
15
15
 
@@ -153,6 +153,6 @@ rubyforge_project: aquarium
153
153
  rubygems_version: 1.0.1
154
154
  signing_key:
155
155
  specification_version: 2
156
- summary: Aquarium-0.3.1 (r7) - Aspect-Oriented Programming toolkit for Ruby http://aquarium.rubyforge.org
156
+ summary: Aquarium-0.4.0 (r7) - Aspect-Oriented Programming toolkit for Ruby http://aquarium.rubyforge.org
157
157
  test_files: []
158
158