【发布时间】:2013-10-17 14:29:54
【问题描述】:
我禁用了 ActionController 的 include_all_helpers,所以我必须在我的视图规范中处理这个问题。这工作正常:
require 'spec_helper'
describe "admin/test.html.haml" do
before(:each) { view.extend Admin::BaseHelper }
it { render }
end
我想将前一行提取到 spec_helper.rb:
RSpec.configure do |config|
config.before(:each, type: :view) do
if example.metadata[:full_description].start_with?('admin/')
view.extend Admin::BaseHelper
end
end
end
没有我的规范失败:
undefined method `view_context' for nil:NilClass
所以我的扩展调用导致视图为零?我错过了什么吗?还是我误会了什么?
【问题讨论】:
-
看起来这是 rspec 中最近的回归:github.com/rspec/rspec-rails/pull/833
标签: ruby-on-rails ruby ruby-on-rails-3 rspec