Ruby on rails 3 Rails 3集成测试失败,对简单html请求的406响应

Ruby on rails 3 Rails 3集成测试失败,对简单html请求的406响应,ruby-on-rails-3,testing,integration-testing,http-status-code-406,Ruby On Rails 3,Testing,Integration Testing,Http Status Code 406,我有一个集成测试,它向“show”操作发送一个简单的GET请求。当我断言_响应时,我得到一个消息:success,它失败了,因为响应是406,这意味着格式是不可接受的HTTP require 'test_helper' class UserFlowsTest < ActionDispatch::IntegrationTest fixtures :continents, :countries, :types test "browse register order" do

我有一个集成测试,它向“show”操作发送一个简单的GET请求。当我断言_响应时,我得到一个消息:success,它失败了,因为响应是406,这意味着格式是不可接受的HTTP

require 'test_helper'

class UserFlowsTest < ActionDispatch::IntegrationTest
  fixtures :continents, :countries, :types

  test "browse register order" do
    docs = make_docs
    assert_equal Doc.count, docs.length, "Docs not created properly"
    bob=new_session_as(:bob)
    bob.goes_to_home
    bob.goes_to_doc(1)
  end

  private

  module TestDSL
    def goes_to_home
      get root_url
      test_results("docs/index")
    end

    def goes_to_doc(id)
      get docs_url(id), #{:format => :html} - fails with this as well...
      y request.inspect
      p response.inspect
      test_results("docs/show")
    end

    def test_results(path)
      assert_response :success, "Checking #{path}"
      assert_template path
    end
  end #module TestDSL



  def new_session_as(person)
    new_session do |sess|
      #sess.goes_to_login
      #sess.logs_in_as(person)
      yield sess if block_given?
    end
  end

  def new_session
    open_session do |sess|
      sess.extend(TestDSL)
      yield sess if block_given?
    end
  end

end
需要“测试助手”
类UserFlowsTest:html}也会失败。。。
y请求检查
p.检查
测试结果(“文件/显示”)
终止
def测试结果(路径)
assert_response:success,“检查#{path}”
断言模板路径
终止
结束#模块测试DSL
def新会话作为(个人)
新的会话do | sess|
#sess.goes\u to\u登录
#sess.以(个人)身份登录
如果给定块,产量sess?
终止
终止
def新课程
开放式会话do | sess|
sess.extend(TestDSL)
如果给定块,产量sess?
终止
终止
终止
以下是request.inspect输出:

---“#[], \“操作\u分派.请求.参数\”=>{\“格式\”=>“1\”, \“action\”=>“index\”,“controller\”=>“docs\”}, \“rack.session\”=>{“origin\u url\”=>\“/docs.1?format=html\”, \“会话id\”=>“6E0E0BE703A2C2ACF15121B1EB56668\”, \“rack.test\”=>正确, \“HTTP_ACCEPT\”=>“text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,文本/普通;q=0.8,图像/png,/;q=0.5 \“, \“HTTP\u HOST\”=>“www.example.com\”, \“服务器名称\=>\”www.example.com \“, \“rack.request.cookie\u hash\”=>{\“\u id\u session\”=>\“bah7bypb3jpz2lux3vybciglyipc2vzc2lvbl9pzcilnmuwztztbiztcwm2eyzjhy2nmtuxmjfimwvinty2njg=--ceb0f44d2ac8df81c888e005abb7e9d1df02e802\”, \“操作\u调度。远程\u ip\”=>,“内容\u长度\”=>“0\”, \“rack.url\u scheme\”=>“http\”, \“action\u dispatch.request.query\u parameters\”=>{\“format\”=>“html\”}, \“操作\u分派.请求.未签名的\u会话\u cookie\”=>{\“来源\u url\”=>\“/\”, \“会话id\”=>“6E0E0BE703A2C2ACF15121B1EB56668\”, \“内容类型\=>\”应用程序/x-www-form-urlencoded\”, \“HTTPS\”=>“off\”,“rack.errors\”=>, \“行动调度.秘密令牌”=>“8922d5d0a3e706818581l8cc2d42d9ce584ba6350de71e6afc49b2ad7d3d05c6e763db2615fca9eb123c51b57223d955a5199b60c20e5efb4be14888a4e3520a2”, \“远程地址”=>“127.0.0.1\”,“路径信息”=>“/docs.1\”, \“rack.version\”=>[1,1],“rack.run\u once\”=>false, \“action\u dispatch.request.path\u parameters\”=>{:format=>\“1\”, :controller=>\“docs\”,:action=>\“index\”}, \“rack.request.cookie\u string\”=>“\u id\u session=bah7bypb3jpz2lux3vybciglyipc2vzc2lvbl9pzcilnmuztbiztcwm2eyzjhy2nmmtuxmjfimwvinty2njg%3D--ceb0f44d2ac8df81c888e005abb7e9d1df02e802\”, \“SCRIPT\u NAME\”=>\“\”, \“操作\u分派.参数\u筛选器\”=>[:密码,:数据], \“操作\u调度。显示\u异常\”=>错误, \“HTTP\u COOKIE\”=>“\u id\u session=bah7bypb3jpz2lux3vybciglyipc2vzc2lvbl9pzcilnmuztbiztcwm2eyzjhy2nmmtuxmjfimwvinty2njg%3D--ceb0f44d2ac8df81c888e005abb7e9d1df02e802\”, \“rack.multi-thread\”=>true, \“action_dispatch.request.request_parameters\”=>{}, \“rack.request.form\u vars\”=>\“\”, \“action\u dispatch.cookies\”=>{“\u id\u session\”=>\“bah7bypb3jpz2lux3vybciyl2rvy3mumt9mb3jtyxq9ahrtbccipc2vzc2lvbl9pzcilnmuztbiztcwm2eyzjy2nmtuxmjfimwvinty2njg=-529dbf0f8e243c480526f3adb777bd9fba49fd\”, \“请求URI\”=>\“/docs.1\”,“rack.multiprocess\”=>true, \“rack.request.query\u hash\”=>{“format\”=>“html\”}, \“rack.request.form_input\”=>#, \“服务器\u端口\=>“80\”, \“action\u controller.instance\”=>“1\”,“action\”=>“index\”, \“controller\”=>“docs\”}、@env={…}>、@cache\u control={}、@body=[\” \“],@status=406,@length=0,@charset=\“utf-8\”, @标头={\'X-UA-Compatible\'=>\'IE=Edge,chrome=1\', \“X-Runtime\”=>\“0.013935\”,“内容类型\”=>\“文本/html; 字符集=utf-8 \“, \“设置Cookie\”=>\“\u id\u session=bah7bypb3jpz2lux3vybciyl2rvy3mumt9mb3jtyxq9ahrtbcipc2vzc2lvbl9pzcilnmuztztcwm2eyzjhy2nmmtuxmjfimwvinty2njg%3D--529dbf0f8e243c830526f37adb777bd9fba49fd; path=/;HttpOnly\“,\“缓存控制\”=>“无缓存\”},@block=nil, @作者=#, @blank=true、@sending_file=false、@etag=nil、, @内容类型=#, @cookie=[]>,@_headers={\“Content Type\”=>\“text/html\”},@docs=[#、#、#、#、#、#、#],@_config=#, @国家=[#,#,#], @大陆=[#,#],@(行动)名称="索引", @_请求=\“1\”, \“action\”=>“index\”,“controller\”=>“docs\”},@env={…}>, @查找上下文=#=>{\“layouts\”=>{\“nav\”=>{true=>[app/views/layouts/_nav.html.haml]}, \“application\”=>{false=>[app/views/layouts/application.html.haml]}, \“docs\”=>{false=>[]}, \“docs\”=>{\“index\”=>{false=>[app/views/docs/index.html.haml]}, @路径=\“/home/jon/id/app/views\”>

@缓存={{#=>{\'布局\'=>{\'文档\'=>{false=>[]}}}, @path=\“/home/jon/.rvm/gems/ruby-1.8.7-p334/gems/devise-1.4.2/app/views\”>”, @详细信息\u key=nil,@skip\u default\u locale=false, @详细信息={:格式=>[:html,:text,:js,:css,:ics,:csv,:xml,:rss, :atom、:yaml、:multipart\u form、:url\u encoded\u form、:json], :handlers=>[:haml,:builder,:erb,:rjs,:rhtml,:rxml], :locale=>[:en,:en]}、@freezed_formats=false>、@doc_types=[#、#]、@_status=200、, @view\u context\u class=nil,@action\u具有\u layout=true>, \“rack.session.options\”=>{:secure=>false,:expire\u after=>nil, :domain=>nil,:httponly=>true, :id=>\“6E0BE703A2C2ACF15121B1EB56668\”,:path=>\“/\”, \“请求\方法\=>\”获取\“,\”典狱长\“=>典狱长::代理:-616946978 @config={:default\u scope=>:user,:failure\u app=>designe::FailureApp, :intercept_401=>false,:default_strategies=>{:user=>[:rememberable, :database_authenticatable]},:scope_defaults=>{}, \“rac