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

Undefined method `configure' for RSpec:Module (NoMethodError) #26

Open
mahdiarn opened this issue Mar 28, 2023 · 0 comments
Open

Undefined method `configure' for RSpec:Module (NoMethodError) #26

mahdiarn opened this issue Mar 28, 2023 · 0 comments

Comments

@mahdiarn
Copy link

mahdiarn commented Mar 28, 2023

Issue happened on:

dry-validation-matchers 1.2.2
Ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [arm64-darwin21]
Rails 7.0.4.3
Gemfile depends on rspec-rails gem only and not depends on rspec-core directly
dry-validation-matchers gem was defined after rspec-rails gem

Issue trigger:

run rails c
or
run rails s -b 0.0.0.0

Error log when exception raised:

/Users/username/.rvm/gems/ruby-3.0.0/gems/dry-validation-matchers-1.2.2/lib/dry/validation/matchers/integrations/rspec.rb:2:in `<main>': undefined method `configure' for RSpec:Module (NoMethodError)
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/kernel.rb:38:in `require'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/dry-validation-matchers-1.2.2/lib/dry/validation/matchers.rb:5:in `<main>'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/kernel.rb:38:in `require'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/dry-validation-matchers-1.2.2/lib/dry-validation-matchers.rb:1:in `<main>'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/kernel.rb:38:in `require'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/bundler-2.3.23/lib/bundler/runtime.rb:60:in `block (2 levels) in require'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/bundler-2.3.23/lib/bundler/runtime.rb:55:in `each'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/bundler-2.3.23/lib/bundler/runtime.rb:55:in `block in require'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/bundler-2.3.23/lib/bundler/runtime.rb:44:in `each'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/bundler-2.3.23/lib/bundler/runtime.rb:44:in `require'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/bundler-2.3.23/lib/bundler.rb:187:in `require'
	from /Users/username/Documents/hyrd/repo/hyrd-api/config/application.rb:7:in `<main>'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.2/lib/rails/commands/server/server_command.rb:137:in `block in perform'
	from <internal:kernel>:90:in `tap'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.2/lib/rails/commands/server/server_command.rb:134:in `perform'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.2/lib/rails/command/base.rb:87:in `perform'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.2/lib/rails/command.rb:48:in `invoke'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.2/lib/rails/commands.rb:18:in `<main>'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	from /Users/username/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	from bin/rails:4:in `<main>'

Analysis:

  • Based on the conditions mentioned above, the rspec-rails behavior was extending RSpec module, that makes the RSpec module defined but the configure method was not defined (ref)

Solution:

Alternative solution on this issue:

  • adding rspec-core to the gemfile and defined it before dry-validation-helper
    or
  • defining dry-validation-helper gem before rspec-rails gem
    Both needs to update the README.md to avoid this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant