加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 22:43:57 所属栏目:百科 来源:网络整理
导读:ruby: 2.0rails: 3.2.17rspec: 2.14.8Database: mysql rspec规格只是输出点. 当我推送到Heroku时,我得到了一个贬低的警告,最近添加了rails_12factor宝石来绕过它.现在,我在本地运行规范时为每个事务获取此详细的db输出. 这是一个很好的选择,当我需要它否则它
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,它导致您看到的输出.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读