I\'m writing some tests for my view helper (Rails 4.0) and trying to compile ERB code in a string that executes it. However, for the sake of simplicity, I am using a common
“Normal” Eruby doesn’t allow for expressions using <%=
to have blocks the way Rails uses them. Rails extends the Erubis Eruby handler to add support for them. Your test is just tring to use Erb directly, so this support isn’t available.
You need to make sure this support is loaded for this to work. I can get get it working with this:
ActionView::Template::Handlers::Erubis.new(template).evaluate(ActionView::Base.new)
I don’t know if this is the best way though. Check the RSpec docs, there may be a better way for testing parts of views like this.