2017-10-04 94 views
1

我有一个观点如下:意见规格失败后升级到Rails的5

json = render 'users/info', user: @user 
json[:device] = render 'devices/info', device: @device 
json[:locations] = locations.map { |l| render 'locations/info', l: l } if params[:locations_scope].present? 

json 

和我有一个测试如下:

before do 
    product 
    assign(:user, user) 
    assign(:device, device) 
    allow(view).to receive(:user_is_connected?) { false } 
    allow(view).to receive(:utc_string) 
    render 
    end 

    describe 'user object' do 
    it 'provies the email' do 
     expect(subject['user']['email']).to eq(user.email) 
    end 

升级到轨道前5名,这是工作的罚款,但现在我得到的错误

@rendered_views=#<ActionView::TestCase::Behavior::RenderedViewsCollection:0x007fd6e8f29a88 @rendered_views={}>> does not implement: user_is_connected?

user_is_connected?方法是一个辅助方法在基础控制器中。
似乎这种行为在RoR 5中发生了变化,但我无法找到与此相关的任何内容。

我加rails-controller-testing到Gemfile中为好,但仍然,同样的问题

回答

1

就想通了:禁用RSpec的

config.mock_with :rspec do |mocks| 
    mocks.verify_partial_doubles = false 
end 
部分嘲笑的验证