gpt4 book ai didi

ruby-on-rails - Rspec2 缺少模板错误

转载 作者:行者123 更新时间:2023-11-28 20:33:33 24 4
gpt4 key购买 nike

从 Rails 2 升级到 3。RSpec 1 到 2。看起来 capybara/webrat 正在尝试查找模板,而我只希望它找到操作。可能的解决方法是什么?

错误

Failure/Error: delete :read, :id => @feed_entry.id, :format => 'json'
Missing template feed_entries/read with {:handlers=>[:erb, :rjs, :rhtml, :rxml, :builder], :formats=>[:json], :locale=>[:en, :en]} in view paths "/Users/maletor/Sites/3md/app/views", ...
# ./app/controllers/feed_entries_controller.rb:37:in `read'
# ./app/controllers/feed_entries_controller.rb:35:in `read'
# ./spec/controllers/feed_entries_controller_spec.rb:200

应用程序/ Controller /feed_entries_controller#read

def read
if request.post?
@feed_entry.read_by(current_account)
elsif request.delete?
@feed_entry.unread_by(current_account)
end

respond_to do |format|
format.html { redirect_to topic_path(params[:topic_id]) }
format.json { render :nothing => :true, :status => :no_content }
format.plist { render :nothing => :true, :status => :no_content }
end
end

spec/controllers/feed_entries_controller_spec.rb:200

delete :read, :id => @feed_entry.id, :format => 'json'

最佳答案

看来你不能使用不同于 200 的状态来执行 render :nothing => true。另一种方法是不使用 render,而是使用 head :no_content.

关于ruby-on-rails - Rspec2 缺少模板错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6698135/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com