正在看 restful rail development 这本书,按照书上写的测试报错了,大佬帮我看看

2018-12-16 20:43:49 +08:00
 Caojx
rails 版本 5.2.2
require 'test_helper'

class SayControllerTest < ActionDispatch::IntegrationTest
test "should get hello" do
get say_hello_url
assert_response :success
end
test "should say hello in json" do
get say_hello_url
assert_equal "{\"hello\":\"Rails!\"}", @response.body
end
test "should say hello in json" do
get say_hello_url,{'user'=>"Join"}
assert_equal "{\"hello\":\"Join!\"}", @response.body
end
end
16919 次点击
所在节点    Ruby on Rails
3 条回复
Caojx
2018-12-16 20:45:34 +08:00
第三条测试,我传参不对
Caojx
2018-12-16 20:58:16 +08:00
这是报错
✘ caojianxiong@MacBook-Air  ~/Ruby/hello_rails   master  rake test
/Users/caojianxiong/Ruby/hello_rails/db/schema.rb doesn't exist yet. Run `rails db:migrate` to create it, then try again. If you do not intend to use a database, you should instead alter /Users/caojianxiong/Ruby/hello_rails/config/application.rb to limit the frameworks that will be loaded.
rake aborted!
test_should_say_hello_in_json is already defined in SayControllerTest
/Users/caojianxiong/Ruby/hello_rails/test/controllers/say_controller_test.rb:12:in `<class:SayControllerTest>'
/Users/caojianxiong/Ruby/hello_rails/test/controllers/say_controller_test.rb:3:in `<top (required)>'
Tasks: TOP => test
(See full trace by running task with --trace)
zhaolion
2018-12-16 21:09:25 +08:00
先配置一下 config/database.yaml,然后执行 `rails db:migrate`

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/518075

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX