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
,type
parameter exist when creating a new object ofPost
class. How can I do itpost_test
class? - Is this
test
method are checking the presence ofname
inpost
? - How can I test
check_Validation
throughPostTest
class? - How to check throw error if
posts
is 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