【问题标题】:Colorize/highlight rails 3 'rake test' output着色/突出显示 rails 3 'rake test' 输出
【发布时间】:2011-05-24 01:37:55
【问题描述】:

我已经使用 redgreen gem 来突出显示 rails 3 的一些测试输出。我喜欢它,但我只是因为我正在寻找更具体的解决方案而找到它,而它没有。

我希望看到特别突出显示的文件名。我想用一个例子来说明:

  4) Error:
test_shouldn't_be_able_to_make_duplicate_ModeratorPermission(ModeratorPermissionTest):
NoMethodError: undefined method `users' for #<ModeratorPermissionTest:0x7f13ad7ee3d0>
    /test/unit/moderator_permission_test.rb:10:in `test_shouldn't_be_able_to_make_duplicate_ModeratorPermission'

  5) Error:
test_*should*_be_able_to_make_duplicate_Post(PostTest):
NoMethodError: undefined method `users' for #<PostTest:0x7f13ad7f04a0>
    /test/unit/post_test.rb:12:in `test_*should*_be_able_to_make_duplicate_Post'

  6) Error:
test_should_be_able_to_make_a_post(PostTest):
NoMethodError: undefined method `users' for #<PostTest:0x7f13ad7f0478>
    /test/unit/post_test.rb:6:in `test_should_be_able_to_make_a_post'

当我第一次看到这个黑白相间的时候,我的眼睛并没有立即转向任何一个地方。我希望突出显示“PostTest”和“ModeratorPermission”。如果测试名称本身被突出显示也很好。

有谁知道那里是否有宝石可以做到这一点?

【问题讨论】:

    标签: ruby-on-rails-3 testing colors rake


    【解决方案1】:

    你试过 term-ansicolor 吗?

    http://flori.github.com/term-ansicolor/

    或者,如果您只是在寻找更清洁的输出,不妨试试 turn?

    https://github.com/TwP/turn

    【讨论】:

    • 嗯,我已经有一段时间没有为我的 Rails 应用程序进行 Ruby 端测试了。我认为使用 term-ansicolor,我可以得到我想要的东西。不过,Turn 看起来真的很性感。当我回到测试我的 Rails 应用程序的时候,我肯定会尝试这样做。谢谢!
    【解决方案2】:

    对于rake test 输出上的一点颜色,gem install turn 可用于 ruby​​ 1.9 和 2.0。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-03-07
      • 1970-01-01
      • 2015-03-25
      • 2015-11-26
      • 1970-01-01
      • 2010-09-17
      • 2014-10-21
      • 1970-01-01
      相关资源
      最近更新 更多