Search code examples
ruby-on-railsdevisepundit

Rspec spec failing -- undefined method `permissions' for RSpec::ExampleGroups::UserPolicy:Class (NoMethodError)


I'm installing an app with Pundit authorization and when I try to run RSpec tests I get:

undefined method `permissions'
  for RSpec::ExampleGroups::UserPolicy:Class
      (NoMethodError)

Solution

  • Found out what the problem was...

    Following line in rails_helper.rb was commented out:

    # The following line is provided for convenience purposes. It has the downside
    # of increasing the boot-up time by auto-requiring all files in the support
    # directory. Alternatively, in the individual `*_spec.rb` files, manually
    # require only the support files necessary.
    #
    Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
    

    Activating it made the tests work correctly :)