Sha256: ee1e0a3a80015423c7cdcaa29d1b6bf69935df91dd2c6e83c91feb494a1a3ed0
Contents?: true
Size: 1.53 KB
Versions: 2
Compression:
Stored size: 1.53 KB
Contents
require 'spec_helper' module Qrb describe Syntax, "contract" do subject{ Syntax.parse(input, root: "contract") } let(:contract){ compiled.values.first } context 'No converter and a class' do let(:input){ '<rgb> {r: .Integer, g: .Integer, b: .Integer}' } let(:compiled){ subject.compile(type_factory, Color) } it 'compiles to the expected Hash' do compiled.should be_a(Hash) compiled.keys.should eq([:rgb]) contract.should be_a(Array) contract.first.should be_a(TupleType) contract.last.should be_a(Method) end end context 'No converter and no class' do let(:input){ '<rgb> {r: .Integer, g: .Integer, b: .Integer}' } let(:compiled){ subject.compile(type_factory, nil) } it 'compiles to the expected Hash' do compiled.should be_a(Hash) compiled.keys.should eq([:rgb]) contract.should be_a(Array) contract.first.should be_a(TupleType) contract.last.should be(Qrb::IDENTITY) end end context 'A contract with explicit converters' do let(:input){ '<iso> .String \( s | DateTime.parse(s) ) \( d | d.to_s )' } let(:compiled){ subject.compile(type_factory, nil) } it 'compiles to the expected Hash' do compiled.should be_a(Hash) compiled.keys.should eq([:iso]) contract.should be_a(Array) contract.first.should be_a(BuiltinType) contract.last.should be_a(Proc) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
qrb-0.2.0 | spec/unit/syntax/nodes/test_contract.rb |
qrb-0.1.0 | spec/unit/syntax/nodes/test_contract.rb |