1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
describe Morpher do
let(:object) { described_class }
describe '.sexp' do
subject { object.sexp(&block) }
context 'with no block given' do
let(:block) { nil }
it 'raises an exception' do
expect { subject }.to raise_error(ArgumentError)
end
end
context 'with block given' do
let(:block) do
proc do
s(:foo)
s(:bar)
end
end
it 'allows to use sexp dsl and returns last value' do
should == AST::Node.new(:bar)
end
end
end
describe '.build' do
subject { object.build(&block) }
context 'with no block given' do
let(:block) { nil }
it 'raises an exception' do
expect { subject }.to raise_error(ArgumentError)
end
end
context 'with block given' do
let(:block) do
proc do
s(:foo)
s(:true)
end
end
it 'allows to use sexp dsl and returns last value compiled' do
should eql(Morpher.compile(s(:true)))
end
end
end
end
|