jeudi 2 juillet 2015

Why minitest case are failing?

MyModel class:

class Post < ActiveRecord::Base
 validates_presence_of :value
 ...
end

my post.yml

one:
  row: 2
  col: 3
  name: 'Test'

MyTest cases

require 'test_helper'
class SimulationsModelTest < ActiveSupport::TestCase

def setup
 @post = Post.new
end

test 'post must have name' do
 @post.name = ' '
 assert @post.valid?
end

end

Why this above test cases are failing? However following test cases are passing

test 'post must have name' do
@post.name = ' '
assert_not @post.valid?

end

In my model I don't have presence => true set for name, Then why first test case are failing?

Aucun commentaire:

Enregistrer un commentaire