Skip to content
This repository has been archived by the owner on Oct 27, 2021. It is now read-only.

Commit

Permalink
Moved specs around, little bit of cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Pat Maddox committed May 22, 2008
1 parent de3f6cd commit 7af69e3
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 35 deletions.
35 changes: 0 additions & 35 deletions examples/pure/partial_mock_example.rb
Expand Up @@ -4,20 +4,6 @@ class MockableClass
def self.find id
return :original_return
end

def public_method
private_method
protected_method
end

protected

def protected_method; end

private

def private_method; end

end

describe "A partial mock" do
Expand All @@ -40,25 +26,4 @@ def private_method; end
MockableClass.msg_3
end

it 'should make public proxies for public methods' do
object = MockableClass.new
object.should_receive(:public_method)
object.public_methods.include?('public_method').should == true
object.public_method
end

it 'should make private proxies for private methods' do
object = MockableClass.new
object.should_receive(:private_method)
object.private_methods.include?('private_method').should == true
object.public_method
end

it 'should make protected proxies for protected methods' do
object = MockableClass.new
object.should_receive(:protected_method)
object.protected_methods.include?('protected_method').should == true
object.public_method
end

end
36 changes: 36 additions & 0 deletions spec/spec/mocks/partial_mock_spec.rb
Expand Up @@ -102,5 +102,41 @@ def ==(other)
lambda { o.stub!(:bar) }.should_not raise_error(NoMethodError)
end
end

describe "Method visibility when using partial mocks" do
class MockableClass
def public_method
private_method
protected_method
end
protected
def protected_method; end
private
def private_method; end
end

before(:each) do
@object = MockableClass.new
end

it 'should keep public methods public' do
@object.should_receive(:public_method)
@object.public_methods.should include('public_method')
@object.public_method
end

it 'should keep private methods private' do
@object.should_receive(:private_method)
@object.private_methods.should include('private_method')
@object.public_method
end

it 'should keep protected methods protected' do
@object.should_receive(:protected_method)
@object.protected_methods.should include('protected_method')
@object.public_method
end

end
end
end

0 comments on commit 7af69e3

Please sign in to comment.