Skip to main content
 首页 » 编程设计

ruby-on-rails之为什么人们在 Gemfile 中对 rspec 进行测试和开发

2024年10月25日17birdshome

我通常很清楚 bundler Gemfile 选项,但我不确定为什么 rspec(特别是 rspec-rails)应该同时用于测试和开发。

这是我的测试分组:

group :development, :test do 
  gem 'rspec-rails' 
  gem 'faker' 
end 
 
group :test do 
  gem "factory_girl_rails" 
  gem "capybara" 
  gem 'guard-rspec' 
  gem 'rb-fsevent' 
  gem 'growl' 
end 

这看起来好吗?

请您参考如下方法:

我在引用 the official documentation :

Add rspec-rails to the :test and :development groups in the Gemfile:


group :test, :development do    
    gem "rspec-rails", "~> 2.6"  
end 

It needs to be in the :development group to expose generators and rake tasks without having to type RAILS_ENV=test.