2012-07-26 13:25:23 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2012-08-15 22:10:54 -04:00
|
|
|
describe Mutant::Context::Scope, '#root' do
|
2012-08-10 14:23:39 -04:00
|
|
|
subject { object.root(node) }
|
2012-07-26 13:25:23 -04:00
|
|
|
|
2012-12-12 16:11:35 -05:00
|
|
|
let(:object) { described_class.new(TestApp::Literal, path) }
|
2013-07-14 13:01:30 -04:00
|
|
|
let(:path) { double('Path') }
|
2013-06-25 03:37:45 -04:00
|
|
|
let(:node) { parse(':node') }
|
2012-07-26 13:25:23 -04:00
|
|
|
|
2012-11-21 14:31:01 -05:00
|
|
|
let(:scope) { subject.body }
|
2013-06-25 03:37:45 -04:00
|
|
|
let(:scope_body) { scope.body }
|
2012-07-26 13:25:23 -04:00
|
|
|
|
2012-12-12 16:11:35 -05:00
|
|
|
let(:expected_source) do
|
2013-06-04 13:22:33 -04:00
|
|
|
generate(parse(<<-RUBY))
|
2012-12-12 16:11:35 -05:00
|
|
|
module TestApp
|
|
|
|
class Literal
|
|
|
|
:node
|
|
|
|
end
|
|
|
|
end
|
|
|
|
RUBY
|
2012-08-10 14:23:39 -04:00
|
|
|
end
|
2012-07-26 13:25:23 -04:00
|
|
|
|
2012-12-12 16:11:35 -05:00
|
|
|
let(:generated_source) do
|
2013-06-04 13:22:33 -04:00
|
|
|
Unparser.unparse(subject)
|
2012-12-12 16:11:35 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
let(:round_tripped_source) do
|
2013-06-04 13:22:33 -04:00
|
|
|
Unparser.unparse(parse(expected_source))
|
2012-12-12 16:11:35 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should create correct source' do
|
|
|
|
generated_source.should eql(expected_source)
|
2012-07-26 13:25:23 -04:00
|
|
|
end
|
|
|
|
end
|