I would suggest you not to do that. It would be hackish and unreliable.
What you can do however is divide and conquer! Build a generic version of your gem that is framework agnostic and only handles the logic, let's call it yourgem-core
, then you can build two other gems based on that first one, called yourgem-rails
and yourgems-sinatra
.
It's much better, only logic and logic test in yourgem-core
, only rails integration tests in yourgem-rails
, only sinatra integration tests in yourgem-sinatra