How to verify that the Rails Helper defines a method?

I am creating a Rails plugin and dynamically adding a helper method. I just want this method to be added. How can I see if the helper responds to a method name?

+3
source share
1 answer

Try the following:

def test_that_foo_helper_defines_bar
  o = Object.new
  assert !o.respond_to? :bar
  o.extend FooHelper
  assert o.respond_to? :bar
end
+5
source

Source: https://habr.com/ru/post/1697272/


All Articles