I am developing a Ruby gem that has both a pure ruby and a native-compiled component. Pure ruby is there for times where a speed-up is needed, but the native code cannot be compiled. However, I am having trouble testing both the native and pure ruby code in the same test suite.
I have a module which contains the tests, and am doing something like this:
require 'helper'
class BinarySearchNativeTest < Minitest::Test
require 'binary_search/native'
include CommonTests
end
I have something similar with a different class name, and a require line to import the pure ruby version of the code.
However, when I run this test suite, depending on the order in which things are loaded, it will use either the native or pure ruby version in both test classes.
Short of renaming methods and other trickery to test this, which will change the code under test, I am at a loss on what to do next. Any suggestions on how to do this, without fracturing the gem into a pure gem and a native gem, which has other problems?