<commit_before>Feature: anonymous controller

  As a Rails developer using RSpec
  In order to specify behaviour of ApplicationController
  I want a simple DSL for generating anonymous subclasses

  Scenario: specify error handling in ApplicationController
    Given a file named "spec/controllers/application_controller_spec.rb" with:
    """
    require "spec_helper"

    class ApplicationController < ActionController::Base
      class AccessDenied < StandardError; end

      rescue_from AccessDenied, :with => :access_denied

    private

      def access_denied
        redirect_to "/401.html"
      end
    end

    describe ApplicationController do
      controller do
        def index
          raise ApplicationController::AccessDenied
        end
      end

      describe "handling AccessDenied exceptions" do
        it "redirects to the /401.html page" do
          get :index
          response.should redirect_to("/401.html")
        end
      end
    end
    """
    When I run `rspec spec`
    Then the examples should all pass

  Scenario: specify error handling in subclass of ApplicationController
    Given a file named "spec/controllers/application_controller_subclass_spec.rb" with:
    """
    require "spec_helper"

    class ApplicationController < ActionController::Base
      class AccessDenied < StandardError; end
    end

    class ApplicationControllerSubclass < ApplicationController

      rescue_from ApplicationController::AccessDenied, :with => :access_denied

      private

      def access_denied
        redirect_to "/401.html"
      end
    end

    describe ApplicationControllerSubclass do
      controller(ApplicationControllerSubclass) do
        def index
          raise ApplicationController::AccessDenied
        end
      end

      describe "handling AccessDenied exceptions" do
        it "redirects to the /401.html page" do
          get :index
          response.should redirect_to("/401.html")
        end
      end
    end
    """
    When I run `rspec spec`
    Then the examples should all pass
<commit_msg>doc tweak<commit_after>Feature: anonymous controller

  Use the `controller` method to define an anonymous controller derived from
  ApplicationController, or any other base controller. This is useful for
  spec'ing behavior such as global error handling.

  Scenario: specify error handling in ApplicationController
    Given a file named "spec/controllers/application_controller_spec.rb" with:
    """
    require "spec_helper"

    class ApplicationController < ActionController::Base
      class AccessDenied < StandardError; end

      rescue_from AccessDenied, :with => :access_denied

    private

      def access_denied
        redirect_to "/401.html"
      end
    end

    describe ApplicationController do
      controller do
        def index
          raise ApplicationController::AccessDenied
        end
      end

      describe "handling AccessDenied exceptions" do
        it "redirects to the /401.html page" do
          get :index
          response.should redirect_to("/401.html")
        end
      end
    end
    """
    When I run `rspec spec`
    Then the examples should all pass

  Scenario: specify error handling in subclass of ApplicationController
    Given a file named "spec/controllers/application_controller_subclass_spec.rb" with:
    """
    require "spec_helper"

    class ApplicationController < ActionController::Base
      class AccessDenied < StandardError; end
    end

    class ApplicationControllerSubclass < ApplicationController

      rescue_from ApplicationController::AccessDenied, :with => :access_denied

      private

      def access_denied
        redirect_to "/401.html"
      end
    end

    describe ApplicationControllerSubclass do
      controller(ApplicationControllerSubclass) do
        def index
          raise ApplicationController::AccessDenied
        end
      end

      describe "handling AccessDenied exceptions" do
        it "redirects to the /401.html page" do
          get :index
          response.should redirect_to("/401.html")
        end
      end
    end
    """
    When I run `rspec spec`
    Then the examples should all pass

{'fraction_non_alphanumeric': 0.050620821394460364, 'fraction_numerical': 0.008595988538681949, 'mean_word_length': 2.655322862129145, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1688359', 'n_tokens_mistral': 1068, 'n_tokens_neox': 1006, 'n_words': 361}