Where to put test class for "normal" Ruby classes in Rails? -


i have created module in lib directory (it seems place put it). has 1 method useful many of model classes.

i want unit test it. when try put test in model folder in test fails:

minitest::unexpectederror: nomethoderror: undefined method `type' nil:nilclass 

so wrong. should test be, , should inherit etc work?

your tests follow same folder structure. if have:

app ├── controllers ├── models 

your tests directory be:

spec ├── controllers │   └── some_controller_spec.rb ├── models │   ├── some_model_spec.rb ├── rails_helper.rb └── spec_helper.rb 

in instance, if have lib folder, you'd add lib folder spec/test directory.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -