Suppose we have a custom FormBuilder in Padrino, like the following:
class CustomFormBuilder < Padrino::Helpers::FormBuilder::AbstractFormBuilder
def foo(arg1, arg2, ...)
# do something with #template
end
end
What's the right way to test this?
It seems like the correct thing to do would be something like:
describe CustomFormBuilder do
it "renders the right output"
# ...
result = CustomFormBuilder.new(...).template.render
expect(result).to include 'expected-content'
end
end
It's not clear to me how to pull that off:
- Usually the framework instantiates the FormBuilders, so it feels wrong that I'm doing it here. Is there a better approach?
- I don't know how to pass an object that the FormBuilder will accept as a template.
- I don't know how to get the result of rendering the template.
What's the right way to test this?