Anonymous controller in Minitest w/ Rails

后端 未结 2 1930
暗喜
暗喜 2021-01-06 17:26

While converting from RSpec to Minitest I ran into a slight issue that Google has not helped with one bit, and that\'s figuring out how to do something like this:

         


        
2条回答
  •  攒了一身酷
    2021-01-06 17:45

    I don't think anonymous controllers are supported. Instead of using a DSL to create a controller, try defining a controller in your test.

    class SlugTestController < ApplicationController
      def index
        render nothing: true
      end
    end
    
    describe SlugTestController do
      it "should catch bad slugs" do
        get :index, slug: "bad%20slug"
        response.code.must_equal "403"
      end
    end
    

提交回复
热议问题