aquarium 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/CHANGES +26 -5
  2. data/README +8 -8
  3. data/RELEASE-PLAN +20 -2
  4. data/TODO.rb +26 -0
  5. data/UPGRADE +5 -5
  6. data/examples/aspect_design_example.rb +1 -1
  7. data/examples/aspect_design_example_spec.rb +1 -1
  8. data/examples/design_by_contract_example.rb +4 -9
  9. data/examples/design_by_contract_example_spec.rb +7 -9
  10. data/examples/exception_wrapping_example.rb +48 -0
  11. data/examples/exception_wrapping_example_spec.rb +49 -0
  12. data/examples/reusable_aspect_hack_example.rb +56 -0
  13. data/examples/reusable_aspect_hack_example_spec.rb +80 -0
  14. data/lib/aquarium.rb +1 -0
  15. data/lib/aquarium/aspects.rb +1 -1
  16. data/lib/aquarium/aspects/advice.rb +16 -13
  17. data/lib/aquarium/aspects/aspect.rb +81 -56
  18. data/lib/aquarium/aspects/join_point.rb +4 -4
  19. data/lib/aquarium/aspects/pointcut.rb +49 -73
  20. data/lib/aquarium/dsl.rb +2 -0
  21. data/lib/aquarium/dsl/aspect_dsl.rb +77 -0
  22. data/lib/aquarium/{aspects/dsl → dsl}/object_dsl.rb +2 -2
  23. data/lib/aquarium/extras/design_by_contract.rb +1 -1
  24. data/lib/aquarium/finders.rb +1 -1
  25. data/lib/aquarium/finders/method_finder.rb +26 -26
  26. data/lib/aquarium/finders/type_finder.rb +45 -39
  27. data/lib/aquarium/utils/array_utils.rb +6 -5
  28. data/lib/aquarium/utils/default_logger.rb +2 -1
  29. data/lib/aquarium/utils/options_utils.rb +178 -67
  30. data/lib/aquarium/utils/set_utils.rb +8 -3
  31. data/lib/aquarium/version.rb +1 -1
  32. data/spec/aquarium/aspects/aspect_invocation_spec.rb +111 -14
  33. data/spec/aquarium/aspects/aspect_spec.rb +91 -7
  34. data/spec/aquarium/aspects/pointcut_spec.rb +61 -0
  35. data/spec/aquarium/{aspects/dsl → dsl}/aspect_dsl_spec.rb +76 -32
  36. data/spec/aquarium/finders/method_finder_spec.rb +80 -80
  37. data/spec/aquarium/finders/type_finder_spec.rb +57 -52
  38. data/spec/aquarium/finders/type_finder_with_descendents_and_ancestors_spec.rb +12 -12
  39. data/spec/aquarium/spec_example_types.rb +4 -3
  40. data/spec/aquarium/utils/array_utils_spec.rb +9 -7
  41. data/spec/aquarium/utils/options_utils_spec.rb +106 -5
  42. data/spec/aquarium/utils/set_utils_spec.rb +14 -0
  43. metadata +12 -7
  44. data/lib/aquarium/aspects/dsl.rb +0 -2
  45. data/lib/aquarium/aspects/dsl/aspect_dsl.rb +0 -64
@@ -7,6 +7,7 @@ class Outside
7
7
  class ReallyInside; end
8
8
  end
9
9
  end
10
+ class SubOutside < Outside; end
10
11
 
11
12
  describe Aquarium::Finders::TypeFinder, "#find invocation parameters" do
12
13
 
@@ -18,16 +19,18 @@ describe Aquarium::Finders::TypeFinder, "#find invocation parameters" do
18
19
  lambda { Aquarium::Finders::TypeFinder.new.find "foo" }.should raise_error(Aquarium::Utils::InvalidOptions)
19
20
  end
20
21
 
21
- it "should raise if the input type value is nil." do
22
- lambda { Aquarium::Finders::TypeFinder.new.find :type => nil }.should raise_error(Aquarium::Utils::InvalidOptions)
23
- end
24
-
25
22
  it "should return no matched types and no unmatched type expressions by default (i.e., the input is empty)." do
26
23
  actual = Aquarium::Finders::TypeFinder.new.find
27
24
  actual.matched.should == {}
28
25
  actual.not_matched.should == {}
29
26
  end
30
27
 
28
+ it "should return no matched types and no unmatched type expressions if nil is specified for the types." do
29
+ actual = Aquarium::Finders::TypeFinder.new.find :type => nil
30
+ actual.matched.should == {}
31
+ actual.not_matched.should == {}
32
+ end
33
+
31
34
  it "should return no matched types and no unmatched type expressions if the input hash is empty." do
32
35
  actual = Aquarium::Finders::TypeFinder.new.find {}
33
36
  actual.matched.should == {}
@@ -62,51 +65,33 @@ describe Aquarium::Finders::TypeFinder, "#find invocation parameters" do
62
65
  end
63
66
  end
64
67
 
65
- describe Aquarium::Finders::TypeFinder, "#is_recognized_option" do
66
-
67
- it "should be true for :names, :types, :name, :type (synonyms), as strings or symbols." do
68
- %w[name type names types].each do |s|
69
- Aquarium::Finders::TypeFinder.is_recognized_option(s).should == true
70
- Aquarium::Finders::TypeFinder.is_recognized_option(s.to_sym).should == true
71
- end
72
- end
73
-
74
- it "should be false for unknown options." do
75
- %w[public2 wierd unknown string method object].each do |s|
76
- Aquarium::Finders::TypeFinder.is_recognized_option(s).should == false
77
- Aquarium::Finders::TypeFinder.is_recognized_option(s.to_sym).should == false
78
- end
79
- end
80
- end
81
-
82
-
83
- describe Aquarium::Finders::TypeFinder, "#find with :type or :name used to specify a single type" do
68
+ describe Aquarium::Finders::TypeFinder, "#find with :types used to specify a single type" do
84
69
  it "should find a type matching a simple name (without :: namespace delimiters) using its name and the :type option." do
85
- actual = Aquarium::Finders::TypeFinder.new.find :type => :Object
70
+ actual = Aquarium::Finders::TypeFinder.new.find :types => :Object
86
71
  actual.matched_keys.should == [Object]
87
72
  actual.not_matched.should == {}
88
73
  end
89
74
 
90
75
  it "should find a type matching a simple name (without :: namespace delimiters) using its name and the :name option." do
91
- actual = Aquarium::Finders::TypeFinder.new.find :name => :Object
76
+ actual = Aquarium::Finders::TypeFinder.new.find :types => :Object
92
77
  actual.matched_keys.should == [Object]
93
78
  actual.not_matched.should == {}
94
79
  end
95
80
 
96
81
  it "should return an empty match for a simple name (without :: namespace delimiters) that doesn't match an existing type." do
97
- actual = Aquarium::Finders::TypeFinder.new.find :name => :Unknown
82
+ actual = Aquarium::Finders::TypeFinder.new.find :types => :Unknown
98
83
  actual.matched.should == {}
99
84
  actual.not_matched_keys.should == [:Unknown]
100
85
  end
101
86
 
102
87
  it "should find a type matching a name with :: namespace delimiters using its name." do
103
- actual = Aquarium::Finders::TypeFinder.new.find :name => "Outside::Inside1"
88
+ actual = Aquarium::Finders::TypeFinder.new.find :types => "Outside::Inside1"
104
89
  actual.matched_keys.should == [Outside::Inside1]
105
90
  actual.not_matched.should == {}
106
91
  end
107
92
  end
108
-
109
- describe Aquarium::Finders::TypeFinder, "#find with :types, :names, :type, and :name used to specify one or more names" do
93
+
94
+ describe Aquarium::Finders::TypeFinder, "#find with :types used to specify one or more names" do
110
95
  it "should find types matching simple names (without :: namespace delimiters) using their names." do
111
96
  expected_found_types = [Class, Kernel, Module, Object]
112
97
  expected_unfound_exps = %w[TestCase Unknown1 Unknown2]
@@ -124,7 +109,7 @@ describe Aquarium::Finders::TypeFinder, "#find with :types, :names, :type, and :
124
109
  end
125
110
  end
126
111
 
127
- describe Aquarium::Finders::TypeFinder, "#find with :types, :names, :type, and :name used to specify one or more regular expressions" do
112
+ describe Aquarium::Finders::TypeFinder, "#find with :types used to specify one or more regular expressions" do
128
113
  it "should find types matching simple names (without :: namespace delimiters) using lists of regular expressions." do
129
114
  expected_found_types = [Class, Kernel, Module, Object]
130
115
  expected_unfound_exps = [/Unknown2/, /^.*TestCase.*$/, /^Unknown1/]
@@ -172,6 +157,16 @@ describe Aquarium::Finders::TypeFinder, "#find with :types, :names, :type, and :
172
157
  end
173
158
  end
174
159
 
160
+ describe Aquarium::Finders::TypeFinder, "#find with :types" do
161
+ Aquarium::Finders::TypeFinder::CANONICAL_OPTIONS["types"].reject{|key| key.eql?("types")}.each do |key|
162
+ it "should accept :#{key} as a synonym for :types." do
163
+ actual = Aquarium::Finders::TypeFinder.new.find key.intern => "Outside::Inside1"
164
+ actual.matched_keys.should == [Outside::Inside1]
165
+ actual.not_matched.should == {}
166
+ end
167
+ end
168
+ end
169
+
175
170
  describe Aquarium::Finders::TypeFinder, "#find with :exclude_types" do
176
171
  it "should exclude types specified with a regular expression." do
177
172
  expected_found_types = [Class, Module, Object]
@@ -193,35 +188,45 @@ describe Aquarium::Finders::TypeFinder, "#find with :exclude_types" do
193
188
  actual.not_matched.size.should == 0
194
189
  end
195
190
 
196
- it "should be a synonym for :exclude_type." do
197
- expected_found_types = [Class, Module]
198
- actual = Aquarium::Finders::TypeFinder.new.find :types => [/K.+l/, /^Mod.+e$/, /^Object$/, /^Clas{2}$/], :exclude_type => [Kernel, Object]
191
+ Aquarium::Finders::TypeFinder::CANONICAL_OPTIONS["exclude_types"].reject{|key| key.eql?("exclude_types")}.each do |key|
192
+ it "should accept :#{key} as a synonym for :exclude_types." do
193
+ expected_found_types = [Class, Module]
194
+ actual = Aquarium::Finders::TypeFinder.new.find :types => [/K.+l/, /^Mod.+e$/, /^Object$/, /^Clas{2}$/], key.intern => [Kernel, Object]
195
+ actual.matched_keys.sort_by {|x| x.to_s}.should == expected_found_types.sort_by {|x| x.to_s}
196
+ actual.not_matched.size.should == 0
197
+ end
198
+ end
199
+ end
200
+
201
+ describe Aquarium::Finders::TypeFinder, "#find with :types_and_descendents" do
202
+ it "should find the types and their descendents." do
203
+ expected_found_types = [Outside, SubOutside]
204
+ actual = Aquarium::Finders::TypeFinder.new.find :types_and_descendents => Outside
199
205
  actual.matched_keys.sort_by {|x| x.to_s}.should == expected_found_types.sort_by {|x| x.to_s}
200
206
  actual.not_matched.size.should == 0
201
207
  end
202
208
 
203
- it "should be a synonym for :exclude_names." do
204
- expected_found_types = [Class, Module]
205
- actual = Aquarium::Finders::TypeFinder.new.find :types => [/K.+l/, /^Mod.+e$/, /^Object$/, /^Clas{2}$/], :exclude_names => [Kernel, Object]
206
- actual.matched_keys.sort_by {|x| x.to_s}.should == expected_found_types.sort_by {|x| x.to_s}
207
- actual.not_matched.size.should == 0
208
- end
209
+ Aquarium::Finders::TypeFinder::CANONICAL_OPTIONS["types_and_descendents"].reject{|key| key.eql?("types_and_descendents")}.each do |key|
210
+ it "should accept :#{key} as a synonym for :types_and_descendents." do
211
+ lambda {actual = Aquarium::Finders::TypeFinder.new.find key.intern => Outside, :noop => true}.should_not raise_error
212
+ end
213
+ end
214
+ end
209
215
 
210
- it "should be a synonym for :exclude_name." do
211
- expected_found_types = [Class, Module]
212
- actual = Aquarium::Finders::TypeFinder.new.find :types => [/K.+l/, /^Mod.+e$/, /^Object$/, /^Clas{2}$/], :exclude_name => [Kernel, Object]
213
- actual.matched_keys.sort_by {|x| x.to_s}.should == expected_found_types.sort_by {|x| x.to_s}
216
+ describe Aquarium::Finders::TypeFinder, "#find with :types_and_ancestors" do
217
+ it "should find the types and their ancestors." do
218
+ actual = Aquarium::Finders::TypeFinder.new.find :types_and_ancestors => SubOutside
219
+ [Outside, SubOutside, Kernel, Object].each do |x|
220
+ actual.matched_keys.should include(x)
221
+ end
214
222
  actual.not_matched.size.should == 0
215
223
  end
216
- end
217
-
218
- describe Aquarium::Finders::TypeFinder, "#find" do
219
- it "should find types when types given." do
220
- expected_found_types = [Outside::Inside1, Outside::Inside2]
221
- actual = Aquarium::Finders::TypeFinder.new.find :names => expected_found_types
222
- actual.matched_keys.sort_by {|x| x.to_s}.should == expected_found_types.sort_by {|x| x.to_s}
223
- actual.not_matched_keys.should == []
224
- end
224
+
225
+ Aquarium::Finders::TypeFinder::CANONICAL_OPTIONS["types_and_ancestors"].reject{|key| key.eql?("types_and_ancestors")}.each do |key|
226
+ it "should accept :#{key} as a synonym for :types_and_ancestors." do
227
+ lambda {actual = Aquarium::Finders::TypeFinder.new.find key.intern => SubOutside, :noop => true}.should_not raise_error
228
+ end
229
+ end
225
230
  end
226
231
 
227
232
 
@@ -21,9 +21,9 @@ describe TypeUtils, "#find types and their descendents, using :types_and_descend
21
21
  end
22
22
  end
23
23
 
24
- Aquarium::Finders::TypeFinder::TYPES_SYNONYMS.reject{|t| t == :types}.each do |n|
25
- it "should accept :#{n}_and_descendents as a synonym for :types_and_descendents" do
26
- lambda {Aquarium::Finders::TypeFinder.new.find "#{n}_and_descendents".intern => TypeUtils.sample_types, :noop => true}.should_not raise_error(InvalidOptions)
24
+ Aquarium::Finders::TypeFinder::CANONICAL_OPTIONS["types_and_descendents"].each do |synonym|
25
+ it "should accept :#{synonym} as a synonym for :types_and_descendents" do
26
+ lambda {Aquarium::Finders::TypeFinder.new.find synonym.intern => TypeUtils.sample_types, :noop => true}.should_not raise_error(InvalidOptions)
27
27
  end
28
28
  end
29
29
  end
@@ -39,9 +39,9 @@ describe TypeUtils, "#find types subtracting out excluded types and descendents,
39
39
  actual.not_matched_keys.should == []
40
40
  end
41
41
 
42
- Aquarium::Finders::TypeFinder::TYPES_SYNONYMS.reject{|t| t == :types}.each do |n|
43
- it "should accept :exclude_#{n}_and_descendents as a synonym for :exclude_types_and_descendents" do
44
- lambda {Aquarium::Finders::TypeFinder.new.find :types_and_descendents => ModuleForDescendents, "exclude_#{n}_and_descendents".intern => D1ForDescendents, :noop => true}.should_not raise_error(InvalidOptions)
42
+ Aquarium::Finders::TypeFinder::CANONICAL_OPTIONS["exclude_types_and_descendents"].each do |synonym|
43
+ it "should accept :#{synonym} as a synonym for :exclude_types_and_descendents" do
44
+ lambda {Aquarium::Finders::TypeFinder.new.find :types_and_descendents => ModuleForDescendents, synonym.intern => D1ForDescendents, :noop => true}.should_not raise_error(InvalidOptions)
45
45
  end
46
46
  end
47
47
  end
@@ -57,9 +57,9 @@ describe TypeUtils, "#find types and their ancestors, using :types_and_ancestors
57
57
  end
58
58
  end
59
59
 
60
- Aquarium::Finders::TypeFinder::TYPES_SYNONYMS.reject{|t| t == :types}.each do |n|
61
- it "should accept :#{n}_and_ancestors as a synonym for :types_and_ancestors" do
62
- lambda {Aquarium::Finders::TypeFinder.new.find "#{n}_and_ancestors".intern => TypeUtils.sample_types, :noop => true}.should_not raise_error(InvalidOptions)
60
+ Aquarium::Finders::TypeFinder::CANONICAL_OPTIONS["types_and_ancestors"].each do |synonym|
61
+ it "should accept :#{synonym} as a synonym for :types_and_ancestors" do
62
+ lambda {Aquarium::Finders::TypeFinder.new.find synonym.intern => TypeUtils.sample_types, :noop => true}.should_not raise_error(InvalidOptions)
63
63
  end
64
64
  end
65
65
  end
@@ -76,9 +76,9 @@ describe TypeUtils, "#find types subtracting out excluded types and ancestors, u
76
76
  actual.not_matched_keys.should == []
77
77
  end
78
78
 
79
- Aquarium::Finders::TypeFinder::TYPES_SYNONYMS.reject{|t| t == :types}.each do |n|
80
- it "should accept :exclude_#{n}_and_ancestors as a synonym for :exclude_types_and_ancestors" do
81
- lambda {Aquarium::Finders::TypeFinder.new.find :types_and_ancestors => D1ForDescendents, "exclude_#{n}_and_ancestors".intern => ModuleForDescendents, :noop => true}.should_not raise_error(InvalidOptions)
79
+ Aquarium::Finders::TypeFinder::CANONICAL_OPTIONS["exclude_types_and_ancestors"].each do |synonym|
80
+ it "should accept :#{synonym} as a synonym for :exclude_types_and_ancestors" do
81
+ lambda {Aquarium::Finders::TypeFinder.new.find :types_and_ancestors => D1ForDescendents, synonym.intern => ModuleForDescendents, :noop => true}.should_not raise_error(InvalidOptions)
82
82
  end
83
83
  end
84
84
  end
@@ -1,6 +1,6 @@
1
1
  # :enddoc:
2
2
 
3
- require 'aquarium/aspects/dsl/aspect_dsl'
3
+ require 'aquarium/dsl/aspect_dsl'
4
4
 
5
5
  # Declares classes, etc. that support several different module specs.
6
6
  class ExampleParentClass
@@ -101,7 +101,7 @@ class ClassWithAttribs < ExampleParentClass
101
101
  end
102
102
 
103
103
  class Watchful
104
- include Aquarium::Aspects::DSL::AspectDSL
104
+ include Aquarium::DSL
105
105
  class WatchfulError < Exception
106
106
  def initialize message = nil
107
107
  super
@@ -225,7 +225,8 @@ module Aquarium
225
225
  include SpecExampleTypes
226
226
 
227
227
  def stub_type_utils_descendents
228
- @stubbed_type_utils_descendents = Aspect.new :around, :calls_to => :descendents, :on_type => Aquarium::Utils::TypeUtils, :restricting_methods_to => :class_methods do |jp, object, *args|
228
+ @stubbed_type_utils_descendents = Aspect.new :around, :calls_to => :descendents, :on_type => Aquarium::Utils::TypeUtils,
229
+ :restricting_methods_to => :class_methods do |jp, object, *args|
229
230
  descendents[args[0]]
230
231
  end
231
232
  end
@@ -49,24 +49,26 @@ describe Aquarium::Utils::ArrayUtils, "#make_array" do
49
49
  end
50
50
  end
51
51
 
52
- describe Aquarium::Utils::ArrayUtils, "#strip_nils" do
52
+ describe Aquarium::Utils::ArrayUtils, "#strip_array_nils" do
53
53
  it "should return an empty array if an input array contains all nils." do
54
- strip_nils([nil, nil]).should == []
54
+ strip_array_nils([nil, nil]).should == []
55
55
  end
56
56
 
57
57
  it "should return an empty array if an input Set contains all nils." do
58
- strip_nils(Set.new([nil, nil])).should == []
58
+ strip_array_nils(Set.new([nil, nil])).should == []
59
59
  end
60
60
 
61
61
  it "should return an array with all nils removed from the input array." do
62
- strip_nils([nil, 1, 2, nil, 3, 4]).should == [1, 2, 3, 4]
62
+ strip_array_nils([nil, 1, 2, nil, 3, 4]).should == [1, 2, 3, 4]
63
63
  end
64
64
 
65
65
  it "should return an array with all nils removed from the input Set." do
66
- strip_nils(Set.new([nil, 1, 2, nil, 3, 4])).should == [1, 2, 3, 4]
66
+ strip_array_nils(Set.new([nil, 1, 2, nil, 3, 4])).should == [1, 2, 3, 4]
67
67
  end
68
+ end
68
69
 
69
- it "should be accessible as a class method." do
70
- Aquarium::Utils::ArrayUtils.strip_nils(Set.new([nil, 1, 2, nil, 3, 4])).should == [1, 2, 3, 4]
70
+ describe Aquarium::Utils::ArrayUtils, ".strip_array_nils" do
71
+ 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]
71
73
  end
72
74
  end
@@ -8,10 +8,7 @@ module Aquarium
8
8
  class OptionsUtilsUser
9
9
  include OptionsUtils
10
10
  def initialize hash = {}
11
- init_specification hash, {}
12
- end
13
- def all_allowed_option_symbols
14
- []
11
+ init_specification hash, {}, []
15
12
  end
16
13
  end
17
14
  end
@@ -119,4 +116,108 @@ describe OptionsUtils, "#noop=" do
119
116
  object.noop = false
120
117
  object.noop.should be_false
121
118
  end
122
- end
119
+ end
120
+
121
+ module Aquarium
122
+ class OptionsUtilsExample
123
+ include OptionsUtils
124
+ CANONICAL_OPTIONS = {
125
+ "foos" => %w[foo foo1 foo2],
126
+ "bars" => %w[bar bar1 bar2]
127
+ }
128
+ def initialize options = {}
129
+ init_specification options, CANONICAL_OPTIONS
130
+ end
131
+ end
132
+
133
+ class OptionsUtilsExampleWithCanonicalOptionsAccessors < OptionsUtilsExample
134
+ canonical_option_accessor CANONICAL_OPTIONS
135
+ end
136
+ class OptionsUtilsExampleWithAccessors < OptionsUtilsExample
137
+ canonical_option_accessor :foos, :bars
138
+ end
139
+ class OptionsUtilsExampleWithReaders < OptionsUtilsExample
140
+ canonical_option_reader :foos, :bars
141
+ end
142
+ class OptionsUtilsExampleWithWriters < OptionsUtilsExample
143
+ canonical_option_writer :foos, :bars
144
+ end
145
+ class OptionsUtilsExampleWithAdditionalAllowedOptions
146
+ include OptionsUtils
147
+ CANONICAL_OPTIONS = {
148
+ "foos" => %w[foo foo1 foo2],
149
+ "bars" => %w[bar bar1 bar2]
150
+ }
151
+ canonical_option_writer :foos, :bars
152
+ def initialize options = {}
153
+ init_specification options, CANONICAL_OPTIONS, [:baz, :bbb]
154
+ end
155
+ end
156
+ end
157
+
158
+ describe OptionsUtils, ".canonical_option_accessor" do
159
+ 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=")
164
+ end
165
+ 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=")
170
+ end
171
+ 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=")
176
+ end
177
+ end
178
+ describe OptionsUtils, ".canonical_option_reader" do
179
+ 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=")
184
+ end
185
+ it "should create readers that return set values" do
186
+ object = Aquarium::OptionsUtilsExampleWithReaders.new
187
+ object.foos.class.should == Set
188
+ end
189
+ end
190
+ describe OptionsUtils, ".canonical_option_writer" do
191
+ 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=")
196
+ end
197
+ it "should create writers that convert the input values to sets, if they aren't already sets" do
198
+ object = Aquarium::OptionsUtilsExampleWithAccessors.new
199
+ object.foos = "bar"
200
+ object.foos.class.should == Set
201
+ end
202
+ it "should create writers that leave the input sets unchanged" do
203
+ expected = Set.new([:b1, :b2])
204
+ object = Aquarium::OptionsUtilsExampleWithAccessors.new
205
+ object.foos = expected
206
+ object.foos.should == expected
207
+ end
208
+ end
209
+
210
+ describe OptionsUtils, "and options handling" do
211
+ it "should raise if an unknown option is specified" do
212
+ lambda {Aquarium::OptionsUtilsExampleWithAdditionalAllowedOptions.new :unknown => true}.should raise_error(Aquarium::Utils::InvalidOptions)
213
+ end
214
+ it "should not raise if a known canonical option is specified" do
215
+ lambda {Aquarium::OptionsUtilsExampleWithAdditionalAllowedOptions.new :foos => true}.should_not raise_error(Aquarium::Utils::InvalidOptions)
216
+ end
217
+ it "should not raise if a known canonical option synonym is specified" do
218
+ lambda {Aquarium::OptionsUtilsExampleWithAdditionalAllowedOptions.new :foo1 => true}.should_not raise_error(Aquarium::Utils::InvalidOptions)
219
+ end
220
+ it "should not raise if an known additional allowed option is specified" do
221
+ lambda {Aquarium::OptionsUtilsExampleWithAdditionalAllowedOptions.new :baz => true}.should_not raise_error(Aquarium::Utils::InvalidOptions)
222
+ end
223
+ end
@@ -58,3 +58,17 @@ describe Aquarium::Utils::SetUtils, "make_set" do
58
58
  make_set(Set.new([nil, 1, 2, nil, 3, 4])).should == Set.new([1, 2, 3, 4])
59
59
  end
60
60
  end
61
+
62
+ describe Aquarium::Utils::SetUtils, "strip_set_nils" do
63
+ it "should return an empty set if an empty set is specified" do
64
+ strip_set_nils(Set.new([])).should == Set.new([])
65
+ end
66
+
67
+ it "should return an empty set if a set of only nil values is specified" do
68
+ strip_set_nils(Set.new([nil, nil])).should == Set.new([])
69
+ end
70
+
71
+ it "should return a set will all nil values removed" do
72
+ strip_set_nils(Set.new([nil, :a, nil, :b])).should == Set.new([:a, :b])
73
+ end
74
+ 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.4.0
4
+ version: 0.4.1
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-02-25 00:00:00 -06:00
12
+ date: 2008-04-15 00:00:00 -05:00
13
13
  default_executable: ""
14
14
  dependencies: []
15
15
 
@@ -33,18 +33,19 @@ files:
33
33
  - Rakefile
34
34
  - README
35
35
  - RELEASE-PLAN
36
+ - TODO.rb
36
37
  - UPGRADE
37
38
  - lib/aquarium/aspects/advice.rb
38
39
  - lib/aquarium/aspects/aspect.rb
39
40
  - lib/aquarium/aspects/default_objects_handler.rb
40
- - lib/aquarium/aspects/dsl/aspect_dsl.rb
41
- - lib/aquarium/aspects/dsl/object_dsl.rb
42
- - lib/aquarium/aspects/dsl.rb
43
41
  - lib/aquarium/aspects/exclusion_handler.rb
44
42
  - lib/aquarium/aspects/join_point.rb
45
43
  - lib/aquarium/aspects/pointcut.rb
46
44
  - lib/aquarium/aspects/pointcut_composition.rb
47
45
  - lib/aquarium/aspects.rb
46
+ - lib/aquarium/dsl/aspect_dsl.rb
47
+ - lib/aquarium/dsl/object_dsl.rb
48
+ - lib/aquarium/dsl.rb
48
49
  - lib/aquarium/extensions/hash.rb
49
50
  - lib/aquarium/extensions/regexp.rb
50
51
  - lib/aquarium/extensions/set.rb
@@ -82,11 +83,11 @@ files:
82
83
  - spec/aquarium/aspects/concurrent_aspects_with_objects_and_types_spec.rb
83
84
  - spec/aquarium/aspects/concurrently_accessed.rb
84
85
  - spec/aquarium/aspects/default_objects_handler_spec.rb
85
- - spec/aquarium/aspects/dsl/aspect_dsl_spec.rb
86
86
  - spec/aquarium/aspects/join_point_spec.rb
87
87
  - spec/aquarium/aspects/pointcut_and_composition_spec.rb
88
88
  - spec/aquarium/aspects/pointcut_or_composition_spec.rb
89
89
  - spec/aquarium/aspects/pointcut_spec.rb
90
+ - spec/aquarium/dsl/aspect_dsl_spec.rb
90
91
  - spec/aquarium/extensions/hash_spec.rb
91
92
  - spec/aquarium/extensions/regex_spec.rb
92
93
  - spec/aquarium/extensions/set_spec.rb
@@ -115,10 +116,14 @@ files:
115
116
  - examples/aspect_design_example_spec.rb
116
117
  - examples/design_by_contract_example.rb
117
118
  - examples/design_by_contract_example_spec.rb
119
+ - examples/exception_wrapping_example.rb
120
+ - examples/exception_wrapping_example_spec.rb
118
121
  - examples/method_missing_example.rb
119
122
  - examples/method_missing_example_spec.rb
120
123
  - examples/method_tracing_example.rb
121
124
  - examples/method_tracing_example_spec.rb
125
+ - examples/reusable_aspect_hack_example.rb
126
+ - examples/reusable_aspect_hack_example_spec.rb
122
127
  - rake_tasks/examples.rake
123
128
  - rake_tasks/examples_specdoc.rake
124
129
  - rake_tasks/examples_with_rcov.rake
@@ -153,6 +158,6 @@ rubyforge_project: aquarium
153
158
  rubygems_version: 1.0.1
154
159
  signing_key:
155
160
  specification_version: 2
156
- summary: Aquarium-0.4.0 (r7) - Aspect-Oriented Programming toolkit for Ruby http://aquarium.rubyforge.org
161
+ summary: Aquarium-0.4.1 (r7) - Aspect-Oriented Programming toolkit for Ruby http://aquarium.rubyforge.org
157
162
  test_files: []
158
163