The interesting method is capture_haml, which does the same as Rails builtin capture but for HAML. haml_tag/puts methods write output directly to the buffer and does not return the generated content as a String, thus we cannot just test on the method output.