简体   繁体   English

如何在RSpec自动测试中添加颜色?

[英]How to add colors in autotest for rspec?

So I have these gems for dev: 所以我为开发人员准备了这些宝藏:

  gem 'autotest'
  gem 'ZenTest'
  gem 'autotest-growl'

In my .autotest file: 在我的.autotest文件中:

require 'active_support'
require 'active_support/core_ext'
require 'autotest/restart'
require 'redgreen/autotest'


begin
  require 'autotest/growl'
rescue LoadError
  warn "Error loading autotest/growl. Run '[sudo] gem install autotest-growl' first."
end

 Autotest::Growl::show_modified_files = false
 Autotest::Growl::hide_label = true
 Autotest::Growl::remote_notification = true

Autotest.add_hook :initialize do |at|
  %w{.git .svn .hg .DS_Store ._* log}.each {|exception|at.add_exception(exception)}
end

If i run with require 'redgreen/autotest' or 'autotest/redgreen', I get these erros: 如果我运行要求'redgreen / autotest'或'autotest / redgreen',我会得到以下错误信息:

C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/ZenTest-4.11.1/lib/autotest.rb:419:in `run_tests'
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/ZenTest-4.11.1/lib/autotest.rb:394:in `get_to_green'
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/ZenTest-4.11.1/lib/autotest.rb:367:in `block in run'
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/ZenTest-4.11.1/lib/autotest.rb:365:in `loop'
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/ZenTest-4.11.1/lib/autotest.rb:365:in `run'
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/ZenTest-4.11.1/lib/autotest.rb:248:in `run'
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/ZenTest-4.11.1/bin/autotest:6:in `<top (required)>'
C:/RailsInstaller/Ruby2.3.3/bin/autotest:22:in `load'
C:/RailsInstaller/Ruby2.3.3/bin/autotest:22:in `<main>'
Quitting

I tried also with kule/redgreen gem, but nothing? 我也尝试过kule / redgreen宝石,但是什么也没有? If I run rspec separately it has colors. 如果我单独运行rspec,则它具有颜色。 Tried it on multiple terminals, installed ansi etcetera. 在多个终端上进行了尝试,安装了ansi等。

Edit 1: My gemfile https://gist.github.com/bbtdev/2c511c4741749db7fbffb02b6d72d9ad 编辑1:我的gemfile https://gist.github.com/bbtdev/2c511c4741749db7fbffb02b6d72d9ad

Edit 2: I also have a app/autotest/discovery.rb with Autotest.add_discovery { "rspec" } My rspec version is 3.7 编辑2:我也有一个带有autotest.add_discovery {“ rspec”}的app / autotest / discovery.rb我的rspec版本是3.7

Edit 3: I installed 编辑3:我安装

gem 'rspec-autotest' gem 'autotest-rails' gem'rspec-autotest'gem'autotest-rails'

And when trying to add require 'redgreen/autotest' or require 'redgreen/autotest' unless ENV['RSPEC'] it gives me 当尝试添加要求'redgreen / autotest'或要求'redgreen / autotest'时,除非ENV ['RSPEC']它给我

bundler: command not found: C:\\RailsInstaller\\Ruby2.3.3\\bin\\ruby -rrubygems -e require 捆绑器:找不到命令:C:\\ RailsInstaller \\ Ruby2.3.​​3 \\ bin \\ ruby​​ -rrubygems -e require

Try changing, 尝试改变,

require 'redgreen/autotest'

to

require 'redgreen/autotest' unless ENV['RSPEC']

in your .autotest file. 在您的.autotest文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM