Including Haml Helpers in an RSpec spec
My current project uses Haml 3.1.2, RSpec 2.6.0, and Rails 3.0.9. We have several helpers that make use of capture_haml and haml_tag and have been lacking tests coverage on those helpers.
Running a spec that referenced a haml helper method was yielding the following:
undefined method `capture_haml' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_2::Nested_1:0x000001064f6d50>
The HamlHelpers need to be included in the RSpec ExampleGroup, ideally for each Helper Spec. spec/spech_helper.rb was the place to be but the exact incantation wasn’t readily available from a quick round of Googling. After some deeper digging however, this appears to be the magic: