【问题标题】:Use rspec only in integration tests仅在集成测试中使用 rspec
【发布时间】:2013-02-06 10:55:54
【问题描述】:

我有一个与 Rails 默认测试套件 Test::Unit 配合使用的项目,我没有理由更改我编写的测试。但是当我用 capybara 编写集成测试时,我发现 capybara 总是与 rspec 一起使用,并且在使用 capybara 和 Test::Unit 时遇到了一些问题。所以我决定在集成测试中使用 rspec。

但这就是问题所在。运行rails g rspec:install 后,cmd rails g model 将在规范中创建测试,我如何仅将 rspec 用于集成测试并在其他测试中使用 Test::Unit。

提前致谢。

【问题讨论】:

    标签: ruby-on-rails ruby testing rspec


    【解决方案1】:

    我假设您安装了 rspec-rails gem。宝石configures Rails to use RSpec for testing。生成器通常在开发中运行,因此通过将 rspec-rails 限定为 :test group in your Gemfile,Rails 不应在开发中加载 gem。

    group :test do
      gem 'rspec-rails'
    end
    

    您还可以在 gem 加载后覆盖 rspec-rails 设置的设置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多