reifyhealth / specmonstah

Specmonstah will eat the face off your test fixtures
MIT License
359 stars 18 forks source link

How to establish relation between attributes of different ents #49

Closed sushovannits closed 5 years ago

sushovannits commented 5 years ago

Is there any way we can establish relation between two different entities. e.g.: we have two different entities carand wheel. Now every wheel refs to a car. However both car and wheel has a price attribute. The relation I want to establish is: price of wheel w0 which refs car c0 is not greater than c0's price.

Is it possible in specmonstah? I am not sure if insert visitation can be used.

flyingmachine commented 5 years ago

Thanks for question! Not sure when I'll be able to look into it, but hopefully in the next couple weeks :)

flyingmachine commented 5 years ago

There's no way to directly impose this kind of constraint. I do think it'd be possible to write a visitor that could traverse the ents, get to w0 and check its price compared to c0's price. This code shows how you can get referenced ents and their attributes.

flyingmachine commented 5 years ago

PS thanks for the good question!