How do I test that a Rails Helper defines a method?
-
01-07-2019 - |
Question
I am creating a Rails plugin and it is dynamically adding a method to a Helper. I just want to ensure that the method is added. How can I see if the Helper responds to the method name?
Solution
Try this:
def test_that_foo_helper_defines_bar
o = Object.new
assert !o.respond_to? :bar
o.extend FooHelper
assert o.respond_to? :bar
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow