2012-07-26 19:25:23 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2012-08-10 20:23:39 +02:00
|
|
|
describe Mutant::Context::Constant, '#root' do
|
|
|
|
subject { object.root(node) }
|
2012-07-26 19:25:23 +02:00
|
|
|
|
2012-08-14 12:26:56 +02:00
|
|
|
let(:object) { described_class.build(path, TestApp::Literal) }
|
|
|
|
let(:path) { mock('Path') }
|
|
|
|
let(:node) { mock('Node') }
|
2012-07-26 19:25:23 +02:00
|
|
|
|
2012-08-10 20:23:39 +02:00
|
|
|
let(:constant) { subject.body }
|
|
|
|
let(:scope) { constant.body }
|
|
|
|
let(:scope_body) { scope.body }
|
2012-07-26 19:25:23 +02:00
|
|
|
|
2012-08-10 20:23:39 +02:00
|
|
|
it { should be_a(Rubinius::AST::Script) }
|
2012-08-14 12:26:56 +02:00
|
|
|
its(:file) { should be(path) }
|
2012-07-26 19:25:23 +02:00
|
|
|
|
2012-08-10 20:23:39 +02:00
|
|
|
it 'should wrap the ast under constant' do
|
2012-08-14 12:26:56 +02:00
|
|
|
scope.should be_kind_of(Rubinius::AST::ClassScope)
|
2012-08-10 20:23:39 +02:00
|
|
|
end
|
2012-07-26 19:25:23 +02:00
|
|
|
|
2012-08-10 20:44:45 +02:00
|
|
|
it 'should place the ast under scope inside of block' do
|
|
|
|
scope_body.should be_a(Rubinius::AST::Block)
|
|
|
|
scope_body.array.should eql([node])
|
|
|
|
scope_body.array.first.should be(node)
|
2012-07-26 19:25:23 +02:00
|
|
|
end
|
|
|
|
end
|