aquarium 0.4.4 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/CHANGES +31 -6
  2. data/README +4 -1
  3. data/RELEASE-PLAN +2 -0
  4. data/Rakefile +20 -30
  5. data/UPGRADE +14 -4
  6. data/lib/aquarium/aspects/advice.rb +25 -10
  7. data/lib/aquarium/aspects/aspect.rb +8 -7
  8. data/lib/aquarium/aspects/join_point.rb +15 -5
  9. data/lib/aquarium/aspects/pointcut.rb +4 -4
  10. data/lib/aquarium/extensions.rb +0 -1
  11. data/lib/aquarium/finders/method_finder.rb +3 -10
  12. data/lib/aquarium/finders/pointcut_finder.rb +15 -5
  13. data/lib/aquarium/finders/type_finder.rb +0 -1
  14. data/lib/aquarium/utils/array_utils.rb +0 -1
  15. data/lib/aquarium/utils/method_utils.rb +13 -2
  16. data/lib/aquarium/utils/options_utils.rb +1 -0
  17. data/lib/aquarium/utils/type_utils.rb +21 -5
  18. data/lib/aquarium/version.rb +2 -2
  19. data/spec/aquarium/aspects/advice_chain_node_spec.rb +0 -1
  20. data/spec/aquarium/aspects/advice_spec.rb +80 -45
  21. data/spec/aquarium/aspects/aspect_invocation_spec.rb +66 -31
  22. data/spec/aquarium/aspects/aspect_spec.rb +88 -91
  23. data/spec/aquarium/aspects/concurrent_aspects_spec.rb +1 -1
  24. data/spec/aquarium/aspects/concurrent_aspects_with_objects_and_types_spec.rb +3 -1
  25. data/spec/aquarium/aspects/join_point_spec.rb +0 -1
  26. data/spec/aquarium/aspects/pointcut_spec.rb +21 -18
  27. data/spec/aquarium/extensions/hash_spec.rb +211 -219
  28. data/spec/aquarium/extensions/set_spec.rb +1 -1
  29. data/spec/aquarium/extras/design_by_contract_spec.rb +1 -1
  30. data/spec/aquarium/finders/finder_result_spec.rb +4 -4
  31. data/spec/aquarium/finders/method_finder_spec.rb +6 -9
  32. data/spec/aquarium/finders/type_finder_spec.rb +2 -2
  33. data/spec/aquarium/finders/type_finder_with_descendents_and_ancestors_spec.rb +12 -10
  34. data/spec/aquarium/spec_example_types.rb +2 -2
  35. data/spec/aquarium/spec_helper.rb +1 -1
  36. data/spec/aquarium/utils/array_utils_spec.rb +32 -5
  37. data/spec/aquarium/utils/hash_utils_spec.rb +1 -0
  38. data/spec/aquarium/utils/method_utils_spec.rb +18 -0
  39. data/spec/aquarium/utils/options_utils_spec.rb +16 -20
  40. data/spec/aquarium/utils/type_utils_sample_classes.rb +10 -1
  41. data/spec/aquarium/utils/type_utils_spec.rb +9 -7
  42. metadata +29 -35
  43. data/lib/aquarium/extensions/symbol.rb +0 -22
  44. data/spec/aquarium/extensions/symbol_spec.rb +0 -37
@@ -15,7 +15,7 @@ end
15
15
  class Bar
16
16
  end
17
17
 
18
- describe "set comparison", :shared => true do
18
+ shared_examples_for "set comparison" do
19
19
  it "should return true for the same set" do
20
20
  s = Set.new [Foo.new("f1"), Foo.new("f2")]
21
21
  s.should eql(s)
@@ -28,7 +28,7 @@ describe Aquarium::Extras::DesignByContract, "postcondition" do
28
28
  end
29
29
 
30
30
  postcondition :method => :action, :message => "Must pass more than one argument and first argument must be non-empty." do |jp, obj, *args|
31
- args.size > 0 && ! args[0].empty?
31
+ args.size > 0 && ! args[0].to_s.empty?
32
32
  end
33
33
  end
34
34
 
@@ -153,7 +153,7 @@ describe Aquarium::Finders::FinderResult, "#<<" do
153
153
  end
154
154
  end
155
155
 
156
- describe "union of finder results", :shared => true do
156
+ shared_examples_for "union of finder results" do
157
157
  it "should return a FinderResult equal to the second, non-empty FinderResult if the first FinderResult is empty." do
158
158
  result1 = Aquarium::Finders::FinderResult.new
159
159
  result2 = Aquarium::Finders::FinderResult.new :b => [:b1, :b2]
@@ -221,7 +221,7 @@ describe Aquarium::Finders::FinderResult, "#|" do
221
221
  end
222
222
  end
223
223
 
224
- describe "intersection of finder results", :shared => true do
224
+ shared_examples_for "intersection of finder results" do
225
225
  it "should return an empty FinderResult if self is empty." do
226
226
  result1 = Aquarium::Finders::FinderResult.new
227
227
  result2 = Aquarium::Finders::FinderResult.new :b => [:b1, :b2]
@@ -298,7 +298,7 @@ describe Aquarium::Finders::FinderResult, "#&" do
298
298
  end
299
299
 
300
300
 
301
- describe "subtraction of finder results", :shared => true do
301
+ shared_examples_for "subtraction of finder results" do
302
302
  it "should return an empty FinderResult if self is substracted from itself." do
303
303
  result = Aquarium::Finders::FinderResult.new :b => [:b1, :b2]
304
304
  (result - result).should be_empty
@@ -377,7 +377,7 @@ describe Aquarium::Finders::FinderResult, "#.append_not_matched" do
377
377
  end
378
378
  end
379
379
 
380
- describe "equality", :shared => true do
380
+ shared_examples_for "equality" do
381
381
  it "should return true for the same object." do
382
382
  result = Aquarium::Finders::FinderResult.new
383
383
  result.should be_eql(result)
@@ -1,6 +1,7 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
2
  require 'aquarium/spec_example_types'
3
3
  require 'aquarium/finders/method_finder'
4
+ require 'stringio'
4
5
 
5
6
  # :stopdoc:
6
7
  class Base
@@ -115,12 +116,6 @@ describe Aquarium::Finders::MethodFinder, "#find (synonymous input parameters)"
115
116
  actual.should == expected
116
117
  end
117
118
  end
118
-
119
- it "should warn that :options as a synonym for :method_options is deprecated." do
120
- expected = Aquarium::Finders::MethodFinder.new.find :types => Derived, :methods => [/^mder/, /^mmod/], :options => [:exclude_ancestor_methods], :logger_stream => @logger_stream
121
- @logger_stream.to_s.grep(/WARN.*deprecated/).should_not be_nil
122
- end
123
-
124
119
  end
125
120
 
126
121
  describe Aquarium::Finders::MethodFinder, "#find (invalid input parameters)" do
@@ -332,15 +327,17 @@ describe Aquarium::Finders::MethodFinder, "#find (searching for class methods)"
332
327
  end
333
328
 
334
329
  it "should find all class methods specified by regular expression for types when :class is used." do
335
- # NOTE: The list of methods defined by Kernel is different for MRI and JRuby!
330
+ # NOTE: The list of methods defined by Kernel is different for Ruby 1.8 and 1.9.
336
331
  expected = {}
337
332
  expected[Kernel] = [:respond_to?]
338
- expected[Kernel] += [:chomp!, :chop!] unless Object.const_defined?('JRUBY_VERSION')
333
+ if RUBY_VERSION.index("1.8")
334
+ expected[Kernel] += [:chomp!, :chop!]
335
+ end
339
336
  [Object, Module, Class].each do |clazz|
340
337
  expected[clazz] = [:respond_to?]
341
338
  end
342
339
  class_array = [Kernel, Module, Object, Class]
343
- actual = Aquarium::Finders::MethodFinder.new.find :types => class_array, :methods => [/^resp.*\?$/, /^ch.*\!$/], :method_options => :class
340
+ actual = Aquarium::Finders::MethodFinder.new.find :types => class_array, :methods => [/^resp.*to\?$/, /^ch.*\!$/], :method_options => :class
344
341
  class_array.each do |c|
345
342
  actual.matched[c].should == Set.new(expected[c])
346
343
  end
@@ -97,7 +97,7 @@ describe Aquarium::Finders::TypeFinder, "#find with :types used to specify one o
97
97
  expected_unfound_exps = %w[TestCase Unknown1 Unknown2]
98
98
  actual = Aquarium::Finders::TypeFinder.new.find :types=> %w[Kernel Module Object Class TestCase Unknown1 Unknown2]
99
99
  actual.matched_keys.sort.should == expected_found_types.sort
100
- actual.not_matched_keys.should == expected_unfound_exps
100
+ actual.not_matched_keys.sort.should == expected_unfound_exps.sort
101
101
  end
102
102
 
103
103
  it "should find types with :: namespace delimiters using their names." do
@@ -254,4 +254,4 @@ describe Aquarium::Finders::TypeFinder, "#get_type_from_parent should" do
254
254
  end
255
255
  end
256
256
 
257
-
257
+
@@ -3,7 +3,7 @@ require 'aquarium/utils/type_utils_sample_classes'
3
3
  require 'aquarium/finders/type_finder'
4
4
 
5
5
  include Aquarium::Utils
6
-
6
+
7
7
  def purge_actuals actuals
8
8
  # Remove extra stuff inserted by RSpec, Aquarium, and "pretty printer" (rake?), possibly in other specs!
9
9
  actuals.matched_keys.reject do |t2|
@@ -14,7 +14,7 @@ def purge_actuals actuals
14
14
  end
15
15
  end
16
16
 
17
- describe TypeUtils, "#find types and their descendents, using :types_and_descendents" do
17
+ describe Aquarium::Finders::TypeFinder, "#find types and their descendents, using :types_and_descendents" do
18
18
  it "should find the matching types and their descendent subtypes, even in different nested modules." do
19
19
  TypeUtils.sample_types.each do |t|
20
20
  actual = Aquarium::Finders::TypeFinder.new.find :types_and_descendents => (t.name)
@@ -31,7 +31,7 @@ describe TypeUtils, "#find types and their descendents, using :types_and_descend
31
31
  end
32
32
  end
33
33
 
34
- describe TypeUtils, "#find types subtracting out excluded types and descendents, using :exclude_types_and_descendents" do
34
+ describe Aquarium::Finders::TypeFinder, "#find types subtracting out excluded types and descendents, using :exclude_types_and_descendents" do
35
35
  it "should find the matching types and their descendent subtypes, minus the excluded type hierarchies." do
36
36
  actual = Aquarium::Finders::TypeFinder.new.find :types_and_descendents => ModuleForDescendents, :exclude_types_and_descendents => D1ForDescendents
37
37
  actual_keys = purge_actuals actual
@@ -50,7 +50,7 @@ describe TypeUtils, "#find types subtracting out excluded types and descendents,
50
50
  end
51
51
 
52
52
 
53
- describe TypeUtils, "#find types and their ancestors, using :types_and_ancestors" do
53
+ describe Aquarium::Finders::TypeFinder, "#find types and their ancestors, using :types_and_ancestors" do
54
54
  it "should find the matching types and their ancestors, even in different nested modules." do
55
55
  TypeUtils.sample_types.each do |t|
56
56
  actual = Aquarium::Finders::TypeFinder.new.find :types_and_ancestors => (t.name)
@@ -68,7 +68,7 @@ describe TypeUtils, "#find types and their ancestors, using :types_and_ancestors
68
68
  end
69
69
 
70
70
 
71
- describe TypeUtils, "#find types subtracting out excluded types and ancestors, using :exclude_types_and_ancestors" do
71
+ describe Aquarium::Finders::TypeFinder, "#find types subtracting out excluded types and ancestors, using :exclude_types_and_ancestors" do
72
72
  it "should find the matching types and their ancestors, minus the excluded types and ancestors." do
73
73
  actual = Aquarium::Finders::TypeFinder.new.find :types_and_ancestors => D1ForDescendents, :exclude_types_and_ancestors => ModuleForDescendents
74
74
  actual_keys = purge_actuals actual
@@ -87,7 +87,7 @@ describe TypeUtils, "#find types subtracting out excluded types and ancestors, u
87
87
  end
88
88
 
89
89
 
90
- describe TypeUtils, "#find types and their descendents and ancestors" do
90
+ describe Aquarium::Finders::TypeFinder, "#find types and their descendents and ancestors" do
91
91
  it "should find the matching types and their descendents and ancestors, even in different nested modules." do
92
92
  TypeUtils.sample_types.each do |t|
93
93
  actual = Aquarium::Finders::TypeFinder.new.find :types_and_ancestors => (t.name), :types_and_descendents => (t.name)
@@ -99,7 +99,7 @@ describe TypeUtils, "#find types and their descendents and ancestors" do
99
99
  end
100
100
  end
101
101
 
102
- describe TypeUtils, "#find types subtracting out excluded types and their descendents and ancestors" do
102
+ describe Aquarium::Finders::TypeFinder, "#find types subtracting out excluded types and their descendents and ancestors" do
103
103
  it "should find the matching types and their descendents and ancestors, minus the excluded types and their descendents and ancestors." do
104
104
  actual = Aquarium::Finders::TypeFinder.new.find \
105
105
  :types_and_ancestors => Aquarium::ForDescendents::NestedD1ForDescendents,
@@ -113,12 +113,14 @@ describe TypeUtils, "#find types subtracting out excluded types and their descen
113
113
  end
114
114
  end
115
115
 
116
- describe TypeUtils, "#find types and their descendents and ancestors, specified with regular expressions" do
116
+ describe Aquarium::Finders::TypeFinder, "#find types and their descendents and ancestors, specified with regular expressions" do
117
117
  it "should find the matching types and their descendents and ancestors, even in different nested modules." do
118
118
  regexs = [/ForDescendents$/, /Aquarium::ForDescendents::.*ForDescendents/]
119
119
  actual = Aquarium::Finders::TypeFinder.new.find :types_and_ancestors => regexs, :types_and_descendents => regexs
120
120
  actual_keys = purge_actuals actual
121
- expected = TypeUtils.sample_types_descendents_and_ancestors.keys + [Kernel, Object]
121
+ extras = RUBY_VERSION =~ /^1.8/ ? [Kernel, Object] : [Kernel, BasicObject, Object]
122
+
123
+ expected = TypeUtils.sample_types_descendents_and_ancestors.keys + extras
122
124
  actual_keys.size.should == expected.size
123
125
  expected.each do |t|
124
126
  actual_keys.should include(t)
@@ -128,7 +130,7 @@ describe TypeUtils, "#find types and their descendents and ancestors, specified
128
130
  end
129
131
  end
130
132
 
131
- describe TypeUtils, "#find types and their descendents and ancestors, subtracting out excluded types and their descendents and ancestors, specified using regular expressions" do
133
+ describe Aquarium::Finders::TypeFinder, "#find types and their descendents and ancestors, subtracting out excluded types and their descendents and ancestors, specified using regular expressions" do
132
134
  it "should find the matching types and their descendents and ancestors, minus the excluded types and their descendents and ancestors." do
133
135
  actual = Aquarium::Finders::TypeFinder.new.find :types_and_ancestors => /Aquarium::ForDescendents::.*D1ForDescendents/,
134
136
  :types_and_descendents => /Aquarium::ForDescendents::.*D1ForDescendents/,
@@ -118,9 +118,8 @@ class Watchful
118
118
 
119
119
  %w[public protected private].each do |protection|
120
120
  class_eval(<<-EOF, __FILE__, __LINE__)
121
- public
122
121
  attr_accessor :#{protection}_watchful_method_args, :#{protection}_watchful_method_that_raises_args
123
- #{protection}
122
+ public :#{protection}_watchful_method_args, :#{protection}_watchful_method_that_raises_args
124
123
  def #{protection}_watchful_method *args
125
124
  @#{protection}_watchful_method_args = args
126
125
  yield *args if block_given?
@@ -130,6 +129,7 @@ class Watchful
130
129
  yield *args if block_given?
131
130
  raise WatchfulError.new #("#{protection}_watchful_method_that_raises")
132
131
  end
132
+ #{protection} :#{protection}_watchful_method, :#{protection}_watchful_method_that_raises
133
133
  EOF
134
134
  end
135
135
 
@@ -1,4 +1,4 @@
1
1
  $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../../lib')
2
2
  $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..')
3
3
  require 'rubygems'
4
- require 'spec'
4
+ require 'rspec'
@@ -3,6 +3,8 @@ require 'aquarium/utils/array_utils'
3
3
  require 'set'
4
4
 
5
5
  describe Aquarium::Utils::ArrayUtils, "#make_array" do
6
+ include Aquarium::Utils::ArrayUtils
7
+
6
8
  it "should return an empty array if the input is nil." do
7
9
  make_array(nil).should == []
8
10
  end
@@ -25,7 +27,12 @@ describe Aquarium::Utils::ArrayUtils, "#make_array" do
25
27
  end
26
28
 
27
29
  it "should return an array with all nils removed from the input Set." do
28
- make_array(Set.new([nil, 1, 2, nil, 3, 4])).should == [1, 2, 3, 4]
30
+ array = make_array(Set.new([nil, 1, 2, nil, 3, 4]))
31
+ array.should include(1)
32
+ array.should include(2)
33
+ array.should include(3)
34
+ array.should include(4)
35
+ array.should_not include(nil)
29
36
  end
30
37
 
31
38
  it "should return an 1-element array with an empty element if the input is empty." do
@@ -41,15 +48,25 @@ describe Aquarium::Utils::ArrayUtils, "#make_array" do
41
48
  end
42
49
 
43
50
  it "should return an input Set#to_a if it contains no nil elements." do
44
- make_array(Set.new([1,2,"123"])).should == [1,2,"123"]
51
+ array = make_array(Set.new([1,2,"123"]))
52
+ array.should include(1)
53
+ array.should include(2)
54
+ array.should include("123")
55
+ array.should_not include(nil)
45
56
  end
46
57
 
47
58
  it "should be available as a class method." do
48
- Aquarium::Utils::ArrayUtils.make_array(Set.new([1,2,"123"])).should == [1,2,"123"]
59
+ array = Aquarium::Utils::ArrayUtils.make_array(Set.new([1,2,"123"]))
60
+ array.should include(1)
61
+ array.should include(2)
62
+ array.should include("123")
63
+ array.should_not include(nil)
49
64
  end
50
65
  end
51
66
 
52
67
  describe Aquarium::Utils::ArrayUtils, "#strip_array_nils" do
68
+ include Aquarium::Utils::ArrayUtils
69
+
53
70
  it "should return an empty array if an input array contains all nils." do
54
71
  strip_array_nils([nil, nil]).should == []
55
72
  end
@@ -63,12 +80,22 @@ describe Aquarium::Utils::ArrayUtils, "#strip_array_nils" do
63
80
  end
64
81
 
65
82
  it "should return an array with all nils removed from the input Set." do
66
- strip_array_nils(Set.new([nil, 1, 2, nil, 3, 4])).should == [1, 2, 3, 4]
83
+ array = strip_array_nils(Set.new([nil, 1, 2, nil, 3, 4]))
84
+ array.should include(1)
85
+ array.should include(2)
86
+ array.should include(3)
87
+ array.should include(4)
88
+ array.should_not include(nil)
67
89
  end
68
90
  end
69
91
 
70
92
  describe Aquarium::Utils::ArrayUtils, ".strip_array_nils" do
71
93
  it "should work like the instance method." do
72
- Aquarium::Utils::ArrayUtils.strip_array_nils(Set.new([nil, 1, 2, nil, 3, 4])).should == [1, 2, 3, 4]
94
+ array = Aquarium::Utils::ArrayUtils.strip_array_nils(Set.new([nil, 1, 2, nil, 3, 4]))
95
+ array.should include(1)
96
+ array.should include(2)
97
+ array.should include(3)
98
+ array.should include(4)
99
+ array.should_not include(nil)
73
100
  end
74
101
  end
@@ -3,6 +3,7 @@ require 'aquarium/spec_example_types'
3
3
  require 'aquarium/utils/hash_utils'
4
4
 
5
5
  describe Aquarium::Utils::HashUtils, "#make_hash" do
6
+ include Aquarium::Utils::HashUtils
6
7
 
7
8
  it "should return an empty hash if the input is nil." do
8
9
  make_hash(nil).should == {}
@@ -1,6 +1,24 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
2
  require 'aquarium/utils/method_utils'
3
3
 
4
+ describe Aquarium::Utils::MethodUtils, ".to_name" do
5
+ it "should return a String for Ruby 1.8" do
6
+ name = Aquarium::Utils::MethodUtils.to_name "length"
7
+ if RUBY_VERSION =~ /^1.8/
8
+ name.class.should == String
9
+ end
10
+ String.public_instance_methods.include?(name)
11
+ end
12
+
13
+ it "should return a Symbol for Ruby 1.9" do
14
+ name = Aquarium::Utils::MethodUtils.to_name "length"
15
+ if RUBY_VERSION =~ /^1.9/
16
+ name.class.should == Symbol
17
+ end
18
+ String.public_instance_methods.include?(name)
19
+ end
20
+ end
21
+
4
22
  describe Aquarium::Utils::MethodUtils, ".method_args_to_hash" do
5
23
 
6
24
  it "should return an empty hash for no arguments." do
@@ -1,6 +1,7 @@
1
1
 
2
2
  require File.dirname(__FILE__) + '/../spec_helper'
3
3
  require 'aquarium/utils'
4
+ require 'stringio'
4
5
 
5
6
  include Aquarium::Utils
6
7
 
@@ -155,44 +156,39 @@ module Aquarium
155
156
  end
156
157
  end
157
158
 
159
+ def method_checks which_type, has_methods, has_not_methods = []
160
+ # Handle 1.8 vs. 1.9 difference; convert methods names uniformly to symbols
161
+ methods = which_type.instance_methods.map {|m| m.intern}
162
+ has_methods.each {|m| methods.should include(m)}
163
+ has_not_methods.each {|m| methods.should_not include(m)}
164
+ end
165
+
158
166
  describe OptionsUtils, ".canonical_option_accessor" do
167
+
159
168
  it "should create a reader and writer method for each option" do
160
- Aquarium::OptionsUtilsExampleWithAccessors.instance_methods.should include("foos")
161
- Aquarium::OptionsUtilsExampleWithAccessors.instance_methods.should include("bars")
162
- Aquarium::OptionsUtilsExampleWithAccessors.instance_methods.should include("foos=")
163
- Aquarium::OptionsUtilsExampleWithAccessors.instance_methods.should include("bars=")
169
+ method_checks Aquarium::OptionsUtilsExampleWithAccessors, [:foos, :bars, :foos=, :bars=]
164
170
  end
165
171
  it "should accept individual options" do
166
- Aquarium::OptionsUtilsExampleWithAccessors.instance_methods.should include("foos")
167
- Aquarium::OptionsUtilsExampleWithAccessors.instance_methods.should include("bars")
168
- Aquarium::OptionsUtilsExampleWithAccessors.instance_methods.should include("foos=")
169
- Aquarium::OptionsUtilsExampleWithAccessors.instance_methods.should include("bars=")
172
+ method_checks Aquarium::OptionsUtilsExampleWithAccessors, [:foos, :bars, :foos=, :bars=]
170
173
  end
171
174
  it "should accept the CANONICAL_OPTIONS as an argument" do
172
- Aquarium::OptionsUtilsExampleWithCanonicalOptionsAccessors.instance_methods.should include("foos")
173
- Aquarium::OptionsUtilsExampleWithCanonicalOptionsAccessors.instance_methods.should include("bars")
174
- Aquarium::OptionsUtilsExampleWithCanonicalOptionsAccessors.instance_methods.should include("foos=")
175
- Aquarium::OptionsUtilsExampleWithCanonicalOptionsAccessors.instance_methods.should include("bars=")
175
+ method_checks Aquarium::OptionsUtilsExampleWithCanonicalOptionsAccessors, [:foos, :bars, :foos=, :bars=]
176
176
  end
177
177
  end
178
+
178
179
  describe OptionsUtils, ".canonical_option_reader" do
179
180
  it "creates a reader method for each option" do
180
- Aquarium::OptionsUtilsExampleWithReaders.instance_methods.should include("foos")
181
- Aquarium::OptionsUtilsExampleWithReaders.instance_methods.should include("bars")
182
- Aquarium::OptionsUtilsExampleWithReaders.instance_methods.should_not include("foos=")
183
- Aquarium::OptionsUtilsExampleWithReaders.instance_methods.should_not include("bars=")
181
+ method_checks Aquarium::OptionsUtilsExampleWithReaders, [:foos, :bars], [:foos=, :bars=]
184
182
  end
185
183
  it "should create readers that return set values" do
186
184
  object = Aquarium::OptionsUtilsExampleWithReaders.new
187
185
  object.foos.class.should == Set
188
186
  end
189
187
  end
188
+
190
189
  describe OptionsUtils, ".canonical_option_writer" do
191
190
  it "creates a writer method for each option" do
192
- Aquarium::OptionsUtilsExampleWithWriters.instance_methods.should_not include("foos")
193
- Aquarium::OptionsUtilsExampleWithWriters.instance_methods.should_not include("bars")
194
- Aquarium::OptionsUtilsExampleWithWriters.instance_methods.should include("foos=")
195
- Aquarium::OptionsUtilsExampleWithWriters.instance_methods.should include("bars=")
191
+ method_checks Aquarium::OptionsUtilsExampleWithWriters, [:foos=, :bars=], [:foos, :bars]
196
192
  end
197
193
  it "should create writers that convert the input values to sets, if they aren't already sets" do
198
194
  object = Aquarium::OptionsUtilsExampleWithAccessors.new
@@ -115,7 +115,7 @@ module Aquarium
115
115
  Aquarium::ForDescendents::Nested2ModuleForDescendents,
116
116
  ModuleForDescendents]}
117
117
 
118
- @@sample_classes_ancestors = {
118
+ sample_classes_ancestors = {
119
119
  BaseForDescendents => [
120
120
  BaseForDescendents,
121
121
  Object,
@@ -178,6 +178,15 @@ module Aquarium
178
178
  BaseForDescendents,
179
179
  Object,
180
180
  Kernel]}
181
+
182
+ @@sample_classes_ancestors = if RUBY_VERSION =~ /^1.8/
183
+ sample_classes_ancestors
184
+ else
185
+ sample_classes_ancestors.inject({}) do |map, (k,v)|
186
+ map[k] = (v << BasicObject).sort {|a,b| a.name <=> b.name}
187
+ map
188
+ end
189
+ end
181
190
 
182
191
  @@sample_types_ancestors = @@sample_classes_ancestors.merge @@sample_modules_ancestors
183
192
 
@@ -31,13 +31,15 @@ describe TypeUtils, ".descendents called with a class" do
31
31
  end
32
32
 
33
33
  it "should return just the class if it has no descendents" do
34
- TypeUtils.descendents(D11ForDescendents).should eql([D11ForDescendents])
35
- TypeUtils.descendents(D2ForDescendents).should eql([D2ForDescendents])
36
- TypeUtils.descendents(Aquarium::ForDescendents::NestedD11ForDescendents).should eql([Aquarium::ForDescendents::NestedD11ForDescendents])
37
- TypeUtils.descendents(Aquarium::ForDescendents::NestedD2ForDescendents).should eql([Aquarium::ForDescendents::NestedD2ForDescendents])
38
- TypeUtils.descendents(Aquarium::ForDescendents::NestedD3ForDescendents).should eql([Aquarium::ForDescendents::NestedD3ForDescendents])
39
- TypeUtils.descendents(Aquarium::ForDescendents::NestedD4ForDescendents).should eql([Aquarium::ForDescendents::NestedD4ForDescendents])
40
- TypeUtils.descendents(Aquarium::ForDescendents::NestedD31ForDescendents).should eql([Aquarium::ForDescendents::NestedD31ForDescendents])
34
+ [D11ForDescendents,
35
+ D2ForDescendents,
36
+ Aquarium::ForDescendents::NestedD11ForDescendents,
37
+ Aquarium::ForDescendents::NestedD2ForDescendents,
38
+ Aquarium::ForDescendents::NestedD3ForDescendents,
39
+ Aquarium::ForDescendents::NestedD4ForDescendents,
40
+ Aquarium::ForDescendents::NestedD31ForDescendents].each do |t|
41
+ TypeUtils.descendents(t).should eql([t])
42
+ end
41
43
  end
42
44
 
43
45
  TypeUtils.sample_classes.each do |t|