Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable custom description for permit matcher #759

Closed
barelyknown opened this issue Feb 18, 2023 · 0 comments · Fixed by #806
Closed

Enable custom description for permit matcher #759

barelyknown opened this issue Feb 18, 2023 · 0 comments · Fixed by #806

Comments

@barelyknown
Copy link
Contributor

barelyknown commented Feb 18, 2023

We're using RSpec output to document the permissions of all our resources. The default description is not what we want since it inspects the user and that adds noise to the output for no value.

I understand that it's probably not reasonable to change the default description because some people may depend on that behavior. But, it would be good to add the ability to customize it.

For example, I added a:

module Pundit
  module RSpec
    module Matchers
      extend ::RSpec::Matchers::DSL
      def self.description(&block)
        @description = block.call
      end
      # ...
      matcher :permit do |user, record|
        # ...
        description do
          if Pundit::RSpec::Matchers.instance_variable_defined?(:@description)
            Pundit::RSpec::Matchers.instance_variable_get(:@description)
          else
            super
          end
        end
      # ...
end

If you're interested in a related PR, I'll send one in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants