我从视图规范中得到了一些奇怪的结果
Failure/Error: assert_select "div.fileinput-new.thumbnail"
ArgumentError:
wrong number of arguments (3 for 1)
好的,所以这似乎是不言自明的(虽然我不确定引用的3个参数是什么)。
但是,如果我再次运行套件,我可能会得到0错误。接下来,5个错误,与上面相同的类型,但引用不同的DOM元素。
这些规格中没有任何花哨的东西
describe do
build :object / create :object
@object = assign(:object, object )
it 'displays the DOM elements' do
render
asset_select #DOM_elements
end
end
什么可能导致视图规范的这种不一致的覆盖?
示例堆栈跟踪
Failure/Error: assert_select "div.fileinput-new.thumbnail"
ArgumentError:
wrong number of arguments (3 for 1)
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/actionview-4.2.6/lib/action_view/helpers/text_helper.rb:52:in `concat'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/searchable.rb:165:in `evaluate'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/searchable.rb:165:in `block in xpath'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/searchable.rb:156:in `map'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/searchable.rb:156:in `xpath'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/searchable.rb:193:in `css_internal'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/node_set.rb:76:in `block in css'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/node_set.rb:187:in `block in each'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/node_set.rb:186:in `upto'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/node_set.rb:186:in `each'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/node_set.rb:75:in `inject'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/nokogiri-1.6.7.2/lib/nokogiri/xml/node_set.rb:75:in `css'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rails-dom-testing-1.0.7/lib/rails/dom/testing/assertions/selector_assertions/html_selector.rb:20:in `select'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rails-dom-testing-1.0.7/lib/rails/dom/testing/assertions/selector_assertions.rb:174:in `assert_select'
# ./spec/views/users/settings/profile.html.erb_spec.rb:24:in `block (4 levels) in <top (required)>'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rails-dom-testing-1.0.7/lib/rails/dom/testing/assertions/selector_assertions.rb:295:in `nest_selection'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rails-dom-testing-1.0.7/lib/rails/dom/testing/assertions/selector_assertions.rb:177:in `block in assert_select'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rails-dom-testing-1.0.7/lib/rails/dom/testing/assertions/selector_assertions.rb:174:in `tap'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rails-dom-testing-1.0.7/lib/rails/dom/testing/assertions/selector_assertions.rb:174:in `assert_select'
# ./spec/views/users/settings/profile.html.erb_spec.rb:22:in `block (3 levels) in <top (required)>'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:236:in `instance_exec'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:236:in `block in run'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:478:in `block in with_around_and_singleton_context_hooks'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:435:in `block in with_around_example_hooks'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/hooks.rb:478:in `block in run'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/hooks.rb:618:in `block in run_around_example_hooks_for'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:320:in `call'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:320:in `call'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-rails-3.4.2/lib/rspec/rails/adapters.rb:127:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:425:in `instance_exec'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:425:in `instance_exec'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/hooks.rb:389:in `execute_with'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/hooks.rb:620:in `block (2 levels) in run_around_example_hooks_for'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:320:in `call'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:320:in `call'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/hooks.rb:621:in `run_around_example_hooks_for'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/hooks.rb:478:in `run'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:435:in `with_around_example_hooks'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:478:in `with_around_and_singleton_context_hooks'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/example.rb:233:in `run'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/example_group.rb:581:in `block in run_examples'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/example_group.rb:577:in `map'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/example_group.rb:577:in `run_examples'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/example_group.rb:543:in `run'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/example_group.rb:544:in `block in run'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/example_group.rb:544:in `map'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/example_group.rb:544:in `run'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:119:in `block (3 levels) in run_specs'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:119:in `map'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:119:in `block (2 levels) in run_specs'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/configuration.rb:1680:in `with_suite_hooks'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:118:in `block in run_specs'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/reporter.rb:77:in `report'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:117:in `run_specs'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:93:in `run'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:78:in `run'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/lib/rspec/core/runner.rb:45:in `invoke'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/gems/rspec-core-3.4.4/exe/rspec:4:in `<top (required)>'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/bin/rspec:23:in `load'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/bin/rspec:23:in `<main>'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/bin/ruby_executable_hooks:15:in `eval'
# /Users/me/.rvm/gems/ruby-2.2.3@myapp/bin/ruby_executable_hooks:15:in `<main>'
答案 0 :(得分:2)
这不是一个明确的答案:看起来,由于一些奇怪的原因,Nokogiri的Searchable
模块中的evaluate
method将concat()
函数视为自定义XPath函数而不是internal XPath function。
外部XPath函数在handler
evaluate
属性的上下文中为called as normal ruby methods。通常情况下,处理程序是SubstitutionContext
class但在你的情况下,似乎有时它会获得定义TextHelper
方法的concat
模块的上下文,只接受1个参数(而XPath的{ {1}}函数接受任意数量的参数)。我认为这会导致您观察到的错误。
您是否可以在this line上打开concat()
文件(请参阅堆栈跟踪查找其位置)并在其前面添加一些调试消息以检查以下变量的内容?
searchable.rb
然后,您能为其中一个失败的测试提供打印输出吗?
更新:输出结果显示测试上下文确实被puts "ctx #{ctx.inspect}"
puts "path #{path.inspect}"
puts "handler #{handler.inspect}"
if handler.respond_to?(:concat)
puts "concat #{handler.method(:concat).inspect}"
else
puts "not responding to :concat"
end
模块污染了,最后发现其中包含ActionView::TextHelpers
个模块测试中使用的模型。