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.
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 themock_with
method is not called therequire 'ruby_smb'
is successful.If I
require 'ruby_smb'
before theRSpec.configure
block in thespec_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.