ruby on rails - writing model method tests using minitest -


i use mini-test testing framework. try write model tests.

class person   include mongoid::document    field :provider, type:string   field :user_id, type:string   field :name, type:string    def self.create_with_omniauth(auth)     create! |person|       person.provider = auth["provider"]       person.user_id = auth["uid"]       #user.name = auth["info"]["name"]     end   end    def self.find_by_provider_and_uid(provider, uid)     where(provider: provider, user_id: uid).first   end  end 

above person model. want write test controls if person has "create_with_omniauth method" or not.

how can write test. wait ideas? in advance.

to accomplish can use assert_respond_to.

a complete example:

class persontest < minitest::unit::testcase   def test_responds_to_create_with_omniauth      assert_respond_to(person, :create_with_omniauth)   end end 

my personal opinion test behaviour of method instead of asserting whether exists or not, i'll leave you.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -