Ruby on rails Rspec-如何在共享的_示例中包含共享的_上下文

Ruby on rails Rspec-如何在共享的_示例中包含共享的_上下文,ruby-on-rails,ruby,rspec,rspec-rails,Ruby On Rails,Ruby,Rspec,Rspec Rails,我有以下Rspec结构 共享上下文.rb shared_context 'do something' do end 测试规格rb shared_examples 'testing' do end describe 'do something' do it_should_behave_like 'testing' end end 共享\u示例取决于共享\u上下文。我如何在共享\u示例中包含共享\u上下文 我试过使用包含上下文,试过需要“支持/共享上下文.rb”,但都不起作

我有以下Rspec结构

共享上下文.rb

shared_context 'do something' do

end
测试规格rb

shared_examples 'testing' do 

end

describe 'do something' do 
   it_should_behave_like 'testing'
   end
end
共享\u示例取决于共享\u上下文。我如何在共享\u示例中包含共享\u上下文

我试过使用包含上下文,试过需要“支持/共享上下文.rb”,但都不起作用


谢谢

只需要文件就行了。也许找不到有问题的文件,您应该使用require
require Rails.root.join('spec/support/shared\u context.rb')
来确定

我通常需要spec_helper.rb中的整个spec/support目录

Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }

我已经包含了Dir[Rails.root.join('spec/support/***.rb')。每个{f|require f}都包含在我的spec|u助手中。你能进一步澄清一下吗,什么是不起作用的?你能给出你得到的错误吗?我得到了以下错误-未定义的局部变量或方法“variable\u name”问题中没有提到
variable\u name
方法。你能为这个问题补充更多细节吗?