add spec for pattern function