Rspec/Capybara 正在加载,通知要求被认为是有害的 [英] Rspec/Capybara loading in progress, circular require considered harmful

查看:27
本文介绍了Rspec/Capybara 正在加载,通知要求被认为是有害的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不确定这是否是 Capybara 的问题,但我刚刚重新安装了 Rails (4.1.1) 和 Rspec Rails (3.0.1),我想使用 Capybara (2.3.0),但从未使用过我遇到了问题.我在 spec/features 中创建了一个规范",规范本身按预期运行并通过,但是在运行 rspec 时我收到以下警告".有任何想法吗?我是否只需要在 ruby​​ 级别禁用警告?

/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/mail-2.5.4/lib/mail/network/delivery_methods/sendmail.rb:53:警告:阴影外局部变量 - to/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:警告:正在加载,循环需要被认为有害 -/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/capybara-2.3.0/lib/capybara.rb来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/bin/ruby_executable_hooks:15:in `<main>'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/bin/ruby_executable_hooks:15:in `eval'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/bin/rspec:23:in `<main>'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/bin/rspec:23:in `load'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/rspec-core-3.0.0/exe/rspec:4:in `'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/rspec-core-3.0.0/lib/rspec/core/runner.rb:38:in `invoke'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/rspec-core-3.0.0/lib/rspec/core/runner.rb:70:in `run'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/rspec-core-3.0.0/lib/rspec/core/runner.rb:85:in `run'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/rspec-core-3.0.0/lib/rspec/core/runner.rb:97:in `setup'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/rspec-core-3.0.0/lib/rspec/core/configuration.rb:1051:in `load_spec_files'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/rspec-core-3.0.0/lib/rspec/core/configuration.rb:1051:in `each'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/rspec-core-3.0.0/lib/rspec/core/configuration.rb:1051:in `block in load_spec_files'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/rspec-core-3.0.0/lib/rspec/core/configuration.rb:1051:in `load'来自/Users/typeoneerror/Dev/Doki/engines/doki_core/spec/features/accounts/sign_up_spec.rb:1:in `<top (required)>'来自/Users/typeoneerror/Dev/Doki/engines/doki_core/spec/features/accounts/sign_up_spec.rb:1:in `require'来自/Users/typeoneerror/Dev/Doki/engines/doki_core/spec/rails_helper.rb:7:in `<top (required)>'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `block in require'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/rspec-rails-3.0.1/lib/rspec/rails.rb:9:in `<top (required)>'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `block in require'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/rspec-rails-3.0.1/lib/rspec/rails/vendor/capybara.rb:2:in `<top (required)>'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `block in require'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/capybara-2.3.0/lib/capybara/rspec.rb:1:in `<top (required)>'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `block in require'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/capybara-2.3.0/lib/capybara.rb:5:in `'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/capybara-2.3.0/lib/capybara.rb:320:in `<module:Capybara>'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `block in require'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/capybara-2.3.0/lib/capybara/dsl.rb:1:in `<top (required)>'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `block in require'来自/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/capybara-2.3.0/lib/capybara/node/matchers.rb:121: 警告:已分配但未使用的变量 - e/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/capybara-2.3.0/lib/capybara/selenium/driver.rb:119: 警告:已分配但未使用的变量 - a

解决方案

.rspec 中删除 --warnings.rspec 3.0.0 中的生成器包含此设置,但我们已经意识到这是一个错误——虽然鼓励用户编写无警告代码是件好事,但如果用户在不确定原因的情况下收到这些警告,就会感到困惑.

更多信息:

https://github.com/rspec/rspec-core/issues/1571

Unsure if this is a Capybara issue, but I just did a fresh install of Rails (4.1.1) and Rspec Rails (3.0.1) and I would like to use Capybara (2.3.0), but having never used it I'm running into issues. I created a "spec" in spec/features and the spec itself runs and passes as expected, but I get the following "warnings" when rspec is run. Any ideas? Do I just need to disable warnings at the ruby level or something?

/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/mail-2.5.4/lib/mail/network/delivery_methods/sendmail.rb:53: warning: shadowing outer local variable - to
/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247: warning: loading in progress, circular require considered harmful - /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/capybara-2.3.0/lib/capybara.rb
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/bin/ruby_executable_hooks:15:in  `<main>'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/bin/ruby_executable_hooks:15:in  `eval'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/bin/rspec:23:in  `<main>'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/bin/rspec:23:in  `load'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/rspec-core-3.0.0/exe/rspec:4:in  `<top (required)>'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/rspec-core-3.0.0/lib/rspec/core/runner.rb:38:in  `invoke'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/rspec-core-3.0.0/lib/rspec/core/runner.rb:70:in  `run'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/rspec-core-3.0.0/lib/rspec/core/runner.rb:85:in  `run'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/rspec-core-3.0.0/lib/rspec/core/runner.rb:97:in  `setup'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/rspec-core-3.0.0/lib/rspec/core/configuration.rb:1051:in  `load_spec_files'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/rspec-core-3.0.0/lib/rspec/core/configuration.rb:1051:in  `each'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/rspec-core-3.0.0/lib/rspec/core/configuration.rb:1051:in  `block in load_spec_files'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/rspec-core-3.0.0/lib/rspec/core/configuration.rb:1051:in  `load'
    from /Users/typeoneerror/Dev/Doki/engines/doki_core/spec/features/accounts/sign_up_spec.rb:1:in  `<top (required)>'
    from /Users/typeoneerror/Dev/Doki/engines/doki_core/spec/features/accounts/sign_up_spec.rb:1:in  `require'
    from /Users/typeoneerror/Dev/Doki/engines/doki_core/spec/rails_helper.rb:7:in  `<top (required)>'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in  `require'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in  `load_dependency'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in  `block in require'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in  `require'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/rspec-rails-3.0.1/lib/rspec/rails.rb:9:in  `<top (required)>'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in  `require'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in  `load_dependency'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in  `block in require'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in  `require'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/rspec-rails-3.0.1/lib/rspec/rails/vendor/capybara.rb:2:in  `<top (required)>'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in  `require'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in  `load_dependency'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in  `block in require'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in  `require'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/capybara-2.3.0/lib/capybara/rspec.rb:1:in  `<top (required)>'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in  `require'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in  `load_dependency'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in  `block in require'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in  `require'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/capybara-2.3.0/lib/capybara.rb:5:in  `<top (required)>'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/capybara-2.3.0/lib/capybara.rb:320:in  `<module:Capybara>'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in  `require'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in  `load_dependency'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in  `block in require'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in  `require'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/capybara-2.3.0/lib/capybara/dsl.rb:1:in  `<top (required)>'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in  `require'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in  `load_dependency'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in  `block in require'
    from /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in  `require'
/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/capybara-2.3.0/lib/capybara/node/matchers.rb:121: warning: assigned but unused variable - e
/Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/capybara-2.3.0/lib/capybara/selenium/driver.rb:119: warning: assigned but unused variable - a

解决方案

Remove --warnings from .rspec. The generator in rspec 3.0.0 included this setting, but we've realized it was a mistake -- while it's good to encourage users to write warning-free code, it's confusing for users to get these warnings without being sure why.

For more info:

https://github.com/rspec/rspec-core/issues/1571

这篇关于Rspec/Capybara 正在加载,通知要求被认为是有害的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆