I have to maintain a Ruby script, which requires some libs I don't have locally and which won't work in my environment. Nevertheless I want to spec some methods in this script so that I can change them easily.
Is there an option to stub some of the require
statements in the script I want to test so that it can be loaded by rspec and the spec can be executed within my environment?
Example (old_script.rb
):
require "incompatible_lib"
class Script
def some_other_stuff
...
end
def add(a,b)
a+b
end
end
How can I write a test to check the add
function without splitting the "old_Script.rb" file and without providing the incompatible_lib
I don't have?
Thanks, I also thought about the option of adding the files, but finally hacked the require itself within the test case:
I know that this is an ugly hack but as this is legacy code executed on a modified ruby compiler I can't easily get these libs running and it's sufficient to let me test my modifications...