【问题标题】:Rails generated app without tests, how can i generate rspec test files without recreating project?Rails 生成的应用程序没有测试,如何在不重新创建项目的情况下生成 rspec 测试文件?
【发布时间】:2019-12-31 01:34:39
【问题描述】:

我使用 Rails 为我一直从事的项目生成了无需测试的仅 API 应用程序。是否有任何命令可以在不重新创建整个项目的情况下重新生成测试文件?

【问题讨论】:

标签: ruby-on-rails ruby unit-testing rspec-rails


【解决方案1】:

首先您应该将 rspec gem 添加到 Gemfile 并运行 bundle 或 gem install rspec 也运行 rails g rspec:install

之后,您应该配置 rspec,您可以在此处查看有关本教程测试的更多信息: https://medium.com/@sedwardscode/how-to-properly-test-a-rails-api-with-rspec-f15cbe1dfd11

https://rspec.info/

https://medium.com/@lcriswell/rails-api-request-specs-with-rspec-effeac468c4e

https://www.nopio.com/blog/rails-api-tests-rspec/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-12-14
    • 2012-04-12
    • 1970-01-01
    • 2023-01-09
    • 1970-01-01
    • 2012-05-13
    • 1970-01-01
    相关资源
    最近更新 更多