【问题标题】:Why does color_enabled work in Ruby's rspec 3.0.3 throw a NoMethodError?为什么 color_enabled 在 Ruby 的 rspec 3.0.3 中工作会抛出 NoMethodError?
【发布时间】:2014-10-18 23:46:19
【问题描述】:

我有一个名为 mySpec 的 ruby​​ 规范文件。在规范文件中,我想在第 37 行运行一个特定的测试。但是,当我运行该测试时,我得到一个NoMethodError

$ rspec -v
3.0.3

$ bundle exec rspec myspec.rb:37
Coverage report generated for RSpec to coverage. 79 / 223 LOC (35.43%) covered.
spec_helper.rb:10:in `block in <top (required)>': undefined method `color_enabled=' for #<RSpec::Core::Configuration:0x007f905e2ea2c0> (NoMethodError)

spec_helper.rb 文件的相关部分如下所示:

RSpec.configure do |config|
    # Use color in STDOUT
    config.color_enabled = true
    config.tty = true
    config.order = "random"
end

那为什么我找不到color_enabled?我尝试按照建议hererspec-railsrspec-console 添加到我的Gemfile 中。但这并没有什么不同。

【问题讨论】:

    标签: ruby-on-rails ruby rspec rails-console


    【解决方案1】:

    嗯,有color_enabled?,但没有color_enabled=。试试这个:

    RSpec.configure do |config|
      config.color = true
      config.tty = true
      config.order = "random"
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-23
      • 2018-07-26
      • 1970-01-01
      • 2016-03-02
      • 2023-03-18
      相关资源
      最近更新 更多