我正在尝试对示例应用程序运行rake测试,我有一个错误,我似乎无法转移。
`ERROR["test_invalid_signup_information", UsersSignupTest, 0.717775303] test_invalid_signup_information#UsersSignupTest (0.72s)ArgumentError: ArgumentError: unknown command 'v' test/integration/users_signup_test.rb:15:in `test' test/integration/users_signup_test.rb:15:in `block in <class:UsersSignupTest>' test/integration/users_signup_test.rb:15:in `test' test/integration/users_signup_test.rb:15:in `block in <class:UsersSignupTest>'
16/16: [=] 100% Time: 00:00:00, Time: 00:00:00
Finished in 0.72207s
16 tests, 34 assertions, 0 failures, 1 errors, 0 skips1
它似乎指向我在下面粘贴的users_signup页面。
`require 'test_helper'
class UsersSignupTest < ActionDispatch::IntegrationTest
test "invalid signup information" do
get signup_path
assert_no_difference 'User.count' do
post users_path, user: { name: "",
email: "user@invalid",
password: "foo",
password_confirmation: "bar" }
end
assert_template 'users/new'
test "valid signup information" do
get signup_path
name = "Example User"
email = "user@example.com"
password = "password"
assert_difference 'User.count', 1 do
post_via_redirect users_path, user: { name: name,
email: email,
password: password,
password_confirmation: password }
end
assert_template 'users/show'
end
end
end
任何人都可以看到错误吗?
答案 0 :(得分:0)
也许是因为你没有关闭第一次测试的控制流结构?缺少end
。
尝试使用以下代码:
require 'test_helper'
class UsersSignupTest < ActionDispatch::IntegrationTest
test "invalid signup information" do
get signup_path
assert_no_difference 'User.count' do
post users_path, user: { name: "",
email: "user@invalid",
password: "foo",
password_confirmation: "bar" }
end
assert_template 'users/new'
end
test "valid signup information" do
get signup_path
name = "Example User"
email = "user@example.com"
password = "password"
assert_difference 'User.count', 1 do
post_via_redirect users_path, user: { name: name,
email: email,
password: password,
password_confirmation: password }
end
assert_template 'users/show'
end
end