1

我的规格是这样的:

describe SomeController do

    before(:each) do
        @request.env["HTTP_ACCEPT"] = 'application/vnd.apple.mpegurl'
    end

    describe 'GET #index' do
        it "returns response" do
            get 'index', format: :m3u8
            puts response.code # prints 406
            response.should be_success # fails
        end
    end
end

控制器:

class SomeController < AuthenticatedController
  def index
    Mime::Type.register "application/vnd.apple.mpegurl", :m3u8
    # do some stuff
    respond_to do |format|
        format.m3u8 { render :m3u8 => @some_variable.html_safe }
    end
end

我缺少什么让它以状态 200 响应?现在,返回的状态是 406。谢谢。

4

1 回答 1

1

放下@.

before(:each) do
  request.env["HTTP_ACCEPT"] = 'application/vnd.apple.mpegurl'
end
于 2012-12-23T20:46:41.863 回答