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
@@ -97,7 +97,7 @@ describe Aspect, " with :before advice" do
97
97
  block_called = 0
98
98
  watchful.public_watchful_method(:a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2') { |*args| block_called += 1 }
99
99
  block_called.should == 1
100
- advice_called.should be_true
100
+ advice_called.should be_truthy
101
101
  end
102
102
 
103
103
  it "should evaluate the advice before the method body and its block (if any)." do
@@ -127,7 +127,7 @@ describe Aspect, " with :after advice" do
127
127
  block_called = 0
128
128
  watchful.public_watchful_method(:a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2') { |*args| block_called += 1 }
129
129
  block_called.should == 1
130
- advice_called.should be_true
130
+ advice_called.should be_truthy
131
131
  end
132
132
 
133
133
  it "should pass the context information to the advice, including self, the method parameters, and the rescued exception when an exception is raised." do
@@ -137,14 +137,14 @@ describe Aspect, " with :after advice" do
137
137
  context = jp.context
138
138
  end
139
139
  block_called = 0
140
- lambda {watchful.public_watchful_method_that_raises(:a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2') do |*args|
140
+ expect {watchful.public_watchful_method_that_raises(:a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2') do |*args|
141
141
  block_called += 1
142
142
  args.should == [:a1, :a2, :a3, {:h1 => 'h1', :h2 => 'h2'}]
143
- end }.should raise_error(Watchful::WatchfulError)
143
+ end }.to raise_error(Watchful::WatchfulError)
144
144
  block_called.should == 1
145
145
  context.advised_object.should == watchful
146
146
  context.returned_value.should == nil
147
- context.raised_exception.kind_of?(Watchful::WatchfulError).should be_true
147
+ context.raised_exception.kind_of?(Watchful::WatchfulError).should be_truthy
148
148
  end
149
149
 
150
150
  it "should evaluate the advice after the method body and its block (if any)." do
@@ -187,10 +187,10 @@ describe Aspect, " with :after advice" do
187
187
  aspect_advice_invoked = true
188
188
  jp.context.raised_exception = MyError1
189
189
  end
190
- aspect_advice_invoked.should be_false
190
+ aspect_advice_invoked.should be_falsey
191
191
  ctr = ClassThatRaises.new
192
- lambda {ctr.raises}.should raise_error(MyError1)
193
- aspect_advice_invoked.should be_true
192
+ expect {ctr.raises}.to raise_error(MyError1)
193
+ aspect_advice_invoked.should be_truthy
194
194
  end
195
195
  end
196
196
 
@@ -213,7 +213,7 @@ describe Aspect, " with :after_returning advice" do
213
213
  block_called = 0
214
214
  watchful.public_watchful_method(:a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2') { |*args| block_called += 1 }
215
215
  block_called.should == 1
216
- advice_called.should be_true
216
+ advice_called.should be_truthy
217
217
  end
218
218
 
219
219
  it "should evaluate the advice after the method body and its block (if any)." do
@@ -265,12 +265,12 @@ describe Aspect, " with :after_raising advice" do
265
265
  jp.context.advised_object.should == watchful
266
266
  jp.context.advice_kind.should == :after_raising
267
267
  jp.context.returned_value.should == nil
268
- jp.context.raised_exception.kind_of?(Watchful::WatchfulError).should be_true
268
+ jp.context.raised_exception.kind_of?(Watchful::WatchfulError).should be_truthy
269
269
  end
270
270
  block_called = 0
271
- lambda {watchful.public_watchful_method_that_raises(:a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2') { |*args| block_called += 1 }}.should raise_error(Watchful::WatchfulError)
271
+ expect {watchful.public_watchful_method_that_raises(:a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2') { |*args| block_called += 1 }}.to raise_error(Watchful::WatchfulError)
272
272
  block_called.should == 1
273
- advice_called.should be_true
273
+ advice_called.should be_truthy
274
274
  end
275
275
 
276
276
  it "should evaluate the advice after the method body and its block (if any)." do
@@ -285,9 +285,9 @@ describe Aspect, " with :after_raising advice" do
285
285
  @aspect = Aspect.new(:after_raising => Watchful::WatchfulError, :pointcut => {:type => Watchful, :methods => /public_watchful_method/}) {|jp, obj, *args| aspect_advice_invoked = true}
286
286
  block_invoked = false
287
287
  watchful = Watchful.new
288
- lambda {watchful.public_watchful_method_that_raises(:a1, :a2, :a3) {|*args| block_invoked = true}}.should raise_error(Watchful::WatchfulError)
289
- aspect_advice_invoked.should be_true
290
- block_invoked.should be_true
288
+ expect {watchful.public_watchful_method_that_raises(:a1, :a2, :a3) {|*args| block_invoked = true}}.to raise_error(Watchful::WatchfulError)
289
+ aspect_advice_invoked.should be_truthy
290
+ block_invoked.should be_truthy
291
291
  end
292
292
 
293
293
  it "should invoke advice when exceptions of the specified type are raised, which were specified with :exceptions => ..." do
@@ -295,9 +295,9 @@ describe Aspect, " with :after_raising advice" do
295
295
  @aspect = Aspect.new(:after_raising, :exceptions => Watchful::WatchfulError, :pointcut => {:type => Watchful, :methods => /public_watchful_method/}) {|jp, obj, *args| aspect_advice_invoked = true}
296
296
  block_invoked = false
297
297
  watchful = Watchful.new
298
- lambda {watchful.public_watchful_method_that_raises(:a1, :a2, :a3) {|*args| block_invoked = true}}.should raise_error(Watchful::WatchfulError)
299
- aspect_advice_invoked.should be_true
300
- block_invoked.should be_true
298
+ expect {watchful.public_watchful_method_that_raises(:a1, :a2, :a3) {|*args| block_invoked = true}}.to raise_error(Watchful::WatchfulError)
299
+ aspect_advice_invoked.should be_truthy
300
+ block_invoked.should be_truthy
301
301
  end
302
302
 
303
303
  it "should not invoke advice when exceptions of types that don't match the specified exception type are raised" do
@@ -305,9 +305,9 @@ describe Aspect, " with :after_raising advice" do
305
305
  @aspect = Aspect.new(:after_raising => MyError1, :pointcut => {:type => Watchful, :methods => /public_watchful_method/}) {|jp, obj, *args| aspect_advice_invoked = true}
306
306
  block_invoked = false
307
307
  watchful = Watchful.new
308
- lambda {watchful.public_watchful_method_that_raises(:a1, :a2, :a3) {|*args| block_invoked = true}}.should raise_error(Watchful::WatchfulError)
309
- aspect_advice_invoked.should be_false
310
- block_invoked.should be_true
308
+ expect {watchful.public_watchful_method_that_raises(:a1, :a2, :a3) {|*args| block_invoked = true}}.to raise_error(Watchful::WatchfulError)
309
+ aspect_advice_invoked.should be_falsey
310
+ block_invoked.should be_truthy
311
311
  end
312
312
 
313
313
  it "should not invoke advice when exceptions of types that don't match the specified exception type are raised, which were specified with :exceptions => ..." do
@@ -315,9 +315,9 @@ describe Aspect, " with :after_raising advice" do
315
315
  @aspect = Aspect.new(:after_raising, :exceptions => MyError1, :pointcut => {:type => Watchful, :methods => /public_watchful_method/}) {|jp, obj, *args| aspect_advice_invoked = true}
316
316
  block_invoked = false
317
317
  watchful = Watchful.new
318
- lambda {watchful.public_watchful_method_that_raises(:a1, :a2, :a3) {|*args| block_invoked = true}}.should raise_error(Watchful::WatchfulError)
319
- aspect_advice_invoked.should be_false
320
- block_invoked.should be_true
318
+ expect {watchful.public_watchful_method_that_raises(:a1, :a2, :a3) {|*args| block_invoked = true}}.to raise_error(Watchful::WatchfulError)
319
+ aspect_advice_invoked.should be_falsey
320
+ block_invoked.should be_truthy
321
321
  end
322
322
 
323
323
  it "should invoke advice when one exception in the list of the specified types is raised" do
@@ -325,17 +325,17 @@ describe Aspect, " with :after_raising advice" do
325
325
  @aspect = Aspect.new(:after_raising => [Watchful::WatchfulError, MyError1], :pointcut => {:type => Watchful, :methods => /public_watchful_method/}) {|jp, obj, *args| aspect_advice_invoked = true}
326
326
  block_invoked = false
327
327
  watchful = Watchful.new
328
- lambda {watchful.public_watchful_method_that_raises(:a1, :a2, :a3) {|*args| block_invoked = true}}.should raise_error(Watchful::WatchfulError)
329
- aspect_advice_invoked.should be_true
330
- block_invoked.should be_true
328
+ expect {watchful.public_watchful_method_that_raises(:a1, :a2, :a3) {|*args| block_invoked = true}}.to raise_error(Watchful::WatchfulError)
329
+ aspect_advice_invoked.should be_truthy
330
+ block_invoked.should be_truthy
331
331
  end
332
332
 
333
333
  it "should invoke advice when an exception that subclasses a specified exception type is raised" do
334
334
  aspect_advice_invoked = false
335
335
  @aspect = Aspect.new(:after_raising => StandardError, :pointcut => {:type => ClassThatRaises, :methods => :raises}) {|jp, obj, *args| aspect_advice_invoked = true}
336
336
  ctr = ClassThatRaises.new
337
- lambda {ctr.raises}.should raise_error(ClassThatRaises::CTRException)
338
- aspect_advice_invoked.should be_true
337
+ expect {ctr.raises}.to raise_error(ClassThatRaises::CTRException)
338
+ aspect_advice_invoked.should be_truthy
339
339
  end
340
340
 
341
341
  it "should not invoke advice when exceptions of types that don't match the specified list of exception types are raised" do
@@ -343,9 +343,9 @@ describe Aspect, " with :after_raising advice" do
343
343
  @aspect = Aspect.new(:after_raising => [MyError1, MyError2], :pointcut => {:type => Watchful, :methods => /public_watchful_method/}) {|jp, obj, *args| aspect_advice_invoked = true}
344
344
  block_invoked = false
345
345
  watchful = Watchful.new
346
- lambda {watchful.public_watchful_method_that_raises(:a1, :a2, :a3) {|*args| block_invoked = true}}.should raise_error(Watchful::WatchfulError)
347
- aspect_advice_invoked.should be_false
348
- block_invoked.should be_true
346
+ expect {watchful.public_watchful_method_that_raises(:a1, :a2, :a3) {|*args| block_invoked = true}}.to raise_error(Watchful::WatchfulError)
347
+ aspect_advice_invoked.should be_falsey
348
+ block_invoked.should be_truthy
349
349
  end
350
350
 
351
351
  it "should not invoke advice when exceptions of types that don't match the specified list of exception types are raised, which were specified with :exceptions => ..." do
@@ -353,9 +353,9 @@ describe Aspect, " with :after_raising advice" do
353
353
  @aspect = Aspect.new(:after_raising, :exceptions => [MyError1, MyError2], :pointcut => {:type => Watchful, :methods => /public_watchful_method/}) {|jp, obj, *args| aspect_advice_invoked = true}
354
354
  block_invoked = false
355
355
  watchful = Watchful.new
356
- lambda {watchful.public_watchful_method_that_raises(:a1, :a2, :a3) {|*args| block_invoked = true}}.should raise_error(Watchful::WatchfulError)
357
- aspect_advice_invoked.should be_false
358
- block_invoked.should be_true
356
+ expect {watchful.public_watchful_method_that_raises(:a1, :a2, :a3) {|*args| block_invoked = true}}.to raise_error(Watchful::WatchfulError)
357
+ aspect_advice_invoked.should be_falsey
358
+ block_invoked.should be_truthy
359
359
  end
360
360
 
361
361
  it "should treat :exception as a synonym for :exceptions" do
@@ -363,9 +363,9 @@ describe Aspect, " with :after_raising advice" do
363
363
  @aspect = Aspect.new(:after_raising, :exception => [MyError1, MyError2], :pointcut => {:type => Watchful, :methods => /public_watchful_method/}) {|jp, obj, *args| aspect_advice_invoked = true}
364
364
  block_invoked = false
365
365
  watchful = Watchful.new
366
- lambda {watchful.public_watchful_method_that_raises(:a1, :a2, :a3) {|*args| block_invoked = true}}.should raise_error(Watchful::WatchfulError)
367
- aspect_advice_invoked.should be_false
368
- block_invoked.should be_true
366
+ expect {watchful.public_watchful_method_that_raises(:a1, :a2, :a3) {|*args| block_invoked = true}}.to raise_error(Watchful::WatchfulError)
367
+ aspect_advice_invoked.should be_falsey
368
+ block_invoked.should be_truthy
369
369
  end
370
370
 
371
371
  it "should merge exceptions specified with :exception(s) and :after_raising" do
@@ -379,10 +379,10 @@ describe Aspect, " with :after_raising advice" do
379
379
  @aspect = Aspect.new :after_raising, :pointcut => {:type => ClassThatRaises, :methods => :raises} do |jp, obj, *args|
380
380
  aspect_advice_invoked = true
381
381
  end
382
- aspect_advice_invoked.should be_false
382
+ aspect_advice_invoked.should be_falsey
383
383
  ctr = ClassThatRaises.new
384
- lambda {ctr.raises}.should raise_error(ClassThatRaises::CTRException)
385
- aspect_advice_invoked.should be_true
384
+ expect {ctr.raises}.to raise_error(ClassThatRaises::CTRException)
385
+ aspect_advice_invoked.should be_truthy
386
386
  end
387
387
 
388
388
  it "should advise all methods that raise strings (which are converted to RuntimeError) when no specific exceptions are specified" do
@@ -390,10 +390,10 @@ describe Aspect, " with :after_raising advice" do
390
390
  @aspect = Aspect.new :after_raising, :pointcut => {:type => ClassThatRaisesString, :methods => :raises} do |jp, obj, *args|
391
391
  aspect_advice_invoked = true
392
392
  end
393
- aspect_advice_invoked.should be_false
393
+ aspect_advice_invoked.should be_falsey
394
394
  ctr = ClassThatRaisesString.new
395
- lambda {ctr.raises}.should raise_error(RuntimeError)
396
- aspect_advice_invoked.should be_true
395
+ expect {ctr.raises}.to raise_error(RuntimeError)
396
+ aspect_advice_invoked.should be_truthy
397
397
  end
398
398
 
399
399
  it "should allow advice to change the exception raised" do
@@ -402,10 +402,10 @@ describe Aspect, " with :after_raising advice" do
402
402
  aspect_advice_invoked = true
403
403
  jp.context.raised_exception = MyError1
404
404
  end
405
- aspect_advice_invoked.should be_false
405
+ aspect_advice_invoked.should be_falsey
406
406
  ctr = ClassThatRaises.new
407
- lambda {ctr.raises}.should raise_error(MyError1)
408
- aspect_advice_invoked.should be_true
407
+ expect {ctr.raises}.to raise_error(MyError1)
408
+ aspect_advice_invoked.should be_truthy
409
409
  end
410
410
  end
411
411
 
@@ -517,13 +517,13 @@ describe Aspect, " with :before and :after_raising advice" do
517
517
  args.should == [:a1, :a2, :a3, {:h1 => 'h1', :h2 => 'h2'}]
518
518
  end
519
519
  block_called = 0
520
- lambda {watchful.public_watchful_method_that_raises(:a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2') { |*args| block_called += 1 }}.should raise_error(Watchful::WatchfulError)
520
+ expect {watchful.public_watchful_method_that_raises(:a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2') { |*args| block_called += 1 }}.to raise_error(Watchful::WatchfulError)
521
521
  block_called.should == 1
522
522
  contexts.size.should == 2
523
523
  advice_kinds[0].should == :before
524
524
  advice_kinds[1].should == :after_raising
525
525
  raised_exceptions[0].should == nil
526
- raised_exceptions[1].kind_of?(Watchful::WatchfulError).should be_true
526
+ raised_exceptions[1].kind_of?(Watchful::WatchfulError).should be_truthy
527
527
  contexts.each do |context|
528
528
  context.advised_object.should == watchful
529
529
  context.returned_value.should == nil
@@ -560,10 +560,10 @@ describe Aspect, " with :around advice" do
560
560
  watchful.public_watchful_method(:a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2') { |*args| public_block_called = true }
561
561
  watchful.send(:protected_watchful_method, :b1, :b2, :b3) {|*args| protected_block_called = true}
562
562
  watchful.send(:private_watchful_method, :c1, :c2, :c3) {|*args| private_block_called = true}
563
- public_block_called.should be_false # proceed is never called!
564
- protected_block_called.should be_true
565
- private_block_called.should be_true
566
- advice_called.should be_true
563
+ public_block_called.should be_falsey # proceed is never called!
564
+ protected_block_called.should be_truthy
565
+ private_block_called.should be_truthy
566
+ advice_called.should be_truthy
567
567
  end
568
568
 
569
569
  module AdvisingSuperClass
@@ -601,10 +601,10 @@ describe Aspect, " with :around advice" do
601
601
  child.public_method(:a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2') { |*args| fail }
602
602
  child.send(:protected_method, :b1, :b2, :b3) {|*args| protected_block_called = true}
603
603
  child.send(:private_method, :c1, :c2, :c3) {|*args| private_block_called = true}
604
- public_block_called.should be_false # proceed is never called!
605
- protected_block_called.should be_true
606
- private_block_called.should be_true
607
- advice_called.should be_true
604
+ public_block_called.should be_falsey # proceed is never called!
605
+ protected_block_called.should be_truthy
606
+ private_block_called.should be_truthy
607
+ advice_called.should be_truthy
608
608
  end
609
609
 
610
610
  module AdvisingSubClass
@@ -642,10 +642,10 @@ describe Aspect, " with :around advice" do
642
642
  child.public_method(:a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2') { |*args| fail }
643
643
  child.send(:protected_method, :b1, :b2, :b3) {|*args| protected_block_called = true}
644
644
  child.send(:private_method, :c1, :c2, :c3) {|*args| private_block_called = true}
645
- public_block_called.should be_false # proceed is never called!
646
- protected_block_called.should be_true
647
- private_block_called.should be_true
648
- advice_called.should be_true
645
+ public_block_called.should be_falsey # proceed is never called!
646
+ protected_block_called.should be_truthy
647
+ private_block_called.should be_truthy
648
+ advice_called.should be_truthy
649
649
  end
650
650
 
651
651
  class WatchfulChild2 < Watchful
@@ -665,7 +665,7 @@ describe Aspect, " with :around advice" do
665
665
  child = WatchfulChild2.new
666
666
  public_block_called = false
667
667
  child.public_watchful_method(:a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2') { |*args| public_block_called = true }
668
- public_block_called.should be_true # advice never called
668
+ public_block_called.should be_truthy # advice never called
669
669
  end
670
670
 
671
671
  it "should evaluate the advice and only evaluate the method body and its block (if any) when JoinPoint#proceed is called." do
@@ -692,8 +692,8 @@ describe Aspect, " with :around advice" do
692
692
  watchful = Watchful.new
693
693
  orig_block_called = false
694
694
  watchful.public_watchful_method(:a1, :a2, :a3) {|*args| orig_block_called = true}
695
- override_block_called.should be_true
696
- orig_block_called.should be_false
695
+ override_block_called.should be_truthy
696
+ orig_block_called.should be_falsey
697
697
  watchful.public_watchful_method_args.should == [:a4, :a5, :a6]
698
698
  end
699
699
 
@@ -765,8 +765,8 @@ describe Aspect, "#unadvise called more than once on the same aspect" do
765
765
  it "should do nothing on the second invocation." do
766
766
  aspect = Aspect.new :around, :type => Watchful, :method => /does_not_exist/, :advice => @advice, :severity => Logger::Severity::ERROR
767
767
  aspect.unadvise
768
- lambda {aspect.unadvise}.should_not raise_error
769
- lambda {aspect.unadvise}.should_not raise_error
768
+ expect {aspect.unadvise}.not_to raise_error
769
+ expect {aspect.unadvise}.not_to raise_error
770
770
  end
771
771
  end
772
772
 
@@ -817,9 +817,9 @@ describe Aspect, "#unadvise clean up" do
817
817
  [public_methods, protected_methods, private_methods]
818
818
  end
819
819
 
820
- def diff_methods actual, expected, private_should_not_be_equal = false
820
+ def diff_methods actual, expected, private_not_to_be_equal = false
821
821
  3.times do |i|
822
- if i==2 && private_should_not_be_equal
822
+ if i==2 && private_not_to_be_equal
823
823
  actual[i].should_not == expected[i]
824
824
  else
825
825
  actual[i].should == expected[i]
@@ -840,8 +840,8 @@ describe Aspect, "#unadvise clean up" do
840
840
  advice_called = false
841
841
  block_called = false
842
842
  @watchful.send("#{protection}_watchful_method".intern, :a1, :a2, :a3) {|*args| block_called = true}
843
- advice_called.should be_false
844
- block_called.should be_true
843
+ advice_called.should be_falsey
844
+ block_called.should be_truthy
845
845
  end
846
846
  end
847
847
 
@@ -949,7 +949,7 @@ describe Aspect, " when unadvising methods for instance-type pointcuts for type-
949
949
  aspect = Aspect.new(:before, :object => object, :method => :m) {true}
950
950
  aspect.unadvise
951
951
  object.m
952
- object.called.should be_true
952
+ object.called.should be_truthy
953
953
  end
954
954
  end
955
955
 
@@ -960,7 +960,7 @@ describe Aspect, " when unadvising methods for instance-type pointcuts for insta
960
960
  aspect = Aspect.new(:before, :object => object, :method => :m) {true}
961
961
  aspect.unadvise
962
962
  object.m
963
- object.called.should be_true
963
+ object.called.should be_truthy
964
964
  end
965
965
  end
966
966
 
@@ -1079,7 +1079,7 @@ def do_watchful_spec protection, raises, expected_advice_called_value, args_pass
1079
1079
  @advice_called = 0
1080
1080
  block_called = 0
1081
1081
  if raises
1082
- lambda {watchful.send("#{protection}_watchful_method#{suffix}".intern, :a1, :a2, :a3) {|*args| block_called += 1}}.should raise_error(Watchful::WatchfulError)
1082
+ expect {watchful.send("#{protection}_watchful_method#{suffix}".intern, :a1, :a2, :a3) {|*args| block_called += 1}}.to raise_error(Watchful::WatchfulError)
1083
1083
  else
1084
1084
  watchful.send("#{protection}_watchful_method#{suffix}".intern, :a1, :a2, :a3) {|*args| block_called += 1}
1085
1085
  end
@@ -42,7 +42,7 @@ describe Aspect, ".new when advising methods in a nested class" do
42
42
  block_called = 0
43
43
  myclass.do1(:a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2') { |*args| block_called += 1 }
44
44
  block_called.should == 1
45
- advice_called.should be_true
45
+ advice_called.should be_truthy
46
46
  end
47
47
 
48
48
  it "should correctly advise methods in an instance of the nested class." do
@@ -59,7 +59,7 @@ describe Aspect, ".new when advising methods in a nested class" do
59
59
  block_called = 0
60
60
  myclass.do1(:a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2') { |*args| block_called += 1 }
61
61
  block_called.should == 1
62
- advice_called.should be_true
62
+ advice_called.should be_truthy
63
63
  end
64
64
  end
65
65
 
@@ -86,7 +86,7 @@ describe Aspect, ".new when advising methods in a nested module included by a cl
86
86
  block_called = 0
87
87
  myclass.do2(:a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2') { |*args| block_called += 1 }
88
88
  block_called.should == 1
89
- advice_called.should be_true
89
+ advice_called.should be_truthy
90
90
  end
91
91
 
92
92
  it "should correctly advise the module's methods when the class is specified." do
@@ -107,7 +107,7 @@ describe Aspect, ".new when advising methods in a nested module included by a cl
107
107
  block_called = 0
108
108
  myclass.do2(:a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2') { |*args| block_called += 1 }
109
109
  block_called.should == 1
110
- advice_called.should be_true
110
+ advice_called.should be_truthy
111
111
  end
112
112
 
113
113
  it "should correctly advise the module's methods when an instance of the class is specified." do
@@ -129,7 +129,7 @@ describe Aspect, ".new when advising methods in a nested module included by a cl
129
129
  block_called = 0
130
130
  myclass.do2(:a1, :a2, :a3, :h1 => 'h1', :h2 => 'h2') { |*args| block_called += 1 }
131
131
  block_called.should == 1
132
- advice_called.should be_true
132
+ advice_called.should be_truthy
133
133
  end
134
134
  end
135
135
 
@@ -39,7 +39,7 @@ module ConcurrentAspectsSpecSupport
39
39
  end
40
40
 
41
41
  def do_invoke_raises accessed
42
- lambda {accessed.invoke_raises :a1, :a2}.should raise_error(ConcurrentlyAccessed::Error)
42
+ expect {accessed.invoke_raises :a1, :a2}.to raise_error(ConcurrentlyAccessed::Error)
43
43
  end
44
44
 
45
45
  def do_invoke accessed
@@ -45,31 +45,31 @@ end
45
45
 
46
46
  describe Aquarium::Aspects::DefaultObjectsHandler, "#default_objects_given?" do
47
47
  it "should return false if the specification contains no :default_object or :default_objects key." do
48
- Aquarium::DefaultObjectsClass.new.default_objects_given?.should be_false
48
+ Aquarium::DefaultObjectsClass.new.default_objects_given?.should be_falsey
49
49
  end
50
50
 
51
51
  it "should return true if one or more objects were specified with the :default_object key." do
52
52
  defaults = ["1", "2"]
53
53
  doc = Aquarium::DefaultObjectsClass.new :default_object => defaults
54
- doc.default_objects_given?.should be_true
54
+ doc.default_objects_given?.should be_truthy
55
55
  end
56
56
 
57
57
  it "should return true if one or more objects were specified with the :default_objects key." do
58
58
  defaults = ["1", "2"]
59
59
  doc = Aquarium::DefaultObjectsClass.new :default_objects => defaults
60
- doc.default_objects_given?.should be_true
60
+ doc.default_objects_given?.should be_truthy
61
61
  end
62
62
 
63
63
  it "should return true if a single objects was specified with the :default_object key." do
64
64
  default = "1"
65
65
  doc = Aquarium::DefaultObjectsClass.new :default_object => default
66
- doc.default_objects_given?.should be_true
66
+ doc.default_objects_given?.should be_truthy
67
67
  end
68
68
 
69
69
  it "should return true if a single objects was specified with the :default_objects key." do
70
70
  default = "1"
71
71
  doc = Aquarium::DefaultObjectsClass.new :default_objects => default
72
- doc.default_objects_given?.should be_true
72
+ doc.default_objects_given?.should be_truthy
73
73
  end
74
74
  end
75
75
 
@@ -26,80 +26,80 @@ include Aquarium::Aspects
26
26
  describe JoinPoint, "#initialize with invalid parameters" do
27
27
 
28
28
  it "should require either a :type or an :object parameter, but not both." do
29
- lambda { JoinPoint.new :method_name => :count }.should raise_error(Aquarium::Utils::InvalidOptions)
30
- lambda { JoinPoint.new :type => String, :object => "", :method_name => :count }.should raise_error(Aquarium::Utils::InvalidOptions)
29
+ expect { JoinPoint.new :method_name => :count }.to raise_error(Aquarium::Utils::InvalidOptions)
30
+ expect { JoinPoint.new :type => String, :object => "", :method_name => :count }.to raise_error(Aquarium::Utils::InvalidOptions)
31
31
  end
32
32
 
33
33
  it "should require a :method_name." do
34
- lambda { JoinPoint.new :type => String }.should raise_error(Aquarium::Utils::InvalidOptions)
34
+ expect { JoinPoint.new :type => String }.to raise_error(Aquarium::Utils::InvalidOptions)
35
35
  end
36
36
 
37
37
  it "should except :method as a synonym for :method_name." do
38
- lambda { JoinPoint.new :type => String, :method => :split }.should_not raise_error(Aquarium::Utils::InvalidOptions)
38
+ expect { JoinPoint.new :type => String, :method => :split }.not_to raise_error
39
39
  end
40
40
 
41
41
  it "should require a valid type name if a name is specified." do
42
- lambda { JoinPoint.new :type => "String", :method => :split }.should_not raise_error(Aquarium::Utils::InvalidOptions)
43
- lambda { JoinPoint.new :type => "Stringgy", :method => :split }.should raise_error(Aquarium::Utils::InvalidOptions)
42
+ expect { JoinPoint.new :type => "String", :method => :split }.not_to raise_error
43
+ expect { JoinPoint.new :type => "Stringgy", :method => :split }.to raise_error(Aquarium::Utils::InvalidOptions)
44
44
  end
45
45
 
46
46
  it "should require a valid type name symbol if a name is specified." do
47
- lambda { JoinPoint.new :type => :String, :method => :split }.should_not raise_error(Aquarium::Utils::InvalidOptions)
48
- lambda { JoinPoint.new :type => :Stringgy, :method => :split }.should raise_error(Aquarium::Utils::InvalidOptions)
47
+ expect { JoinPoint.new :type => :String, :method => :split }.not_to raise_error
48
+ expect { JoinPoint.new :type => :Stringgy, :method => :split }.to raise_error(Aquarium::Utils::InvalidOptions)
49
49
  end
50
50
 
51
51
  it "should require a valid type name regular expression if one is specified." do
52
- lambda { JoinPoint.new :type => /^String$/, :method => :split }.should_not raise_error(Aquarium::Utils::InvalidOptions)
53
- lambda { JoinPoint.new :type => /^Stringgy$/, :method => :split }.should raise_error(Aquarium::Utils::InvalidOptions)
52
+ expect { JoinPoint.new :type => /^String$/, :method => :split }.not_to raise_error
53
+ expect { JoinPoint.new :type => /^Stringgy$/, :method => :split }.to raise_error(Aquarium::Utils::InvalidOptions)
54
54
  end
55
55
 
56
56
  it "should reject a regular expression that matches no types." do
57
- lambda { JoinPoint.new :type => /^Stringgy$/, :method => :split }.should raise_error(Aquarium::Utils::InvalidOptions)
57
+ expect { JoinPoint.new :type => /^Stringgy$/, :method => :split }.to raise_error(Aquarium::Utils::InvalidOptions)
58
58
  end
59
59
 
60
60
  it "should reject a regular expression that matches more than one type." do
61
- lambda { JoinPoint.new :type => /^M/, :method => :split }.should raise_error(Aquarium::Utils::InvalidOptions)
61
+ expect { JoinPoint.new :type => /^M/, :method => :split }.to raise_error(Aquarium::Utils::InvalidOptions)
62
62
  end
63
63
  end
64
64
 
65
65
  describe JoinPoint, "#initialize with parameters that specify class vs. instance methods" do
66
66
  it "should assume the :method_name refers to an instance method, by default." do
67
67
  jp = JoinPoint.new :type => String, :method => :split
68
- jp.instance_method?.should be_true
69
- jp.class_method?.should be_false
68
+ jp.instance_method?.should be_truthy
69
+ jp.class_method?.should be_falsey
70
70
  end
71
71
 
72
72
  it "should treat the :method_name as refering to an instance method if :instance_method is specified as true." do
73
73
  jp = JoinPoint.new :type => String, :method => :split, :instance_method => true
74
- jp.instance_method?.should be_true
75
- jp.class_method?.should be_false
74
+ jp.instance_method?.should be_truthy
75
+ jp.class_method?.should be_falsey
76
76
  end
77
77
 
78
78
  it "should treat the :method_name as refering to a class method if :instance_method is specified as false." do
79
79
  jp = JoinPoint.new :type => String, :method => :split, :instance_method => false
80
- jp.instance_method?.should be_false
81
- jp.class_method?.should be_true
80
+ jp.instance_method?.should be_falsey
81
+ jp.class_method?.should be_truthy
82
82
  end
83
83
 
84
84
  it "should treat the :method_name as refering to an instance method if :class_method is specified as false." do
85
85
  jp = JoinPoint.new :type => String, :method => :split, :class_method => false
86
- jp.instance_method?.should be_true
87
- jp.class_method?.should be_false
86
+ jp.instance_method?.should be_truthy
87
+ jp.class_method?.should be_falsey
88
88
  end
89
89
 
90
90
  it "should treat the :method_name as refering to a class method if :class_method is specified as true." do
91
91
  jp = JoinPoint.new :type => String, :method => :split, :class_method => true
92
- jp.instance_method?.should be_false
93
- jp.class_method?.should be_true
92
+ jp.instance_method?.should be_falsey
93
+ jp.class_method?.should be_truthy
94
94
  end
95
95
 
96
96
  it "should treat give precedence to :instance_method if appears with :class_method." do
97
97
  jp = JoinPoint.new :type => String, :method => :split, :instance_method => false, :class_method => true
98
- jp.instance_method?.should be_false
99
- jp.class_method?.should be_true
98
+ jp.instance_method?.should be_falsey
99
+ jp.class_method?.should be_truthy
100
100
  jp = JoinPoint.new :type => String, :method => :split, :instance_method => true, :class_method => false
101
- jp.instance_method?.should be_true
102
- jp.class_method?.should be_false
101
+ jp.instance_method?.should be_truthy
102
+ jp.class_method?.should be_falsey
103
103
  end
104
104
  end
105
105
 
@@ -221,7 +221,7 @@ describe JoinPoint, "#proceed" do
221
221
  jp.context.advised_object = ioc
222
222
  jp.context.parameters = []
223
223
  jp.context.proceed_proc = nil
224
- lambda { jp.proceed }.should raise_error(JoinPoint::ProceedMethodNotAvailable)
224
+ expect { jp.proceed }.to raise_error(JoinPoint::ProceedMethodNotAvailable)
225
225
  end
226
226
 
227
227
  it "should not raise when the advice is :around advice" do
@@ -231,7 +231,7 @@ describe JoinPoint, "#proceed" do
231
231
  jp.context.advised_object = ioc
232
232
  jp.context.parameters = []
233
233
  jp.context.proceed_proc = Aquarium::Aspects::NoAdviceChainNode.new(:alias_method_name => :invoke)
234
- lambda { jp.proceed }.should_not raise_error(JoinPoint::ProceedMethodNotAvailable)
234
+ expect { jp.proceed }.not_to raise_error
235
235
  end
236
236
 
237
237
  it "should invoke the actual join point" do
@@ -242,7 +242,7 @@ describe JoinPoint, "#proceed" do
242
242
  jp.context.parameters = []
243
243
  jp.context.proceed_proc = Aquarium::Aspects::NoAdviceChainNode.new(:alias_method_name => :invoke)
244
244
  jp.proceed
245
- ioc.called.should be_true
245
+ ioc.called.should be_truthy
246
246
  end
247
247
  end
248
248
 
@@ -254,7 +254,7 @@ end
254
254
  describe JoinPoint, "#invoke_original_join_point" do
255
255
  it "should raise when the join point has an empty context" do
256
256
  jp = JoinPoint.new :type => InvokeOriginalClass, :method => :invoke
257
- lambda { jp.invoke_original_join_point }.should raise_error(JoinPoint::ContextNotCorrectlyDefined)
257
+ expect { jp.invoke_original_join_point }.to raise_error(JoinPoint::ContextNotCorrectlyDefined)
258
258
  end
259
259
 
260
260
  it "should invoke the original join point" do
@@ -265,7 +265,7 @@ describe JoinPoint, "#invoke_original_join_point" do
265
265
  jp.context.parameters = []
266
266
  jp.context.current_advice_node = Aquarium::Aspects::NoAdviceChainNode.new(:alias_method_name => :invoke)
267
267
  jp.invoke_original_join_point
268
- ioc.called.should be_true
268
+ ioc.called.should be_truthy
269
269
  end
270
270
  end
271
271
 
@@ -423,37 +423,37 @@ end
423
423
  describe JoinPoint, "#exists?" do
424
424
  it "should return false if the join point represents a non-existent join point for an instance method in the runtime environment" do
425
425
  jp = JoinPoint.new :type => ProtectionExample, :method_name => :foo
426
- jp.exists?.should be_false
426
+ jp.exists?.should be_falsey
427
427
  end
428
428
 
429
429
  it "should return false if the join point represents a non-existent join point for a class method in the runtime environment" do
430
430
  jp = JoinPoint.new :type => ProtectionExample, :method_name => :foo, :class_method => true
431
- jp.exists?.should be_false
431
+ jp.exists?.should be_falsey
432
432
  end
433
433
 
434
434
  it "should return true if the join point represents a real join point for a public instance method in the runtime environment" do
435
435
  jp = JoinPoint.new :type => ProtectionExample, :method_name => :public_instance_m
436
- jp.exists?.should be_true
436
+ jp.exists?.should be_truthy
437
437
  end
438
438
 
439
439
  it "should return true if the join point represents a real join point for a protected instance method in the runtime environment" do
440
440
  jp = JoinPoint.new :type => ProtectionExample, :method_name => :protected_instance_m
441
- jp.exists?.should be_true
441
+ jp.exists?.should be_truthy
442
442
  end
443
443
 
444
444
  it "should return true if the join point represents a real join point for a private instance method in the runtime environment" do
445
445
  jp = JoinPoint.new :type => ProtectionExample, :method_name => :private_instance_m
446
- jp.exists?.should be_true
446
+ jp.exists?.should be_truthy
447
447
  end
448
448
 
449
449
  it "should return true if the join point represents a real join point for a public class method in the runtime environment" do
450
450
  jp = JoinPoint.new :type => ProtectionExample, :method_name => :public_class_m, :class_method => true
451
- jp.exists?.should be_true
451
+ jp.exists?.should be_truthy
452
452
  end
453
453
 
454
454
  it "should return true if the join point represents a real join point for a private class method in the runtime environment" do
455
455
  jp = JoinPoint.new :type => ProtectionExample, :method_name => :private_class_m, :class_method => true
456
- jp.exists?.should be_true
456
+ jp.exists?.should be_truthy
457
457
  end
458
458
 
459
459
  class ProtectionExample2
@@ -486,11 +486,11 @@ describe JoinPoint::Context, "#initialize" do
486
486
  end
487
487
 
488
488
  it "should accept a :returned_value argument." do
489
- lambda { JoinPoint::Context.new :advice_kind => :before, :advised_object => "object", :parameters => [","], :returned_value => ["12", "34"]}.should_not raise_error(Aquarium::Utils::InvalidOptions)
489
+ expect { JoinPoint::Context.new :advice_kind => :before, :advised_object => "object", :parameters => [","], :returned_value => ["12", "34"]}.not_to raise_error
490
490
  end
491
491
 
492
492
  it "should accept a :raised_exception argument." do
493
- lambda { JoinPoint::Context.new :advice_kind => :before, :advised_object => "object", :parameters => [","], :raised_exception => NameError.new}.should_not raise_error(Aquarium::Utils::InvalidOptions)
493
+ expect { JoinPoint::Context.new :advice_kind => :before, :advised_object => "object", :parameters => [","], :raised_exception => NameError.new}.not_to raise_error
494
494
  end
495
495
 
496
496
  end