Domanda

Sto creando un plug-in Rails e sta aggiungendo dinamicamente un metodo a un Helper. Voglio solo assicurarmi che il metodo sia aggiunto. Come posso vedere se l'helper risponde al nome del metodo?

È stato utile?

Soluzione

Prova questo:

def test_that_foo_helper_defines_bar
  o = Object.new
  assert !o.respond_to? :bar
  o.extend FooHelper
  assert o.respond_to? :bar
end
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top