I just want to do unit/test, test to creat person data (here are 3
cloumns) into the table
“people” of model person. and in model person, there is “def
Person.newly_created(args)” method.
In fixtures file, there is
test1:
id: 1
user_id: 1
firstname: test1
lastname: YY
test2:
id: 2
user_id: 2
firstname: test2
lastname: TT
test3:
id: 3
user_id: 3
firstname: test3
lastname: ZZ
I want to use assert_difference to test creat all data into database.
def test_should_create_person
assert_difference Person, :count do
assert=Person.newly_created.valid?
assert is a method, and you are assigning something to it…?
And, yes, assert_latest can help you, because it can do anything
assert_different Model, :count can do, and more. So if you actually need
that, you could use assert_latest.
---------- Forwarded message ----------
From: OnRails [email protected]
Date: Sep 2, 9:35 pm
Subject: about assert_difference problem. help!!
To: Ruby on Rails: Talk
I just want to do unit/test, test to creat person data (here are 3
cloumns) into the table
“people” of model person. and in model person, there is “def
Person.newly_created(args)” method.
In fixtures file, there is
test1:
id: 1
user_id: 1
firstname: test1
lastname: YY
test2:
id: 2
user_id: 2
firstname: test2
lastname: TT
test3:
id: 3
user_id: 3
firstname: test3
lastname: ZZ
I want to use assert_difference to test creat all data into database.
You’ve got some bugs in your syntax that you’ll need to take care of
before you start worrying assert_difference. Read the api for the
method that’s throwing the exception and do some homework.
assert_difference isn’t the issue here…
Also, neither assert=Person nor assert.Person do what you want to do.
I’d suggest reading up on unit tests in Ruby and Rails.
Rein
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.