Sha256: c8daa1d13811ad2ba6bf0f08ac40b1c2d8ecd9fd85499089e1ce72a8e63f7a9f

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

module Rspectacular
  module Matchers
    module Authentication
      def it_should_require_authentication_for(*actions)
        actions.each do |action_parts|
          method, action, params = action_parts

          params ||= {}
          params.reverse_merge! :id => 1

          it "#{method.upcase} ##{action} should require login" do
            send(method, action, params)

            response.should redirect_to(new_user_session_path)
          end
        end
      end

      def it_should_not_require_authentication_for(*actions)
        actions.each do |action_parts|
          method, action, params = action_parts

          params ||= {}
          params.reverse_merge! :id => 1

          it "#{method.upcase} ##{action} should not require login" do
            send(method, action, params)

            response.should_not redirect_to(new_user_session_path)
          end
        end
      end
    end
  end
end

RSpec.configure do |config|
  config.extend RSpectacular::Matchers::Authentication, :type => :controller
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspectacular-0.53.1 lib/rspectacular/matchers/authentication.rb