Home
subscribe

L'etat, c'est moi

Mere Complexities sells the consulting and development services of me, Paul Wilson.

Conferences

Organising Scotland on Rails
Speaker, RailsConf Europe '08

Archive

Domain Specific Languages - Jmock afterthought

Jmock uses functions with side-effects to build complex expressions. The following tells the mockSingleCustomerCreatorFactory to expect the method create to be called once with the parameters “mendel” and 28; it should return the mockCustomer object:


mockSingleCustomerCreatorFactory.expects(once()).method(“create”)
.with(eq(“mendel”), eq(28)).will(returnValue(mockCustomer));

This provides a DSL, although the limitations of the form make the syntax somewhat awkward. Here is a similar approach used to construct HTML.

All