I just started to learn testing with minitest but it sounds very confusing to me. What does this statement means?
test 'should not save simulations without name' do
post = Post.new
assert !post.save, 'Saved the simulations without a name'
end
Post Model
class Post < ActiveRecord::Base
validates_presence_of :name , :type
belongs_to :user
before_create :check_validation
validates :type, :inclusion => { :in => 1..10, :message => 'The row must be between 1 and 10' }
private
def check_validation(data, type)
....
end
What would be the minitest method for following conditions:
- check if
name,typeparameter exist when creating a new object ofPostclass. How can I do itpost_testclass? - Is this
testmethod are checking the presence ofnameinpost? - How can I test
check_ValidationthroughPostTestclass? - How to check throw error if
postsis not belong to users?
I have already created post.yml file and user.yml file. How to proceed again. I tried to read ruby official documentation but it is not very helpful.
Thanks in adnvance
Aucun commentaire:
Enregistrer un commentaire