【问题标题】:NoMethodError: undefined method `color_enabled=' when run capybara test in rails consoleNoMethodError:在rails控制台中运行capybara测试时未定义的方法`color_enabled ='
【发布时间】:2014-08-17 17:07:03
【问题描述】:
NoMethodError: undefined method `color_enabled='  for #<RSpec::Core::Configuration:0x007ff1ba922ad0> 
from /Users/apple/.rvm/gems/ruby-2.0.0-p247@global/gems/rspec-console-0.2.7/lib/rspec-console/config_cache.rb:69:in `method_missing'

不知道怎么解决~

有什么建议吗?谢谢~

【问题讨论】:

  • 范围非常广泛,显示出极度缺乏努力。您能否详细说明错误是如何产生的,以及您在尝试解决该问题时所查看的内容!
  • 我已经尝试过的:更新撬动。更新所有宝石。 google这个错误信息,发现rspec core去掉color_enabled作为color的别名。 (乔恩·罗)。 (github.com/rspec/rspec-core/blob/master/Changelog.md)。我设置了 config.color_enabled = true,但没有用。 config.color = true 也没用。

标签: ruby-on-rails rspec capybara


【解决方案1】:

我在升级到 rspec-core 3.1.7 时遇到了同样的错误。我通过更改解决了这个特定问题

config.color_enabled = true

config.color = true

在 spec_helper.rb 中。但是,我遇到了其他 rspec 错误并决定暂时恢复到 rspec-core 2.14.8。

【讨论】:

    【解决方案2】:

    设置后

    gem 'rspec-rails', '~> 2.14.2' gem 'rspec-console', '~> 0.2.7'

    一切正常,我认为这个问题是 rspec 和 rspec-console 版本冲突问题。可能和https://github.com/nviennot/rspec-console/pull/14有关。

    【讨论】:

    • 这是因为配置选项在 rspec 3.1 之后发生了变化,请更改上面答案中的配置选项以使其与 3.1 及以上版本一起使用
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多