ruby – 如何获取rspec不显示数据库查询和只有点与rails_12factor?

前端之家收集整理的这篇文章主要介绍了ruby – 如何获取rspec不显示数据库查询和只有点与rails_12factor?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
ruby: 2.0
rails: 3.2.17
rspec: 2.14.8
Database: MysqL

rspec规格只是输出点.

当我推送到Heroku时,我得到了一个贬低的警告,最近添加了rails_12factor宝石来绕过它.现在,我在本地运行规范时为每个事务获取此详细的db输出.
这是一个很好的选择,当我需要它否则它是很多不必要的和令人分心的输出.

所以我想要一个选项,将它用于Heroku,但不在本地.

注意,这不是通过使用格式化程序来解决的.

rspec spec -fd

另外,如果有一个错误,这个级别的详细程度,错误几乎总是滚动当前页面

09:50:39 durrantm Castle2012 /home/durrantm/Dropnot/_/rails_apps/linker 74093480_wire_up_verify_code
$rspec spec/models/link_spec.rb -fd
Connecting to database specified by database.yml
...
Link
   (0.2ms)  BEGIN
   (0.2ms)  SAVEPOINT active_record_1
  sql (0.6ms)  INSERT INTO `groups` (`created_at`,`group_description`,`group_name`,`updated_at`) VALUES ('2014-07-12 13:50:49','VarIoUs jQuery examples of common situa
tions amnd solutions','jQuery Examples','2014-07-12 13:50:49')
   (0.2ms)  RELEASE SAVEPOINT active_record_1
   (0.2ms)  SAVEPOINT active_record_1
  Link Load (0.6ms)  SELECT `links`.* FROM `links` WHERE (links.position IS NOT NULL) AND (1 = 1) ORDER BY links.position DESC LIMIT 1
  sql (0.4ms)  INSERT INTO `links` (`alt_text`,`content_date`,`created_at`,`group_id`,`position`,`updated_at`,`url_address`,`verified_date`,`version_number`) VALUE
S ('examples of common situations amnd solutions',NULL,'2014-07-12 13:50:49',141,1,'http://test.com',NULL)
   (0.1ms)  RELEASE SAVEPOINT active_record_1
   (68.4ms)  ROLLBACK
  should be valid
   (0.2ms)  BEGIN
   (0.2ms)  SAVEPOINT active_record_1
  sql (0.3ms)  INSERT INTO `groups` (`created_at`,'2014-07-12 13:50:49')
   (0.1ms)  RELEASE SAVEPOINT active_record_1
   (0.2ms)  SAVEPOINT active_record_1
  Link Load (0.7ms)  SELECT `links`.* FROM `links` WHERE (links.position IS NOT NULL) AND (1 = 1) ORDER BY links.position DESC LIMIT 1
  sql (0.5ms)  INSERT INTO `links` (`alt_text`,142,NULL)
   (0.2ms)  RELEASE SAVEPOINT active_record_1
   (67.6ms)  ROLLBACK
  should have attribute :group_id
   (0.3ms)  BEGIN
   (0.2ms)  SAVEPOINT active_record_1
  sql (0.4ms)  INSERT INTO `groups` (`created_at`,'2014-07-12 13:50:49')
   (0.1ms)  RELEASE SAVEPOINT active_record_1
   (0.2ms)  SAVEPOINT active_record_1
  Link Load (0.5ms)  SELECT `links`.* FROM `links` WHERE (links.position IS NOT NULL) AND (1 = 1) ORDER BY links.position DESC LIMIT 1
  sql (0.4ms)  INSERT INTO `links` (`alt_text`,143,NULL)
   (0.1ms)  RELEASE SAVEPOINT active_record_1
   (68.7ms)  ROLLBACK
  should have attribute :url_address
...

解决方法

我们也看到这个,它由rails_12factor gem生成,它可以被压制,通常只需确保gem只在生产组中,就像这样:
group :production do
  gem 'rails_12factor'
end

rails_12factor的依赖之一是另一个名为rails_stdout_logging的gem,它导致您看到的输出.

猜你在找的Ruby相关文章