Add specs for Mutant::Subject::Method::Singletion#public?

This commit is contained in:
Markus Schirp 2014-08-08 16:42:12 +00:00
parent 48138d0b6e
commit 6b4faeeab8

View file

@ -6,25 +6,21 @@ describe Mutant::Subject::Method::Singleton do
let(:object) { described_class.new(config, context, node) }
let(:config) { Mutant::Config::DEFAULT }
let(:context) { double }
let(:node) { s(:defs, s(:self), :foo, s(:args)) }
let(:node) do
s(:defs, s(:self), :foo, s(:args))
let(:context) do
Mutant::Context::Scope.new(scope, double('Source Path'))
end
let(:scope) do
Class.new do
def self.foo
end
end
end
describe '#prepare' do
let(:context) do
Mutant::Context::Scope.new(scope, double('Source Path'))
end
let(:scope) do
Class.new do
def self.foo
end
end
end
subject { object.prepare }
it 'undefines method on scope' do
@ -39,4 +35,32 @@ describe Mutant::Subject::Method::Singleton do
it { should eql("def self.foo\nend") }
end
describe '#public?' do
subject { object.public? }
context 'when method is public' do
it { should be(true) }
end
context 'when method is private' do
before do
scope.class_eval do
private_class_method :foo
end
end
it { should be(false) }
end
context 'when method is protected' do
before do
class << scope
protected :foo
end
end
it { should be(false) }
end
end
end