这是我的测试,类似于Hartl教程中的邮件测试:
test "valid signup information with account activation" do
get new_user_path
assert_difference 'User.count', 1 do
post users_path, user: { username: "Jwan622",
first_name: "Jeffrey",
last_name: "Wan",
email: "Jwan622@yahoo.com",
password: "password",
password_confirmation: "password",
city: "New York City",
state: "New York",
country: "United States"
}
end
assert_equal 1, ActionMailer::Base.deliveries.size
user = assigns(:user)
assert_not user.activated?
log_in_as(user)
assert_not is_logged_in?
# Invalid activation token
get edit_account_activation_path("invalid token")
assert_not is_logged_in?
# Valid token, wrong email
get edit_account_activation_path(user.activation_token, email: 'wrong')
assert_not is_logged_in?
# Valid activation token
get edit_account_activation_path(user.activation_token, email: user.email)
assert user.reload.activated?
follow_redirect!
assert_template 'root_path'
assert is_logged_in?
end
这是我的错误消息:
1) Failure:
UserSignupTest#test_valid_signup_information_with_account_activation [/Users/Jwan/Dropbox/Turing/projects/FlyAwayFromHere/test/integration/user_signup_test.rb:94]:
expecting <"root_path"> but rendering with <["layouts/_praise_bar", "layouts/_city_change", "planners/new", "layouts/_nav_bar", "layouts/_footer_bar", "layouts/application"]>
问题:
1)什么样的测试是assert_template?它是最小的吗?水豚?
2)得到什么样的方法?它是一种在轨道上工作的机架方法吗?
3)&#34;分配什么&#34;怎么办?
4)我对assert_template做错了什么?
答案 0 :(得分:1)
将其更改为assert_template :new
以使其正常工作;这是测试new.html.erb
已呈现。
有关assert_template
和一般测试视图的详情,请参阅http://guides.rubyonrails.org/testing.html#testing-templates-and-layouts。