Controller 如下:
class VersionsController < ApplicationController def index @version = Version.find(:all, :conditions => { :status => nil }) end end
然后在 RSpec 想获取到这个 @version
,搜了如下方法都不行…
VersionsController.instance_variable_get(:version)
会提示 is not allowed as an instance variable name
.
expect(assigns(:version)).to be_a_new(Version)
会提示 :version
为 []
...