我正在使用minitest
框架,除了create
类
controller
方法的测试用例外,所有测试用例都运行正常
def setup
@user = users(:pal)
@post = posts(:one)
end
test 'should create a new one' do
sign_in @user
assert_difference 'Post.count' do
post :create, post: { name: @post.name, data: @post.data, user_id: @user.id}
end
assert_redirected_to post_path(assigns(:post))
end
.yml
文件用于用户和帖子的位置
Amit:
email: test1p@gmail.com
encrypted_password: <%= BCrypt::Password.create('render') %>
pal:
email: test2@gmail.com
encrypted_password: <%= BCrypt::Password.create('render') %>
one:
id: 1
name: 'test'
data: 3
two:
id: 2
name: 'value'
data: 3
在运行此测试用例时,我正在
"Post.count" didn't change by 1.
Expected: 2
Actual: 1
我在这里做错了什么?