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

Field 'stub' shadows an existing method in RubySMB::Dcerpc::Request while unit testing #261

Open
ls5302 opened this issue Feb 27, 2024 · 0 comments

Comments

@ls5302
Copy link

ls5302 commented Feb 27, 2024

When I try to unit test my code, a simple SMB client, I get a SyntaxError error with the message field 'stub' shadows an existing method in RubySMB::Dcerpc::Request.

This only happens when I'm running the RSPEC tests, and my code executes without errors. The issue seem to occur because RSPEC has been configured by calling mock_with :rspec, and the BasicObject has a stub function defined. If the mock_with method is not called the require 'ruby_smb' is successful.

If I require 'ruby_smb' before the RSpec.configure block in the spec_helper.rb - like you have in your tests - all is well too.

Any suggestion as to how to run the unit tests without pre-requiring the GEM? Can the check be changed to @the_class.method_defined?(name, false) to ignore inherited methods?

Further problem, name_is_reserved? is also picking up stub as a reserved work because it's part of Hash.

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