diff --git a/spec/pass_through_spec.rb b/spec/pass_through_spec.rb index acdc76c..2d8a241 100644 --- a/spec/pass_through_spec.rb +++ b/spec/pass_through_spec.rb @@ -25,6 +25,7 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. +require "rspec" require "tebako-runtime" # rubocop:disable Metrics/BlockLength @@ -59,5 +60,36 @@ FFI::Platform.send(:remove_const, :PASS_THROUGH) if Object.const_defined?(:PASS_THROUGH) end end + + it "is transparent for other gems in PASS_THROUGH mode" do + if RUBY_PLATFORM =~ /msys|mingw|cygwin/ + if defined?(FFI) + FFI::Platform.send(:remove_const, :OS) + FFI::Platform.send(:remove_const, :ARCH) + FFI::Platform.send(:remove_const, :LIBPREFIX) + FFI::Platform.send(:remove_const, :LIBSUFFIX) + FFI::Platform.send(:remove_const, :PASS_THROUGH) + end + ENV["TEBAKO_PASS_THROUGH"] = "1" + require "fiddle" + + expect(defined?(FFI::Platform::OS)).to_not be_nil + expect(defined?(FFI::Platform::ARCH)).to_not be_nil + expect(defined?(FFI::Platform::LIBPREFIX)).to_not be_nil + expect(defined?(FFI::Platform::LIBSUFFIX)).to_not be_nil + expect(FFI::Platform::PASS_THROUGH).to eq(true) + end + end + + after do + if RUBY_PLATFORM =~ /msys|mingw|cygwin/ + ENV.delete("TEBAKO_PASS_THROUGH") + FFI::Platform.send(:remove_const, :OS) if Object.const_defined?(:OS) + FFI::Platform.send(:remove_const, :ARCH) if Object.const_defined?(:ARCH) + FFI::Platform.send(:remove_const, :LIBPREFIX) if Object.const_defined?(:LIBPREFIX) + FFI::Platform.send(:remove_const, :LIBSUFFIX) if Object.const_defined?(:LIBSUFFIX) + FFI::Platform.send(:remove_const, :PASS_THROUGH) if Object.const_defined?(:PASS_THROUGH) + end + end end # rubocop:enable Metrics/BlockLength