首页   注册   登录
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Coding
V2EX  ›  Ruby on Rails

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

  •  
  •   Caojx · 364 天前 · 12694 次点击
    这是一个创建于 364 天前的主题,其中的信息可能已经有所发展或是发生改变。
    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
    3 回复  |  直到 2018-12-16 21:09:25 +08:00
        1
    Caojx   364 天前
    第三条测试,我传参不对
        2
    Caojx   364 天前
    这是报错
    [email protected]  ~/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)
        3
    zhaolion   364 天前   ♥ 1
    先配置一下 config/database.yaml,然后执行 `rails db:migrate`
    关于   ·   FAQ   ·   API   ·   我们的愿景   ·   广告投放   ·   感谢   ·   实用小工具   ·   812 人在线   最高记录 5043   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.3 · 16ms · UTC 22:32 · PVG 06:32 · LAX 14:32 · JFK 17:32
    ♥ Do have faith in what you're doing.