summaryrefslogtreecommitdiff
path: root/spec/ruby/library/delegate/delegator
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/delegate/delegator')
-rw-r--r--spec/ruby/library/delegate/delegator/case_compare_spec.rb11
-rw-r--r--spec/ruby/library/delegate/delegator/compare_spec.rb11
-rw-r--r--spec/ruby/library/delegate/delegator/complement_spec.rb11
-rw-r--r--spec/ruby/library/delegate/delegator/eql_spec.rb46
-rw-r--r--spec/ruby/library/delegate/delegator/equal_spec.rb13
-rw-r--r--spec/ruby/library/delegate/delegator/equal_value_spec.rb24
-rw-r--r--spec/ruby/library/delegate/delegator/frozen_spec.rb39
-rw-r--r--spec/ruby/library/delegate/delegator/hash_spec.rb11
-rw-r--r--spec/ruby/library/delegate/delegator/marshal_spec.rb21
-rw-r--r--spec/ruby/library/delegate/delegator/method_spec.rb69
-rw-r--r--spec/ruby/library/delegate/delegator/methods_spec.rb37
-rw-r--r--spec/ruby/library/delegate/delegator/not_equal_spec.rb24
-rw-r--r--spec/ruby/library/delegate/delegator/not_spec.rb11
-rw-r--r--spec/ruby/library/delegate/delegator/private_methods_spec.rb20
-rw-r--r--spec/ruby/library/delegate/delegator/protected_methods_spec.rb18
-rw-r--r--spec/ruby/library/delegate/delegator/public_methods_spec.rb18
-rw-r--r--spec/ruby/library/delegate/delegator/send_spec.rb26
-rw-r--r--spec/ruby/library/delegate/delegator/taint_spec.rb23
-rw-r--r--spec/ruby/library/delegate/delegator/tap_spec.rb16
-rw-r--r--spec/ruby/library/delegate/delegator/trust_spec.rb22
-rw-r--r--spec/ruby/library/delegate/delegator/untaint_spec.rb24
-rw-r--r--spec/ruby/library/delegate/delegator/untrust_spec.rb23
22 files changed, 518 insertions, 0 deletions
diff --git a/spec/ruby/library/delegate/delegator/case_compare_spec.rb b/spec/ruby/library/delegate/delegator/case_compare_spec.rb
new file mode 100644
index 0000000000..8bf79c1425
--- /dev/null
+++ b/spec/ruby/library/delegate/delegator/case_compare_spec.rb
@@ -0,0 +1,11 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe "Delegator#===" do
+ it "is delegated" do
+ base = mock('base')
+ delegator = DelegateSpecs::Delegator.new(base)
+ base.should_receive(:===).with(42).and_return(:foo)
+ (delegator === 42).should == :foo
+ end
+end
diff --git a/spec/ruby/library/delegate/delegator/compare_spec.rb b/spec/ruby/library/delegate/delegator/compare_spec.rb
new file mode 100644
index 0000000000..93431bfeb2
--- /dev/null
+++ b/spec/ruby/library/delegate/delegator/compare_spec.rb
@@ -0,0 +1,11 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe "Delegator#<=>" do
+ it "is delegated" do
+ base = mock('base')
+ delegator = DelegateSpecs::Delegator.new(base)
+ base.should_receive(:<=>).with(42).and_return(1)
+ (delegator <=> 42).should == 1
+ end
+end
diff --git a/spec/ruby/library/delegate/delegator/complement_spec.rb b/spec/ruby/library/delegate/delegator/complement_spec.rb
new file mode 100644
index 0000000000..877a6e99c6
--- /dev/null
+++ b/spec/ruby/library/delegate/delegator/complement_spec.rb
@@ -0,0 +1,11 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe "Delegator#~" do
+ it "is delegated" do
+ base = mock('base')
+ delegator = DelegateSpecs::Delegator.new(base)
+ base.should_receive(:~).and_return(:foo)
+ (~delegator).should == :foo
+ end
+end
diff --git a/spec/ruby/library/delegate/delegator/eql_spec.rb b/spec/ruby/library/delegate/delegator/eql_spec.rb
new file mode 100644
index 0000000000..fd6824ec55
--- /dev/null
+++ b/spec/ruby/library/delegate/delegator/eql_spec.rb
@@ -0,0 +1,46 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe "Delegator#eql?" do
+ ruby_version_is ""..."2.5" do
+ it "is delegated" do
+ base = mock('base')
+ delegator = DelegateSpecs::Delegator.new(base)
+ base.should_receive(:eql?).with(42).and_return(:foo)
+ delegator.eql?(42).should == :foo
+ end
+ end
+
+ ruby_version_is "2.5" do
+ it "returns true when compared with same delegator" do
+ base = mock('base')
+ delegator = DelegateSpecs::Delegator.new(base)
+
+ delegator.eql?(delegator).should be_true
+ end
+
+ it "returns true when compared with the inner object" do
+ base = mock('base')
+ delegator = DelegateSpecs::Delegator.new(base)
+
+ delegator.eql?(base).should be_true
+ end
+
+ it "returns false when compared with the delegator with other object" do
+ base = mock('base')
+ other = mock('other')
+ delegator0 = DelegateSpecs::Delegator.new(base)
+ delegator1 = DelegateSpecs::Delegator.new(other)
+
+ delegator0.eql?(delegator1).should be_false
+ end
+
+ it "returns false when compared with the other object" do
+ base = mock('base')
+ other = mock('other')
+ delegator = DelegateSpecs::Delegator.new(base)
+
+ delegator.eql?(other).should be_false
+ end
+ end
+end
diff --git a/spec/ruby/library/delegate/delegator/equal_spec.rb b/spec/ruby/library/delegate/delegator/equal_spec.rb
new file mode 100644
index 0000000000..9333d6a303
--- /dev/null
+++ b/spec/ruby/library/delegate/delegator/equal_spec.rb
@@ -0,0 +1,13 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe "Delegator#equal?" do
+ it "returns true only when compared with the delegator" do
+ obj = mock('base')
+ delegator = DelegateSpecs::Delegator.new(obj)
+ obj.should_not_receive(:equal?)
+ delegator.equal?(obj).should be_false
+ delegator.equal?(nil).should be_false
+ delegator.equal?(delegator).should be_true
+ end
+end
diff --git a/spec/ruby/library/delegate/delegator/equal_value_spec.rb b/spec/ruby/library/delegate/delegator/equal_value_spec.rb
new file mode 100644
index 0000000000..7c965d77d3
--- /dev/null
+++ b/spec/ruby/library/delegate/delegator/equal_value_spec.rb
@@ -0,0 +1,24 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe "Delegator#==" do
+ before :all do
+ @base = mock('base')
+ @delegator = DelegateSpecs::Delegator.new(@base)
+ end
+
+ it "is not delegated when passed self" do
+ @base.should_not_receive(:==)
+ (@delegator == @delegator).should be_true
+ end
+
+ it "is delegated when passed the delegated object" do
+ @base.should_receive(:==).and_return(false)
+ (@delegator == @base).should be_false
+ end
+
+ it "is delegated in general" do
+ @base.should_receive(:==).and_return(true)
+ (@delegator == 42).should be_true
+ end
+end
diff --git a/spec/ruby/library/delegate/delegator/frozen_spec.rb b/spec/ruby/library/delegate/delegator/frozen_spec.rb
new file mode 100644
index 0000000000..1fb561a349
--- /dev/null
+++ b/spec/ruby/library/delegate/delegator/frozen_spec.rb
@@ -0,0 +1,39 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe "Delegator when frozen" do
+ before :all do
+ @array = [42, :hello]
+ @delegate = DelegateSpecs::Delegator.new(@array)
+ @delegate.freeze
+ end
+
+ it "is still readable" do
+ @delegate.should == [42, :hello]
+ @delegate.include?("bar").should be_false
+ end
+
+ it "is frozen" do
+ @delegate.frozen?.should be_true
+ end
+
+ it "is not writeable" do
+ lambda{ @delegate[0] += 2 }.should raise_error( RuntimeError )
+ end
+
+ it "creates a frozen clone" do
+ @delegate.clone.frozen?.should be_true
+ end
+
+ it "creates an unfrozen dup" do
+ @delegate.dup.frozen?.should be_false
+ end
+
+ it "causes mutative calls to raise RuntimeError" do
+ lambda{ @delegate.__setobj__("hola!") }.should raise_error( RuntimeError )
+ end
+
+ it "returns false if only the delegated object is frozen" do
+ DelegateSpecs::Delegator.new([1,2,3].freeze).frozen?.should be_false
+ end
+end
diff --git a/spec/ruby/library/delegate/delegator/hash_spec.rb b/spec/ruby/library/delegate/delegator/hash_spec.rb
new file mode 100644
index 0000000000..3719d1b249
--- /dev/null
+++ b/spec/ruby/library/delegate/delegator/hash_spec.rb
@@ -0,0 +1,11 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe "Delegator#hash" do
+ it "is delegated" do
+ base = mock('base')
+ delegator = DelegateSpecs::Delegator.new(base)
+ base.should_receive(:hash).and_return(42)
+ delegator.hash.should == 42
+ end
+end
diff --git a/spec/ruby/library/delegate/delegator/marshal_spec.rb b/spec/ruby/library/delegate/delegator/marshal_spec.rb
new file mode 100644
index 0000000000..5af32b5754
--- /dev/null
+++ b/spec/ruby/library/delegate/delegator/marshal_spec.rb
@@ -0,0 +1,21 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'delegate'
+
+describe "SimpleDelegator" do
+ before :all do
+ @obj = "hello"
+ @delegate = SimpleDelegator.new(@obj)
+ end
+
+ it "can be marshalled" do
+ m = Marshal.load(Marshal.dump(@delegate))
+ m.class.should == SimpleDelegator
+ (m == @obj).should be_true
+ end
+
+ it "can be marshalled with its instance variables intact" do
+ @delegate.instance_variable_set(:@foo, "bar")
+ m = Marshal.load(Marshal.dump(@delegate))
+ m.instance_variable_get(:@foo).should == "bar"
+ end
+end
diff --git a/spec/ruby/library/delegate/delegator/method_spec.rb b/spec/ruby/library/delegate/delegator/method_spec.rb
new file mode 100644
index 0000000000..1760eda645
--- /dev/null
+++ b/spec/ruby/library/delegate/delegator/method_spec.rb
@@ -0,0 +1,69 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe "Delegator#method" do
+ before :each do
+ @simple = DelegateSpecs::Simple.new
+ @delegate = DelegateSpecs::Delegator.new(@simple)
+ end
+
+ it "returns a method object for public methods of the delegate object" do
+ m = @delegate.method(:pub)
+ m.should be_an_instance_of(Method)
+ m.call.should == :foo
+ end
+
+ it "raises a NameError for protected methods of the delegate object" do
+ lambda {
+ -> {
+ @delegate.method(:prot)
+ }.should complain(/delegator does not forward private method #prot/)
+ }.should raise_error(NameError)
+ end
+
+ it "raises a NameError for a private methods of the delegate object" do
+ lambda {
+ -> {
+ @delegate.method(:priv)
+ }.should complain(/delegator does not forward private method #priv/)
+ }.should raise_error(NameError)
+ end
+
+ it "returns a method object for public methods of the Delegator class" do
+ m = @delegate.method(:extra)
+ m.should be_an_instance_of(Method)
+ m.call.should == :cheese
+ end
+
+ it "returns a method object for protected methods of the Delegator class" do
+ m = @delegate.method(:extra_protected)
+ m.should be_an_instance_of(Method)
+ m.call.should == :baz
+ end
+
+ it "returns a method object for private methods of the Delegator class" do
+ m = @delegate.method(:extra_private)
+ m.should be_an_instance_of(Method)
+ m.call.should == :bar
+ end
+
+ it "raises a NameError for an invalid method name" do
+ lambda {
+ @delegate.method(:invalid_and_silly_method_name)
+ }.should raise_error(NameError)
+ end
+
+ it "returns a method that respond_to_missing?" do
+ m = @delegate.method(:pub_too)
+ m.should be_an_instance_of(Method)
+ m.call.should == :pub_too
+ end
+
+ it "raises a NameError if method is no longer valid because object has changed" do
+ m = @delegate.method(:pub)
+ @delegate.__setobj__([1,2,3])
+ lambda {
+ m.call
+ }.should raise_error(NameError)
+ end
+end
diff --git a/spec/ruby/library/delegate/delegator/methods_spec.rb b/spec/ruby/library/delegate/delegator/methods_spec.rb
new file mode 100644
index 0000000000..91a6d68bfa
--- /dev/null
+++ b/spec/ruby/library/delegate/delegator/methods_spec.rb
@@ -0,0 +1,37 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe "Delegator#methods" do
+ before :all do
+ @simple = DelegateSpecs::Simple.new
+ class << @simple
+ def singleton_method
+ end
+ end
+
+ @delegate = DelegateSpecs::Delegator.new(@simple)
+ @methods = @delegate.methods
+ end
+
+ it "returns singleton methods when passed false" do
+ @delegate.methods(false).should include(:singleton_method)
+ end
+
+ it "includes all public methods of the delegate object" do
+ @methods.should include :pub
+ end
+
+ it "includes all protected methods of the delegate object" do
+ @methods.should include :prot
+ end
+
+ it "includes instance methods of the Delegator class" do
+ @methods.should include :extra
+ @methods.should include :extra_protected
+ end
+
+ it "does not include private methods" do
+ @methods.should_not include :priv
+ @methods.should_not include :extra_private
+ end
+end
diff --git a/spec/ruby/library/delegate/delegator/not_equal_spec.rb b/spec/ruby/library/delegate/delegator/not_equal_spec.rb
new file mode 100644
index 0000000000..c2f91dcfa1
--- /dev/null
+++ b/spec/ruby/library/delegate/delegator/not_equal_spec.rb
@@ -0,0 +1,24 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe "Delegator#!=" do
+ before :all do
+ @base = mock('base')
+ @delegator = DelegateSpecs::Delegator.new(@base)
+ end
+
+ it "is not delegated when passed self" do
+ @base.should_not_receive(:"!=")
+ (@delegator != @delegator).should be_false
+ end
+
+ it "is delegated when passed the delegated object" do
+ @base.should_receive(:"!=").and_return(true)
+ (@delegator != @base).should be_true
+ end
+
+ it "is delegated in general" do
+ @base.should_receive(:"!=").and_return(false)
+ (@delegator != 42).should be_false
+ end
+end
diff --git a/spec/ruby/library/delegate/delegator/not_spec.rb b/spec/ruby/library/delegate/delegator/not_spec.rb
new file mode 100644
index 0000000000..678e07e418
--- /dev/null
+++ b/spec/ruby/library/delegate/delegator/not_spec.rb
@@ -0,0 +1,11 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe "Delegator#!" do
+ it "is delegated" do
+ base = mock('base')
+ delegator = DelegateSpecs::Delegator.new(base)
+ base.should_receive(:"!").and_return(:foo)
+ (!delegator).should == :foo
+ end
+end
diff --git a/spec/ruby/library/delegate/delegator/private_methods_spec.rb b/spec/ruby/library/delegate/delegator/private_methods_spec.rb
new file mode 100644
index 0000000000..557da9bd02
--- /dev/null
+++ b/spec/ruby/library/delegate/delegator/private_methods_spec.rb
@@ -0,0 +1,20 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe "Delegator#private_methods" do
+ before :all do
+ @simple = DelegateSpecs::Simple.new
+ @delegate = DelegateSpecs::Delegator.new(@simple)
+ @methods = @delegate.private_methods
+ end
+
+ it "does not include any method of the delegate object" do # since delegates does not forward private calls
+ @methods.should_not include :priv
+ @methods.should_not include :prot
+ @methods.should_not include :pub
+ end
+
+ it "includes all private instance methods of the Delegate class" do
+ @methods.should include :extra_private
+ end
+end
diff --git a/spec/ruby/library/delegate/delegator/protected_methods_spec.rb b/spec/ruby/library/delegate/delegator/protected_methods_spec.rb
new file mode 100644
index 0000000000..5f03575f25
--- /dev/null
+++ b/spec/ruby/library/delegate/delegator/protected_methods_spec.rb
@@ -0,0 +1,18 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe "Delegator#protected_methods" do
+ before :all do
+ @simple = DelegateSpecs::Simple.new
+ @delegate = DelegateSpecs::Delegator.new(@simple)
+ @methods = @delegate.protected_methods
+ end
+
+ it "includes protected methods of the delegate object" do
+ @methods.should include :prot
+ end
+
+ it "includes protected instance methods of the Delegator class" do
+ @methods.should include :extra_protected
+ end
+end
diff --git a/spec/ruby/library/delegate/delegator/public_methods_spec.rb b/spec/ruby/library/delegate/delegator/public_methods_spec.rb
new file mode 100644
index 0000000000..4ed626be33
--- /dev/null
+++ b/spec/ruby/library/delegate/delegator/public_methods_spec.rb
@@ -0,0 +1,18 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe "Delegator#public_methods" do
+ before :all do
+ @simple = DelegateSpecs::Simple.new
+ @delegate = DelegateSpecs::Delegator.new(@simple)
+ @methods = @delegate.public_methods
+ end
+
+ it "includes public methods of the delegate object" do
+ @methods.should include :pub
+ end
+
+ it "includes public instance methods of the Delegator class" do
+ @methods.should include :extra
+ end
+end
diff --git a/spec/ruby/library/delegate/delegator/send_spec.rb b/spec/ruby/library/delegate/delegator/send_spec.rb
new file mode 100644
index 0000000000..b6e66cb74a
--- /dev/null
+++ b/spec/ruby/library/delegate/delegator/send_spec.rb
@@ -0,0 +1,26 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe "SimpleDelegator.new" do
+ before :all do
+ @simple = DelegateSpecs::Simple.new
+ @delegate = SimpleDelegator.new(@simple)
+ end
+
+ it "forwards public method calls" do
+ @delegate.pub.should == :foo
+ end
+
+ it "forwards protected method calls" do
+ lambda{ @delegate.prot }.should raise_error( NoMethodError )
+ end
+
+ it "doesn't forward private method calls" do
+ lambda{ @delegate.priv }.should raise_error( NoMethodError )
+ end
+
+ it "doesn't forward private method calls even via send or __send__" do
+ lambda{ @delegate.send(:priv, 42) }.should raise_error( NoMethodError )
+ lambda{ @delegate.__send__(:priv, 42) }.should raise_error( NoMethodError )
+ end
+end
diff --git a/spec/ruby/library/delegate/delegator/taint_spec.rb b/spec/ruby/library/delegate/delegator/taint_spec.rb
new file mode 100644
index 0000000000..f78446d018
--- /dev/null
+++ b/spec/ruby/library/delegate/delegator/taint_spec.rb
@@ -0,0 +1,23 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe "Delegator#taint" do
+ before :each do
+ @delegate = DelegateSpecs::Delegator.new("")
+ end
+
+ it "returns self" do
+ @delegate.taint.equal?(@delegate).should be_true
+ end
+
+ it "taints the delegator" do
+ @delegate.__setobj__(nil)
+ @delegate.taint
+ @delegate.tainted?.should be_true
+ end
+
+ it "taints the delegated object" do
+ @delegate.taint
+ @delegate.__getobj__.tainted?.should be_true
+ end
+end
diff --git a/spec/ruby/library/delegate/delegator/tap_spec.rb b/spec/ruby/library/delegate/delegator/tap_spec.rb
new file mode 100644
index 0000000000..1da6d82b01
--- /dev/null
+++ b/spec/ruby/library/delegate/delegator/tap_spec.rb
@@ -0,0 +1,16 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe "Delegator#tap" do
+ it "yield the delegator object" do
+ obj = mock('base')
+ delegator = DelegateSpecs::Delegator.new(obj)
+ obj.should_not_receive(:tap)
+ yielded = []
+ delegator.tap do |x|
+ yielded << x
+ end
+ yielded.size.should == 1
+ yielded[0].equal?(delegator).should be_true
+ end
+end
diff --git a/spec/ruby/library/delegate/delegator/trust_spec.rb b/spec/ruby/library/delegate/delegator/trust_spec.rb
new file mode 100644
index 0000000000..182395c26e
--- /dev/null
+++ b/spec/ruby/library/delegate/delegator/trust_spec.rb
@@ -0,0 +1,22 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe "Delegator#trust" do
+ before :each do
+ @delegate = DelegateSpecs::Delegator.new([])
+ end
+
+ it "returns self" do
+ @delegate.trust.equal?(@delegate).should be_true
+ end
+
+ it "trusts the delegator" do
+ @delegate.trust
+ @delegate.untrusted?.should be_false
+ end
+
+ it "trusts the delegated object" do
+ @delegate.trust
+ @delegate.__getobj__.untrusted?.should be_false
+ end
+end
diff --git a/spec/ruby/library/delegate/delegator/untaint_spec.rb b/spec/ruby/library/delegate/delegator/untaint_spec.rb
new file mode 100644
index 0000000000..2cce99e206
--- /dev/null
+++ b/spec/ruby/library/delegate/delegator/untaint_spec.rb
@@ -0,0 +1,24 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe "Delegator#untaint" do
+ before :each do
+ @delegate = lambda { DelegateSpecs::Delegator.new("") }.call
+ end
+
+ it "returns self" do
+ @delegate.untaint.equal?(@delegate).should be_true
+ end
+
+ it "untaints the delegator" do
+ @delegate.untaint
+ @delegate.tainted?.should be_false
+ # No additional meaningful test; that it does or not taint
+ # "for real" the delegator has no consequence
+ end
+
+ it "untaints the delegated object" do
+ @delegate.untaint
+ @delegate.__getobj__.tainted?.should be_false
+ end
+end
diff --git a/spec/ruby/library/delegate/delegator/untrust_spec.rb b/spec/ruby/library/delegate/delegator/untrust_spec.rb
new file mode 100644
index 0000000000..e2bbf1b294
--- /dev/null
+++ b/spec/ruby/library/delegate/delegator/untrust_spec.rb
@@ -0,0 +1,23 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/classes', __FILE__)
+
+describe "Delegator#untrust" do
+ before :each do
+ @delegate = DelegateSpecs::Delegator.new("")
+ end
+
+ it "returns self" do
+ @delegate.untrust.equal?(@delegate).should be_true
+ end
+
+ it "untrusts the delegator" do
+ @delegate.__setobj__(nil)
+ @delegate.untrust
+ @delegate.untrusted?.should be_true
+ end
+
+ it "untrusts the delegated object" do
+ @delegate.untrust
+ @delegate.__getobj__.untrusted?.should be_true
+ end
+end