这是我的static_pages_controller_test,
require 'test_helper'
class StaticPagesControllerTest < ActionDispatch::IntegrationTest
test "should get home" do
get static_pages_home_url
assert_response :success
end
test "should get help" do
get static_pages_help_url
assert_response :success
end
test "should get about" do
get static_pages_about_url
assert_response :success
end
end
错误:
StaticPagesControllerTest#test_should_get_home: ActiveRecord :: RecordNotUnique:SQLite3 :: ConstraintException:UNIQUE 约束失败:users.email:INSERT INTO“users”(“created_at”, “updated_at”,“id”)VALUES('2018-01-17 05:49:27.300065','2018-01-17 05:49:27.300065',298486374)
我将user.yml更改为,
one:
email: test1@test.com
two:
email: test2@test.com
错误:
StaticPagesControllerTest#test_should_get_about: ActiveRecord :: Fixture :: FormatError:fixture键不是哈希: C:/Sites/IntenetChatSystem/test/fixtures/users.yml,键:[“one”, “电子邮件”,I'mtwo“]
即时混淆我应该怎么做,pplz给出了一些建议
答案 0 :(得分:0)
必须修复user.yml
文件的缩进:
one:
email: test1@test.com
two:
email: test2@test.com
错误信息本身就是一个很好的提示,“夹具键不是哈希:...键:[”one“,”email“,我是两个”]“你可以在键列表中看到存在one
和email
密钥。您应该只拥有one
和two
密钥。