我目前正在研究 Rails 4 Test Prescriptions,遇到了一个本书中没有提到的规范文件的加载顺序问题。不幸的是,我无法从我所能找到的问题中解决这个问题。当我尝试运行我的测试时,得到的输出是
/Users/Admin/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:370:in `find_and_eval_shared': Could not find shared examples "sizeable" (ArgumentError)
from /Users/Admin/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:310:in `block (2 levels) in define_nested_shared_group_method'
from /Users/Admin/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:385:in `module_exec'
from /Users/Admin/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:385:in `subclass'
from /Users/Admin/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:258:in `block in define_example_group_method'
from /Users/Admin/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:309:in `block in define_nested_shared_group_method'
from /Users/Admin/Desktop/Apps/gatherer/spec/models/task_spec.rb:4:in `block in <top (required)>'
from /Users/Admin/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:385:in `module_exec'
from /Users/Admin/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:385:in `subclass'
from /Users/Admin/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/example_group.rb:258:in `block in define_example_group_method'
from /Users/Admin/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/dsl.rb:43:in `block in expose_example_group_alias'
from /Users/Admin/Desktop/Apps/gatherer/spec/models/task_spec.rb:3:in `<top (required)>'
from /Users/Admin/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load'
from /Users/Admin/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `block in load'
from /Users/Admin/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
from /Users/Admin/.rvm/gems/ruby-2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load'
from /Users/Admin/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1435:in `block in load_spec_files'
from /Users/Admin/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1433:in `each'
from /Users/Admin/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/configuration.rb:1433:in `load_spec_files'
from /Users/Admin/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:100:in `setup'
from /Users/Admin/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:86:in `run'
from /Users/Admin/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:71:in `run'
from /Users/Admin/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/runner.rb:45:in `invoke'
from /Users/Admin/.rvm/gems/ruby-2.3.0/gems/rspec-core-3.5.4/exe/rspec:4:in `<top (required)>'
from /Users/Admin/.rvm/gems/ruby-2.3.0/bin/rspec:23:in `load'
from /Users/Admin/.rvm/gems/ruby-2.3.0/bin/rspec:23:in `<main>'
from /Users/Admin/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
from /Users/Admin/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'
您可以在https://github.com/jamesemcc/gatherer上查看我的存储库
谢谢你的帮助!
2条答案
按热度按时间yr9zkbsy1#
将共享示例声明文件
size_group.rb
加载到您的task_spec.rb
就像这样:
编辑:
最好将shared_example主示例加载到
rails_helper.rb
中。3lxsmp7m2#
有一个类似的问题“找不到共享的示例...”
在我的情况下,解决方案是:
我在组名上打错了