aquarium 0.5.1 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES +240 -215
  3. data/README +61 -44
  4. data/RELEASE-PLAN +21 -23
  5. data/Rakefile +64 -94
  6. data/UPGRADE +45 -35
  7. data/aquarium.gemspec +50 -0
  8. data/examples/README.txt +6 -0
  9. data/examples/aspect_design_example_spec.rb +2 -2
  10. data/examples/design_by_contract_example_spec.rb +3 -3
  11. data/examples/exception_wrapping_example_spec.rb +2 -2
  12. data/examples/introductions_example_spec.rb +1 -1
  13. data/examples/method_tracing_example_spec.rb +17 -16
  14. data/examples/reusable_aspect_hack_example_spec.rb +5 -5
  15. data/jruby/Rakefile +61 -0
  16. data/jruby/java/example/Worker.java +9 -0
  17. data/jruby/java/example/sorter/StringListSorter.java +22 -0
  18. data/jruby/java/example/sorter/converter/StringListCaseConverterAndSorter.java +42 -0
  19. data/jruby/java/example/visibility/Visibility.java +13 -0
  20. data/jruby/spec/java_class_aspects_spec.rb +434 -0
  21. data/jruby/spec/java_visibility_spec.rb +122 -0
  22. data/jruby/spec/spec_helper.rb +5 -0
  23. data/lib/aquarium/aspects/aspect.rb +8 -4
  24. data/lib/aquarium/utils/type_utils.rb +4 -1
  25. data/lib/aquarium/version.rb +29 -28
  26. data/previous_failures.txt +0 -0
  27. data/rspec.watchr +60 -0
  28. data/spec/aquarium/aspects/advice_spec.rb +10 -10
  29. data/spec/aquarium/aspects/aspect_invocation_spec.rb +79 -79
  30. data/spec/aquarium/aspects/aspect_spec.rb +73 -73
  31. data/spec/aquarium/aspects/aspect_with_nested_types_spec.rb +5 -5
  32. data/spec/aquarium/aspects/concurrent_aspects_spec.rb +1 -1
  33. data/spec/aquarium/aspects/default_objects_handler_spec.rb +5 -5
  34. data/spec/aquarium/aspects/join_point_spec.rb +40 -40
  35. data/spec/aquarium/aspects/pointcut_and_composition_spec.rb +8 -8
  36. data/spec/aquarium/aspects/pointcut_spec.rb +25 -25
  37. data/spec/aquarium/extensions/regex_spec.rb +6 -6
  38. data/spec/aquarium/extras/design_by_contract_spec.rb +6 -6
  39. data/spec/aquarium/finders/finder_result_spec.rb +2 -2
  40. data/spec/aquarium/finders/method_finder_spec.rb +24 -24
  41. data/spec/aquarium/finders/pointcut_finder_spec.rb +10 -10
  42. data/spec/aquarium/finders/pointcut_finder_spec_test_classes.rb +4 -4
  43. data/spec/aquarium/finders/type_finder_spec.rb +5 -5
  44. data/spec/aquarium/finders/type_finder_with_descendents_and_ancestors_spec.rb +6 -5
  45. data/spec/aquarium/finders/type_finder_with_nested_types_spec.rb +2 -2
  46. data/spec/aquarium/utils/logic_error_spec.rb +1 -1
  47. data/spec/aquarium/utils/method_utils_spec.rb +38 -38
  48. data/spec/aquarium/utils/nil_object_spec.rb +11 -11
  49. data/spec/aquarium/utils/options_utils_spec.rb +8 -8
  50. data/spec/aquarium/utils/type_utils_spec.rb +3 -3
  51. metadata +238 -57
@@ -0,0 +1,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec/aquarium/spec_helper')
2
+
3
+ require 'aquarium'
4
+ require 'jruby/java/example.jar'
5
+ include Java
@@ -432,9 +432,13 @@ module Aquarium
432
432
  end
433
433
 
434
434
  #--
435
- # By NOT dup'ing the join_point, we save about 25% on the overhead! However, we
436
- # compromise thread safety, primarily because the join_point's context object will be changed.
437
- # TODO Refactor context out of static join point part.
435
+ # Previous versions of Aquarium did NOT dup the join_point here, because it saved about 25%
436
+ # on the overhead on circa 2005 machines. However, that seriously compromised thread safety,
437
+ # primarily because the join_point's context object changes during execution.
438
+ # We now dup the joinpoint, because the improved performance of circa 2013 machines seems to
439
+ # have largely made the extra overhead small enough to be inconsequential. There are possible
440
+ # improvements, such as decoupling the mutable and immutable parts and reusing the later.
441
+ # Feedback is welcome.
438
442
  # Note that we have to assign the parameters and block to the context object in case
439
443
  # the advice calls "proceed" or "invoke_original_join_point" without arguments.
440
444
  #++
@@ -445,7 +449,7 @@ module Aquarium
445
449
  alias_method :#{alias_method_name}, :#{join_point.method_name}
446
450
  def #{join_point.method_name} *args, &block_for_method
447
451
  advice_chain = #{type_being_advised_text}.send :class_variable_get, "#{advice_chain_attr_sym}"
448
- join_point = advice_chain.static_join_point
452
+ join_point = advice_chain.static_join_point.dup
449
453
  join_point.context.parameters = args
450
454
  join_point.context.block_for_method = block_for_method
451
455
  join_point.context.advised_object = #{target_self}
@@ -1,4 +1,5 @@
1
1
  require 'set'
2
+ require 'rbconfig'
2
3
 
3
4
  module Aquarium
4
5
  module Utils
@@ -59,7 +60,9 @@ module Aquarium
59
60
  end
60
61
 
61
62
  def self.use_underscore_methods? mod
62
- mod.respond_to?(:__constants__)
63
+ #TODO
64
+ false
65
+ # mod.respond_to?(:__constants__)
63
66
  end
64
67
 
65
68
  def self.responds_to_ancestors? mod
@@ -1,28 +1,29 @@
1
- module Aquarium
2
- module VERSION
3
- def self.build_tag
4
- tag = "REL_" + [MAJOR, MINOR, TINY].join('_')
5
- tag << "_" << RELEASE_CANDIDATE unless RELEASE_CANDIDATE.nil? or RELEASE_CANDIDATE.empty?
6
- tag
7
- end
8
-
9
- unless defined? MAJOR
10
- MAJOR = 0
11
- MINOR = 5
12
- TINY = 1
13
- RELEASE_CANDIDATE = nil
14
-
15
- # RANDOM_TOKEN: 0.598704893979657
16
- REV = "$LastChangedRevision: 7 $".match(/LastChangedRevision: (\d+)/)[1]
17
-
18
- STRING = [MAJOR, MINOR, TINY].join('.')
19
- FULL_VERSION = "#{STRING} (r#{REV})"
20
- TAG = build_tag
21
-
22
- NAME = "Aquarium"
23
- URL = "http://aquarium.rubyforge.org"
24
-
25
- DESCRIPTION = "#{NAME}-#{FULL_VERSION} - Aspect-Oriented Programming toolkit for Ruby\n#{URL}"
26
- end
27
- end
28
- end
1
+ module Aquarium
2
+ module VERSION
3
+ def self.build_tag
4
+ tag = "REL_" + [MAJOR, MINOR, TINY].join('_')
5
+ tag << "_" << RELEASE_CANDIDATE unless RELEASE_CANDIDATE.nil? or RELEASE_CANDIDATE.empty?
6
+ tag
7
+ end
8
+
9
+ unless defined? MAJOR
10
+ MAJOR = 0
11
+ MINOR = 7
12
+ TINY = 1
13
+ RELEASE_CANDIDATE = nil
14
+
15
+ # RANDOM_TOKEN: 0.598704893979657
16
+ REV = "$LastChangedRevision: 7 $".match(/LastChangedRevision: (\d+)/)[1]
17
+
18
+ STRING = [MAJOR, MINOR, TINY].join('.')
19
+ FULL_VERSION = "#{STRING} (r#{REV})"
20
+ TAG = build_tag
21
+
22
+ NAME = "Aquarium"
23
+ URL = "http://aquarium.rubyforge.org"
24
+
25
+ DESCRIPTION = "#{NAME}-#{FULL_VERSION} - Aspect-Oriented Programming toolkit for Ruby\n#{URL}"
26
+ end
27
+ end
28
+ end
29
+
File without changes
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env watchr
2
+ # Run me with:
3
+ #
4
+ # $ watchr rspec.watchr
5
+
6
+ # --------------------------------------------------
7
+ # Convenience Methods
8
+ # --------------------------------------------------
9
+ def all_test_files
10
+ Dir['spec/**/*_spec.rb']
11
+ end
12
+
13
+ def run_test_matching(thing_to_match)
14
+ matches = all_test_files.grep(/#{thing_to_match}/i)
15
+ if matches.empty?
16
+ run_all_tests
17
+ else
18
+ run matches.join(' ')
19
+ end
20
+ end
21
+
22
+ def run(files_to_run)
23
+ puts("Running: #{files_to_run}")
24
+ system("clear;rspec -cfs #{files_to_run}")
25
+ no_int_for_you
26
+ end
27
+
28
+ def run_all_tests
29
+ run(all_test_files.join(' '))
30
+ end
31
+ #
32
+ # --------------------------------------------------
33
+ # Watchr Rules
34
+ # --------------------------------------------------
35
+ watch('^spec/(.*)_spec\.rb' ) { |m| run_test_matching(m[1]) }
36
+ watch('^lib/(.*)\.rb' ) { |m| run_test_matching(m[1]) }
37
+ watch('^spec/spec_helper\.rb') { run_all_tests }
38
+ # --------------------------------------------------
39
+ # Signal Handling
40
+ # --------------------------------------------------
41
+
42
+ def no_int_for_you
43
+ @sent_an_int = nil
44
+ end
45
+
46
+ Signal.trap 'INT' do
47
+ if @sent_an_int then
48
+ puts " Shutting down now."
49
+ exit
50
+ else
51
+ puts " Hit ^C again to exit."
52
+ @sent_an_int = true
53
+ Kernel.sleep 1.5
54
+ run_all_tests
55
+ end
56
+ end
57
+
58
+ run_all_tests
59
+
60
+ # vim:ft=ruby
@@ -115,7 +115,7 @@ describe Advice, "that raises an exception" do
115
115
  aspect = Aspect.new :before, :pointcut => {:type => Watchful, :methods => :public_class_watchful_method, :method_options => [:class]} do |jp, obj, *args|
116
116
  raise MyException1.new("advice called with args: #{args.inspect}")
117
117
  end
118
- lambda { Watchful.public_class_watchful_method :a1, :a2 }.should raise_error(MyException1)
118
+ expect { Watchful.public_class_watchful_method :a1, :a2 }.to raise_error(MyException1)
119
119
  aspect.unadvise
120
120
  end
121
121
 
@@ -208,7 +208,7 @@ describe Advice, "#invoke_original_join_point that raises an exception" do
208
208
  :method_options => [:class]} do |jp, obj, *args|
209
209
  jp.invoke_original_join_point
210
210
  end
211
- lambda { InvokeOriginalJoinPointRaisingException.class_raise_exception :a1, :a2 }.should raise_error(InvokeOriginalJoinPointRaisingException::IOJPRException)
211
+ expect { InvokeOriginalJoinPointRaisingException.class_raise_exception :a1, :a2 }.to raise_error(InvokeOriginalJoinPointRaisingException::IOJPRException)
212
212
  aspect.unadvise
213
213
  end
214
214
 
@@ -272,17 +272,17 @@ end
272
272
 
273
273
  describe AdviceChainNodeFactory, "#make_node" do
274
274
  it "should raise if an unknown advice kind is specified" do
275
- lambda {AdviceChainNodeFactory.make_node :advice_kind => :foo}.should raise_error(Aquarium::Utils::InvalidOptions)
275
+ expect {AdviceChainNodeFactory.make_node :advice_kind => :foo}.to raise_error(Aquarium::Utils::InvalidOptions)
276
276
  end
277
277
 
278
278
  it "should return a node of the type corresponding to the input advice kind" do
279
- AdviceChainNodeFactory.make_node(:advice_kind => :no).kind_of?(NoAdviceChainNode).should be_true
280
- AdviceChainNodeFactory.make_node(:advice_kind => :none).kind_of?(NoAdviceChainNode).should be_true
281
- AdviceChainNodeFactory.make_node(:advice_kind => :before).kind_of?(BeforeAdviceChainNode).should be_true
282
- AdviceChainNodeFactory.make_node(:advice_kind => :after).kind_of?(AfterAdviceChainNode).should be_true
283
- AdviceChainNodeFactory.make_node(:advice_kind => :after_raising).kind_of?(AfterRaisingAdviceChainNode).should be_true
284
- AdviceChainNodeFactory.make_node(:advice_kind => :after_returning).kind_of?(AfterReturningAdviceChainNode).should be_true
285
- AdviceChainNodeFactory.make_node(:advice_kind => :around).kind_of?(AroundAdviceChainNode).should be_true
279
+ AdviceChainNodeFactory.make_node(:advice_kind => :no).kind_of?(NoAdviceChainNode).should be_truthy
280
+ AdviceChainNodeFactory.make_node(:advice_kind => :none).kind_of?(NoAdviceChainNode).should be_truthy
281
+ AdviceChainNodeFactory.make_node(:advice_kind => :before).kind_of?(BeforeAdviceChainNode).should be_truthy
282
+ AdviceChainNodeFactory.make_node(:advice_kind => :after).kind_of?(AfterAdviceChainNode).should be_truthy
283
+ AdviceChainNodeFactory.make_node(:advice_kind => :after_raising).kind_of?(AfterRaisingAdviceChainNode).should be_truthy
284
+ AdviceChainNodeFactory.make_node(:advice_kind => :after_returning).kind_of?(AfterReturningAdviceChainNode).should be_truthy
285
+ AdviceChainNodeFactory.make_node(:advice_kind => :around).kind_of?(AroundAdviceChainNode).should be_truthy
286
286
  end
287
287
  end
288
288
 
@@ -73,15 +73,15 @@ describe Aspect, "methods" do
73
73
  end
74
74
 
75
75
  it "should warn about no join point matches if the :ignore_no_matching_join_points is not specified." do
76
- lambda {Aspect.new(:after, :logger_stream => @log_stream) {true}}.should raise_error(Aquarium::Utils::InvalidOptions)
76
+ expect {Aspect.new(:after, :logger_stream => @log_stream) {true}}.to raise_error(Aquarium::Utils::InvalidOptions)
77
77
  @log_stream.string.should_not be_empty
78
78
  end
79
79
  it "should warn about no join point matches if :ignore_no_matching_join_points => false is specified." do
80
- lambda {Aspect.new(:after, :logger_stream => @log_stream, :ignore_no_matching_join_points => false) {true}}.should raise_error(Aquarium::Utils::InvalidOptions)
80
+ expect {Aspect.new(:after, :logger_stream => @log_stream, :ignore_no_matching_join_points => false) {true}}.to raise_error(Aquarium::Utils::InvalidOptions)
81
81
  @log_stream.string.should_not be_empty
82
82
  end
83
83
  it "should not warn about no join point matches if :ignore_no_matching_join_points => true is specified." do
84
- lambda {Aspect.new(:after, :logger_stream => @log_stream, :ignore_no_matching_join_points => true) {true}}.should raise_error(Aquarium::Utils::InvalidOptions)
84
+ expect {Aspect.new(:after, :logger_stream => @log_stream, :ignore_no_matching_join_points => true) {true}}.to raise_error(Aquarium::Utils::InvalidOptions)
85
85
  @log_stream.string.should be_empty
86
86
  end
87
87
  end
@@ -92,48 +92,48 @@ describe Aspect, "methods" do
92
92
  end
93
93
 
94
94
  it "should require the kind of advice as the first parameter." do
95
- lambda { Aspect.new :pointcut => @pointcut_opts }.should raise_error(Aquarium::Utils::InvalidOptions)
95
+ expect { Aspect.new :pointcut => @pointcut_opts }.to raise_error(Aquarium::Utils::InvalidOptions)
96
96
  end
97
97
 
98
98
  it "should contain no other advice types if :around advice specified." do
99
- lambda { Aspect.new :around, :before, :pointcut => @pointcut_opts }.should raise_error(Aquarium::Utils::InvalidOptions)
100
- lambda { Aspect.new :around, :after, :pointcut => @pointcut_opts }.should raise_error(Aquarium::Utils::InvalidOptions)
101
- lambda { Aspect.new :around, :after_returning, :pointcut => @pointcut_opts }.should raise_error(Aquarium::Utils::InvalidOptions)
102
- lambda { Aspect.new :around, :after_raising, :pointcut => @pointcut_opts }.should raise_error(Aquarium::Utils::InvalidOptions)
99
+ expect { Aspect.new :around, :before, :pointcut => @pointcut_opts }.to raise_error(Aquarium::Utils::InvalidOptions)
100
+ expect { Aspect.new :around, :after, :pointcut => @pointcut_opts }.to raise_error(Aquarium::Utils::InvalidOptions)
101
+ expect { Aspect.new :around, :after_returning, :pointcut => @pointcut_opts }.to raise_error(Aquarium::Utils::InvalidOptions)
102
+ expect { Aspect.new :around, :after_raising, :pointcut => @pointcut_opts }.to raise_error(Aquarium::Utils::InvalidOptions)
103
103
  end
104
104
 
105
105
  it "should allow only one of :after, :after_returning, or :after_raising advice to be specified." do
106
- lambda { Aspect.new :after, :after_returning, :pointcut => @pointcut_opts }.should raise_error(Aquarium::Utils::InvalidOptions)
107
- lambda { Aspect.new :after, :after_raising, :pointcut => @pointcut_opts }.should raise_error(Aquarium::Utils::InvalidOptions)
108
- lambda { Aspect.new :after_returning, :after_raising, :pointcut => @pointcut_opts }.should raise_error(Aquarium::Utils::InvalidOptions)
106
+ expect { Aspect.new :after, :after_returning, :pointcut => @pointcut_opts }.to raise_error(Aquarium::Utils::InvalidOptions)
107
+ expect { Aspect.new :after, :after_raising, :pointcut => @pointcut_opts }.to raise_error(Aquarium::Utils::InvalidOptions)
108
+ expect { Aspect.new :after_returning, :after_raising, :pointcut => @pointcut_opts }.to raise_error(Aquarium::Utils::InvalidOptions)
109
109
  end
110
110
 
111
111
  it "should allow :before to be specified with :after." do
112
- lambda { Aspect.new :before, :after, :pointcut => @pointcut_opts, :noop => true }.should_not raise_error(Aquarium::Utils::InvalidOptions)
112
+ expect { Aspect.new :before, :after, :pointcut => @pointcut_opts, :noop => true }.not_to raise_error
113
113
  end
114
114
 
115
115
  it "should allow :before to be specified with :after_returning." do
116
- lambda { Aspect.new :before, :after_returning, :pointcut => @pointcut_opts, :noop => true }.should_not raise_error(Aquarium::Utils::InvalidOptions)
116
+ expect { Aspect.new :before, :after_returning, :pointcut => @pointcut_opts, :noop => true }.not_to raise_error
117
117
  end
118
118
 
119
119
  it "should allow :before to be specified with :after_raising." do
120
- lambda { Aspect.new :before, :after_raising, :pointcut => @pointcut_opts, :noop => true }.should_not raise_error(Aquarium::Utils::InvalidOptions)
120
+ expect { Aspect.new :before, :after_raising, :pointcut => @pointcut_opts, :noop => true }.not_to raise_error
121
121
  end
122
122
 
123
123
  it "should accept a single exception specified with :after_raising." do
124
- lambda { Aspect.new :before, :after_raising => Exception, :pointcut => @pointcut_opts, :noop => true }.should_not raise_error(Aquarium::Utils::InvalidOptions)
124
+ expect { Aspect.new :before, :after_raising => Exception, :pointcut => @pointcut_opts, :noop => true }.not_to raise_error
125
125
  end
126
126
 
127
127
  it "should accept a list of exceptions specified with :after_raising." do
128
- lambda { Aspect.new :before, :after_raising => [Exception, String], :pointcut => @pointcut_opts, :noop => true }.should_not raise_error(Aquarium::Utils::InvalidOptions)
128
+ expect { Aspect.new :before, :after_raising => [Exception, String], :pointcut => @pointcut_opts, :noop => true }.not_to raise_error
129
129
  end
130
130
 
131
131
  it "should accept a separate :exceptions => list of exceptions specified with :after_raising." do
132
- lambda { Aspect.new :before, :after_raising, :exceptions => [Exception, String], :pointcut => @pointcut_opts, :noop => true }.should_not raise_error(Aquarium::Utils::InvalidOptions)
132
+ expect { Aspect.new :before, :after_raising, :exceptions => [Exception, String], :pointcut => @pointcut_opts, :noop => true }.not_to raise_error
133
133
  end
134
134
 
135
135
  it "should reject the :exceptions argument unless specified with :after_raising." do
136
- lambda { Aspect.new :before, :after, :exceptions => [Exception, String], :pointcut => @pointcut_opts, :noop => true }.should raise_error(Aquarium::Utils::InvalidOptions)
136
+ expect { Aspect.new :before, :after, :exceptions => [Exception, String], :pointcut => @pointcut_opts, :noop => true }.to raise_error(Aquarium::Utils::InvalidOptions)
137
137
  end
138
138
  end
139
139
 
@@ -143,7 +143,7 @@ describe Aspect, "methods" do
143
143
  end
144
144
 
145
145
  it "should contain at least one of :method(s), :pointcut(s), :named_pointcut(s), :type(s), or :object(s)." do
146
- lambda {Aspect.new(:after, :ignore_no_matching_join_points => true) {true}}.should raise_error(Aquarium::Utils::InvalidOptions)
146
+ expect {Aspect.new(:after, :ignore_no_matching_join_points => true) {true}}.to raise_error(Aquarium::Utils::InvalidOptions)
147
147
  end
148
148
 
149
149
  it "should contain at least one of :pointcut(s), :named_pointcut(s), :type(s), or :object(s) unless :default_objects => object is given." do
@@ -227,15 +227,15 @@ describe Aspect, "methods" do
227
227
  end
228
228
 
229
229
  it "should not contain :pointcut(s) and either :type(s) or :object(s)." do
230
- lambda {Aspect.new(:after, :pointcuts => @pointcut_opts, :type => Aquarium::AspectInvocationTestClass, :method => :public_test_method) {true}}.should raise_error(Aquarium::Utils::InvalidOptions)
231
- lambda {Aspect.new(:after, :pointcuts => @pointcut_opts, :object => Aquarium::AspectInvocationTestClass.new, :method => :public_test_method) {true}}.should raise_error(Aquarium::Utils::InvalidOptions)
230
+ expect {Aspect.new(:after, :pointcuts => @pointcut_opts, :type => Aquarium::AspectInvocationTestClass, :method => :public_test_method) {true}}.to raise_error(Aquarium::Utils::InvalidOptions)
231
+ expect {Aspect.new(:after, :pointcuts => @pointcut_opts, :object => Aquarium::AspectInvocationTestClass.new, :method => :public_test_method) {true}}.to raise_error(Aquarium::Utils::InvalidOptions)
232
232
  end
233
233
  end
234
234
 
235
235
  describe Aspect, ".new (parameters that specify named constant and/or class variable pointcuts)" do
236
236
  it "should contain at least one :types or TypeFinder synonym for :types." do
237
- lambda {Aspect.new(:after, :named_pointcuts => {}, :noop => true) {true}}.should raise_error(Aquarium::Utils::InvalidOptions)
238
- lambda {Aspect.new(:after, :named_pointcuts => {:types => all_pointcut_classes}, :noop => true) {true}}.should_not raise_error(Aquarium::Utils::InvalidOptions)
237
+ expect {Aspect.new(:after, :named_pointcuts => {}, :noop => true) {true}}.to raise_error(Aquarium::Utils::InvalidOptions)
238
+ expect {Aspect.new(:after, :named_pointcuts => {:types => Aquarium::PointcutFinderTestClasses.all_pointcut_classes}, :noop => true) {true}}.not_to raise_error
239
239
  end
240
240
 
241
241
  it "should ignore the :default_objects if at least one :named_pointcut is given even if the :default_objects => object are given." do
@@ -261,8 +261,8 @@ describe Aspect, "methods" do
261
261
  end
262
262
 
263
263
  it "should not contain :named_pointcut(s) and either :type(s) or :object(s)." do
264
- lambda {Aspect.new(:after, :named_pointcuts => {:types => Aquarium::PointcutFinderTestClasses::PointcutClassVariableHolder1}, :type => Aquarium::AspectInvocationTestClass, :method => :public_test_method) {true}}.should raise_error(Aquarium::Utils::InvalidOptions)
265
- lambda {Aspect.new(:after, :named_pointcuts => {:types => Aquarium::PointcutFinderTestClasses::PointcutClassVariableHolder1}, :object => Aquarium::AspectInvocationTestClass.new, :method => :public_test_method) {true}}.should raise_error(Aquarium::Utils::InvalidOptions)
264
+ expect {Aspect.new(:after, :named_pointcuts => {:types => Aquarium::PointcutFinderTestClasses::PointcutClassVariableHolder1}, :type => Aquarium::AspectInvocationTestClass, :method => :public_test_method) {true}}.to raise_error(Aquarium::Utils::InvalidOptions)
265
+ expect {Aspect.new(:after, :named_pointcuts => {:types => Aquarium::PointcutFinderTestClasses::PointcutClassVariableHolder1}, :object => Aquarium::AspectInvocationTestClass.new, :method => :public_test_method) {true}}.to raise_error(Aquarium::Utils::InvalidOptions)
266
266
  end
267
267
  end
268
268
 
@@ -272,7 +272,7 @@ describe Aspect, "methods" do
272
272
  aspect = Aspect.new :before, :types => Aquarium::AspectInvocationTestClass, :method => :public_test_method do; @advice_called = true; end
273
273
  Aquarium::AspectInvocationTestClass.new.public_test_method
274
274
  aspect.unadvise
275
- @advice_called.should be_true
275
+ @advice_called.should be_truthy
276
276
  end
277
277
 
278
278
  Aspect::CANONICAL_OPTIONS["types"].each do |key|
@@ -289,7 +289,7 @@ describe Aspect, "methods" do
289
289
  aspect = Aspect.new :before, :pointcuts => {:types => Aquarium::AspectInvocationTestClass, :method => :public_test_method} do; @advice_called = true; end
290
290
  Aquarium::AspectInvocationTestClass.new.public_test_method
291
291
  aspect.unadvise
292
- @advice_called.should be_true
292
+ @advice_called.should be_truthy
293
293
  end
294
294
 
295
295
  Aspect::CANONICAL_OPTIONS["pointcuts"].each do |key|
@@ -307,7 +307,7 @@ describe Aspect, "methods" do
307
307
  aspect = Aspect.new :before, :objects => object, :method => :public_test_method do; @advice_called = true; end
308
308
  object.public_test_method
309
309
  aspect.unadvise
310
- @advice_called.should be_true
310
+ @advice_called.should be_truthy
311
311
  end
312
312
 
313
313
  Aspect::CANONICAL_OPTIONS["objects"].each do |key|
@@ -325,7 +325,7 @@ describe Aspect, "methods" do
325
325
  aspect = Aspect.new :before, :types => Aquarium::AspectInvocationTestClass, :methods => :public_test_method do; @advice_called = true; end
326
326
  Aquarium::AspectInvocationTestClass.new.public_test_method
327
327
  aspect.unadvise
328
- @advice_called.should be_true
328
+ @advice_called.should be_truthy
329
329
  end
330
330
 
331
331
  Aspect::CANONICAL_OPTIONS["methods"].each do |key|
@@ -348,14 +348,14 @@ describe Aspect, "methods" do
348
348
 
349
349
  it "should require the values for :reading => ... and :writing => ... to be equal if both are specified." do
350
350
  @advice = Proc.new {}
351
- lambda {Aspect.new :before, :type => Aquarium::AspectInvocationTestClass3,
352
- :reading => :public_test_method_args, :writing => :public_test_method_args2, :advice => @advice}.should raise_error(Aquarium::Utils::InvalidOptions)
351
+ expect {Aspect.new :before, :type => Aquarium::AspectInvocationTestClass3,
352
+ :reading => :public_test_method_args, :writing => :public_test_method_args2, :advice => @advice}.to raise_error(Aquarium::Utils::InvalidOptions)
353
353
  end
354
354
 
355
355
  it "should require the values for :reading => ... and :changing => ... to be equal if both are specified." do
356
356
  @advice = Proc.new {}
357
- lambda {Aspect.new :before, :type => Aquarium::AspectInvocationTestClass3,
358
- :reading => :public_test_method_args, :changing => :public_test_method_args2, :advice => @advice}.should raise_error(Aquarium::Utils::InvalidOptions)
357
+ expect {Aspect.new :before, :type => Aquarium::AspectInvocationTestClass3,
358
+ :reading => :public_test_method_args, :changing => :public_test_method_args2, :advice => @advice}.to raise_error(Aquarium::Utils::InvalidOptions)
359
359
  end
360
360
 
361
361
  it "should accept :reading => ... as a synonym for :attributes => ..., :attribute_options => [:readers]." do
@@ -411,7 +411,7 @@ describe Aspect, "methods" do
411
411
  else
412
412
  Aquarium::AspectInvocationTestClass.new.method("#{@protection}_test_method").call :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
413
413
  end
414
- advice_called.should be_true
414
+ advice_called.should be_truthy
415
415
  aspect.unadvise
416
416
  end
417
417
 
@@ -599,7 +599,7 @@ describe Aspect, "methods" do
599
599
  object.method("#{@protection}_test_method_args".intern).call
600
600
  @expected_args = :a1
601
601
  object.method("#{@protection}_test_method_args=".intern).call @expected_args
602
- advice_called.should be_true
602
+ advice_called.should be_truthy
603
603
  aspect.unadvise
604
604
  end
605
605
 
@@ -733,7 +733,7 @@ describe Aspect, "methods" do
733
733
  make_array(@object_spec).each do |object|
734
734
  object.method("#{@protection}_test_method".intern).call :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
735
735
  end
736
- advice_called.should be_true
736
+ advice_called.should be_truthy
737
737
  aspect.unadvise
738
738
  end
739
739
 
@@ -829,7 +829,7 @@ describe Aspect, "methods" do
829
829
  object.method("#{@protection}_test_method_args".intern).call
830
830
  @expected_args = :a1
831
831
  object.method("#{@protection}_test_method_args=".intern).call @expected_args
832
- advice_called.should be_true
832
+ advice_called.should be_truthy
833
833
  end
834
834
  aspect.unadvise
835
835
  end
@@ -926,7 +926,7 @@ describe Aspect, "methods" do
926
926
  else
927
927
  Aquarium::AspectInvocationTestClass.new.method("#{@protection}_test_method".intern).call :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
928
928
  end
929
- advice_called.should be_true
929
+ advice_called.should be_truthy
930
930
  aspect.unadvise
931
931
  end
932
932
 
@@ -1117,7 +1117,7 @@ describe Aspect, "methods" do
1117
1117
  args.should == [:a1, :a2, :a3, {:h1 => 'h1', :h2 => 'h2'}]
1118
1118
  end
1119
1119
  Aquarium::AspectInvocationTestClass.new.public_test_method :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
1120
- advice_called.should be_true
1120
+ advice_called.should be_truthy
1121
1121
  aspect.unadvise
1122
1122
  end
1123
1123
 
@@ -1423,7 +1423,7 @@ describe Aspect, "methods" do
1423
1423
  args.should == [:a1, :a2, :a3, {:h1 => 'h1', :h2 => 'h2'}]
1424
1424
  end
1425
1425
  object.public_test_method :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
1426
- advice_called.should be_true
1426
+ advice_called.should be_truthy
1427
1427
  aspect.unadvise
1428
1428
  end
1429
1429
 
@@ -1438,7 +1438,7 @@ describe Aspect, "methods" do
1438
1438
  }
1439
1439
  aspect = Aspect.new :before, :object => object, :methods => :public_test_method, :advice => advice
1440
1440
  object.public_test_method :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
1441
- advice_called.should be_true
1441
+ advice_called.should be_truthy
1442
1442
  aspect.unadvise
1443
1443
  end
1444
1444
 
@@ -1454,7 +1454,7 @@ describe Aspect, "methods" do
1454
1454
  }
1455
1455
  aspect = Aspect.new :before, :object => object, :methods => :public_test_method, key.intern => advice
1456
1456
  object.public_test_method :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
1457
- advice_called.should be_true
1457
+ advice_called.should be_truthy
1458
1458
  aspect.unadvise
1459
1459
  end
1460
1460
  end
@@ -1464,7 +1464,7 @@ describe Aspect, "methods" do
1464
1464
  advice_called = false
1465
1465
  advice1 = Proc.new {|jp, obj, *args| fail "advice1"}
1466
1466
  advice2 = Proc.new {|jp, obj, *args| fail "advice2"}
1467
- lambda {Aspect.new :before, :object => object, :methods => :public_test_method, :advice => advice1, :invoke => advice2}.should raise_error(Aquarium::Utils::InvalidOptions)
1467
+ expect {Aspect.new :before, :object => object, :methods => :public_test_method, :advice => advice1, :invoke => advice2}.to raise_error(Aquarium::Utils::InvalidOptions)
1468
1468
  end
1469
1469
 
1470
1470
  it "should allow ignore an :advice option if a block is given." do
@@ -1476,18 +1476,18 @@ describe Aspect, "methods" do
1476
1476
  advice_called = true
1477
1477
  end
1478
1478
  object.public_test_method :a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2'
1479
- advice_called.should be_true
1479
+ advice_called.should be_truthy
1480
1480
  aspect.unadvise
1481
1481
  end
1482
1482
  end
1483
1483
 
1484
1484
  describe Aspect, ".new (advice block or proc parameter list)" do
1485
1485
  it "should raise unless an advice block or :advice => advice parameter is specified." do
1486
- lambda { Aspect.new(:after, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method)}.should raise_error(Aquarium::Utils::InvalidOptions)
1486
+ expect { Aspect.new(:after, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method)}.to raise_error(Aquarium::Utils::InvalidOptions)
1487
1487
  end
1488
1488
 
1489
1489
  it "should raise if obsolete |jp, *args| list is used." do
1490
- lambda { Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method do |jp, *args|; end }.should raise_error(Aquarium::Utils::InvalidOptions)
1490
+ expect { Aspect.new :before, :type => Aquarium::AspectInvocationTestClass, :methods => :public_test_method do |jp, *args|; end }.to raise_error(Aquarium::Utils::InvalidOptions)
1491
1491
  end
1492
1492
 
1493
1493
  it "should accept an argument list matching |jp, object, *args|." do
@@ -1566,12 +1566,12 @@ describe Aspect, "methods" do
1566
1566
  @included_types.each do |type|
1567
1567
  advice_called = false
1568
1568
  type.new(1).doit
1569
- advice_called.should be_true
1569
+ advice_called.should be_truthy
1570
1570
  end
1571
1571
  @excluded_types.each do |type|
1572
1572
  advice_called = false
1573
1573
  type.new(1).doit
1574
- advice_called.should_not be_true
1574
+ advice_called.should_not be_truthy
1575
1575
  end
1576
1576
  aspect.unadvise
1577
1577
  end
@@ -1644,12 +1644,12 @@ describe Aspect, "methods" do
1644
1644
  @included_objects.each do |object|
1645
1645
  advice_called = false
1646
1646
  object.doit
1647
- advice_called.should be_true
1647
+ advice_called.should be_truthy
1648
1648
  end
1649
1649
  @excluded_objects.each do |object|
1650
1650
  advice_called = false
1651
1651
  object.doit
1652
- advice_called.should_not be_true
1652
+ advice_called.should_not be_truthy
1653
1653
  end
1654
1654
  aspect.unadvise
1655
1655
  end
@@ -1688,12 +1688,12 @@ describe Aspect, "methods" do
1688
1688
  @included_objects.each do |object|
1689
1689
  advice_called = false
1690
1690
  object.doit
1691
- advice_called.should be_true
1691
+ advice_called.should be_truthy
1692
1692
  end
1693
1693
  @excluded_objects.each do |object|
1694
1694
  advice_called = false
1695
1695
  object.doit
1696
- advice_called.should_not be_true
1696
+ advice_called.should_not be_truthy
1697
1697
  end
1698
1698
  aspect.unadvise
1699
1699
  end
@@ -1723,12 +1723,12 @@ describe Aspect, "methods" do
1723
1723
  included_types.each do |type|
1724
1724
  advice_called = false
1725
1725
  type.new(1).doit
1726
- advice_called.should be_true
1726
+ advice_called.should be_truthy
1727
1727
  end
1728
1728
  excluded_types.each do |type|
1729
1729
  advice_called = false
1730
1730
  type.new(1).doit
1731
- advice_called.should_not be_true
1731
+ advice_called.should_not be_truthy
1732
1732
  end
1733
1733
  aspect.unadvise
1734
1734
  end
@@ -1747,10 +1747,10 @@ describe Aspect, "methods" do
1747
1747
 
1748
1748
  advice_called = false
1749
1749
  ClassWithPublicInstanceMethod.new.public_instance_test_method
1750
- advice_called.should be_false
1750
+ advice_called.should be_falsey
1751
1751
  advice_called = false
1752
1752
  ClassIncludingModuleWithPublicInstanceMethod.new.public_instance_module_test_method
1753
- advice_called.should be_false
1753
+ advice_called.should be_falsey
1754
1754
  aspect.unadvise
1755
1755
  end
1756
1756
  end
@@ -1768,10 +1768,10 @@ describe Aspect, "methods" do
1768
1768
 
1769
1769
  advice_called = false
1770
1770
  ClassWithPublicInstanceMethod.new.public_instance_test_method
1771
- advice_called.should be_false
1771
+ advice_called.should be_falsey
1772
1772
  advice_called = false
1773
1773
  ClassIncludingModuleWithPublicInstanceMethod.new.public_instance_module_test_method
1774
- advice_called.should be_false
1774
+ advice_called.should be_falsey
1775
1775
  aspect.unadvise
1776
1776
  end
1777
1777
  end
@@ -1789,10 +1789,10 @@ describe Aspect, "methods" do
1789
1789
 
1790
1790
  advice_called = false
1791
1791
  ClassWithPublicInstanceMethod.new.public_instance_test_method
1792
- advice_called.should be_false
1792
+ advice_called.should be_falsey
1793
1793
  advice_called = false
1794
1794
  ClassIncludingModuleWithPublicInstanceMethod.new.public_instance_module_test_method
1795
- advice_called.should be_false
1795
+ advice_called.should be_falsey
1796
1796
  aspect.unadvise
1797
1797
  end
1798
1798
  end
@@ -1815,12 +1815,12 @@ describe Aspect, "methods" do
1815
1815
  included_types.each do |type|
1816
1816
  advice_called = false
1817
1817
  type.new(1).doit
1818
- advice_called.should be_true
1818
+ advice_called.should be_truthy
1819
1819
  end
1820
1820
  excluded_types.each do |type|
1821
1821
  advice_called = false
1822
1822
  type.new(1).doit
1823
- advice_called.should_not be_true
1823
+ advice_called.should_not be_truthy
1824
1824
  end
1825
1825
  aspect.unadvise
1826
1826
  end
@@ -1851,12 +1851,12 @@ describe Aspect, "methods" do
1851
1851
  @included_objects.each do |object|
1852
1852
  advice_called = false
1853
1853
  object.doit
1854
- advice_called.should be_true
1854
+ advice_called.should be_truthy
1855
1855
  end
1856
1856
  @excluded_objects.each do |object|
1857
1857
  advice_called = false
1858
1858
  object.doit
1859
- advice_called.should_not be_true
1859
+ advice_called.should_not be_truthy
1860
1860
  end
1861
1861
  aspect.unadvise
1862
1862
  end
@@ -1890,12 +1890,12 @@ describe Aspect, "methods" do
1890
1890
  @included_types.each do |type|
1891
1891
  advice_called = false
1892
1892
  type.new(1).doit
1893
- advice_called.should be_true
1893
+ advice_called.should be_truthy
1894
1894
  end
1895
1895
  @excluded_types.each do |type|
1896
1896
  advice_called = false
1897
1897
  type.new(1).doit
1898
- advice_called.should_not be_true
1898
+ advice_called.should_not be_truthy
1899
1899
  end
1900
1900
  aspect.unadvise
1901
1901
  end
@@ -1924,12 +1924,12 @@ describe Aspect, "methods" do
1924
1924
  @included_types.each do |type|
1925
1925
  advice_called = false
1926
1926
  type.new(1).doit
1927
- advice_called.should be_true
1927
+ advice_called.should be_truthy
1928
1928
  end
1929
1929
  @excluded_types.each do |type|
1930
1930
  advice_called = false
1931
1931
  type.new(1).doit
1932
- advice_called.should_not be_true
1932
+ advice_called.should_not be_truthy
1933
1933
  end
1934
1934
  aspect.unadvise
1935
1935
  end
@@ -1947,12 +1947,12 @@ describe Aspect, "methods" do
1947
1947
  Aquarium::PointcutFinderTestClasses.all_class_variables_pointcut_classes.each do |type|
1948
1948
  advice_called = false
1949
1949
  type.new.doit
1950
- advice_called.should be_true
1950
+ advice_called.should be_truthy
1951
1951
  end
1952
1952
  Aquarium::PointcutFinderTestClasses.all_constants_pointcut_classes.each do |type|
1953
1953
  advice_called = false
1954
1954
  type.new.doit
1955
- advice_called.should_not be_true
1955
+ advice_called.should_not be_truthy
1956
1956
  end
1957
1957
  aspect.unadvise
1958
1958
  end
@@ -1985,12 +1985,12 @@ describe Aspect, "methods" do
1985
1985
  @included_types.each do |type|
1986
1986
  advice_called = false
1987
1987
  type.new(1).doit
1988
- advice_called.should be_true
1988
+ advice_called.should be_truthy
1989
1989
  end
1990
1990
  @excluded_types.each do |type|
1991
1991
  advice_called = false
1992
1992
  type.new(1).doit
1993
- advice_called.should_not be_true
1993
+ advice_called.should_not be_truthy
1994
1994
  end
1995
1995
  aspect.unadvise
1996
1996
  end
@@ -2096,12 +2096,12 @@ describe Aspect, "methods" do
2096
2096
  @included_objects.each do |object|
2097
2097
  advice_called = false
2098
2098
  object.doit
2099
- advice_called.should be_true
2099
+ advice_called.should be_truthy
2100
2100
  end
2101
2101
  @excluded_objects.each do |object|
2102
2102
  advice_called = false
2103
2103
  object.doit
2104
- advice_called.should_not be_true
2104
+ advice_called.should_not be_truthy
2105
2105
  end
2106
2106
  aspect.unadvise
2107
2107
  end
@@ -2146,23 +2146,23 @@ describe Aspect, "methods" do
2146
2146
  (@included_types + @excluded_types).each do |type|
2147
2147
  advice_called = false
2148
2148
  type.new(1).doit
2149
- advice_called.should be_true
2149
+ advice_called.should be_truthy
2150
2150
  end
2151
2151
  @excluded_types.each do |type|
2152
2152
  advice_called = false
2153
2153
  type.new(1).doit3
2154
- advice_called.should_not be_true
2154
+ advice_called.should be_falsey
2155
2155
  end
2156
2156
  end
2157
2157
  (@included_objects + @excluded_objects).each do |object|
2158
2158
  advice_called = false
2159
2159
  object.doit
2160
- advice_called.should be_true
2160
+ advice_called.should be_truthy
2161
2161
  end
2162
2162
  @excluded_objects.each do |object|
2163
2163
  advice_called = false
2164
2164
  object.doit3
2165
- advice_called.should_not be_true
2165
+ advice_called.should_not be_truthy
2166
2166
  end
2167
2167
  aspect.unadvise
2168
2168
  end
@@ -2205,7 +2205,7 @@ describe Aspect, "methods" do
2205
2205
  # (@excluded_objects).each do |object|
2206
2206
  # advice_called = false
2207
2207
  # object.doit
2208
- # advice_called.should be_true
2208
+ # advice_called.should be_truthy
2209
2209
  # end
2210
2210
  # aspect.unadvise
2211
2211
  # end