{"record":{"id":"dd2c981fd1ff4611","repo":"thoughtbot/shoulda-matchers","slug":"name-is-not-registered","errorCode":null,"errorMessage":"'#{name}' is not registered","messagePattern":"'#(.+?)' is not registered","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/shoulda/matchers/integrations/registry.rb","lineNumber":22,"sourceCode":"      # @private\n      class Registry\n        def register(klass, name)\n          registry[name] = klass\n        end\n\n        def find!(name)\n          find_class!(name).new\n        end\n\n        private\n\n        def registry\n          @_registry ||= {}\n        end\n\n        def find_class!(name)\n          registry.fetch(name) do\n            raise ArgumentError, \"'#{name}' is not registered\"\n          end\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":4,"sourceCodeEnd":29,"githubUrl":"https://github.com/thoughtbot/shoulda-matchers/blob/79cdfbc326e97c9b43991b644434ca53c1f62c4c/lib/shoulda/matchers/integrations/registry.rb#L4-L29","documentation":"This ArgumentError is raised by Shoulda::Matchers::Integrations::Registry#find_class! (lib/shoulda/matchers/integrations/registry.rb:20-24), the internal symbol-to-class map that backs the `with.test_framework` and `with.library` calls inside a Shoulda::Matchers.configure block. When you pass a name to either method, Integrations::Configuration calls find_test_framework!/find_library!, which does registry.fetch(name) and raises ArgumentError when that symbol was never registered at require time. In practice it means the symbol you typed is not one of the gem's known integration names: it is typo'd, invented, a String instead of a Symbol, or a name passed to the wrong method (a library name given to with.test_framework, or vice versa).","triggerScenarios":"Calling `with.test_framework` with an unregistered symbol: :rspec2, :Minitest (capitalized), :active_support (the registered name is :active_support_test_case), or the string 'rspec' instead of the symbol :rspec (the registry hash is keyed by Symbols). Calling `with.test_framework :rails` — :rails is registered in the library registry (:rails, :active_record, :active_model, :action_controller, :routing), not the framework registry (:rspec, :minitest, :minitest_5, :minitest_4, :test_unit, :active_support_test_case), so the framework lookup fails. Calling `with.library :minitest` or `with.library :factory_bot` — :minitest is a framework and :factory_bot is not an integration name at all. The raise happens synchronously while the configure block runs, i.e. at test-suite boot.","commonSituations":"Typos when hand-copying the configure block from the README; swapping the framework and library arguments; copying a snippet written for a different shoulda-matchers major version (the with.* DSL and mandatory configuration arrived in 3.0, so pre-3.0 or post-3.0 examples use different names); passing a String like \"minitest_5\" instead of a Symbol; expecting a favorite gem (factory_bot, capybara) to be a registrable library when only the Rails component libraries exist.","solutions":["Fix the symbol to a registered name: test frameworks are :rspec, :minitest (aliased to :minitest_5), :minitest_4, :test_unit, :active_support_test_case; libraries are :rails, :active_record, :active_model, :action_controller, :routing.","Give each method the right kind of name: `with.test_framework :minitest_5` plus `with.library :rails` — never `with.test_framework :rails`, because :rails lives in the library registry.","Pass Symbols, not Strings: registry keys are Symbols, so with.test_framework 'rspec' raises while with.test_framework :rspec works.","If the snippet came from documentation for another version, check the shoulda-matchers version in your Gemfile.lock against that doc's version and re-copy the configure block from the matching README."],"exampleFix":"# before\nShoulda::Matchers.configure do |config|\n  config.integrate do |with|\n    with.test_framework :rails        # ArgumentError: \"':rails' is not registered\"\n    with.library :minitest\n  end\nend\n\n# after\nShoulda::Matchers.configure do |config|\n  config.integrate do |with|\n    with.test_framework :minitest_5   # frameworks: :rspec, :minitest, :minitest_4, :test_unit, :active_support_test_case\n    with.library :rails               # libraries: :rails, :active_record, :active_model, :action_controller, :routing\n  end\nend","handlingStrategy":"validation","validationCode":"SHOULD_FRAMEWORKS = %i[\n  rspec minitest minitest_5 minitest_4 test_unit active_support_test_case\n].freeze\nSHOULD_LIBRARIES = %i[\n  rails active_record active_model action_controller routing\n].freeze\n\ndef configure_shoulda!(framework:, library: :rails)\n  unless SHOULD_FRAMEWORKS.include?(framework)\n    raise ArgumentError, \"#{framework.inspect} is not a registered test framework (#{SHOULD_FRAMEWORKS.join(', ')})\"\n  end\n  unless SHOULD_LIBRARIES.include?(library)\n    raise ArgumentError, \"#{library.inspect} is not a registered library (#{SHOULD_LIBRARIES.join(', ')})\"\n  end\n\n  Shoulda::Matchers.configure do |config|\n    config.integrate do |with|\n      with.test_framework framework\n      with.library library\n    end\n  end\nend","typeGuard":"def valid_test_framework?(name)\n  %i[rspec minitest minitest_5 minitest_4 test_unit active_support_test_case].include?(name)\nend\n\ndef valid_library?(name)\n  %i[rails active_record active_model action_controller routing].include?(name)\nend","tryCatchPattern":"begin\n  Shoulda::Matchers.configure do |config|\n    config.integrate do |with|\n      with.test_framework framework_name\n      with.library library_name\n    end\n  end\nrescue ArgumentError => e\n  raise ArgumentError, \"Bad shoulda-matchers integration name (framework=#{framework_name.inspect}, library=#{library_name.inspect}): #{e.message}\"\nend","preventionTips":["Copy the configure block from the README of the exact shoulda-matchers version pinned in your Gemfile.lock, not from posts written for another major version.","Run the suite immediately after touching the configure block — the ArgumentError fires at boot, so a one-line run catches typos instantly.","Keep the slots straight: test frameworks (:rspec, :minitest, :test_unit, ...) go to with.test_framework; Rails component libraries (:rails, :active_record, ...) go to with.library.","Always pass Symbols (:rspec), never Strings ('rspec') — the registry hash is keyed by Symbol.","Centralize the configure block in one helper required by every test entry point, so there is a single place a name can be wrong."],"tags":["ruby","shoulda-matchers","configuration","argumenterror","registry","rspec","minitest"],"backgroundTag":"unknown-configuration-option","analyzedSha":"79cdfbc326e97c9b43991b644434ca53c1f62c4c","analyzedAt":"2026-08-23T09:43:24.200Z","schemaVersion":2},"datasetVersion":"2026-08-23T13:39:53.451Z"}