Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在创建一个 Rails 插件,它正在动态地向 Helper 添加一个方法。我只想确保添加了该方法。如何查看 Helper 是否响应方法名称?
试试这个:
def test_that_foo_helper_defines_bar o = Object.new assert !o.respond_to? :bar o.extend FooHelper assert o.respond_to? :bar end