title: Can you use gems, when you execute a Ruby script in embedded JRuby?
body: <p>It so happened that I need to unit-test this <a href="https://github.com/dpisarenko/50web/blob/mvp/routes/songcontest.rb">Ruby script</a>. It's a <a href="http://www.sinatrarb.com/">Sinatra</a>-based web application that uses several gems.</p>
  
  <p>I have more experience in Java than in Ruby, time is very important (and elegance isn't), and so I thought I may be faster, if I execute that script in a JUnit class and mock all subsystems it depends on (web server, database). That way I could use my Java skills to test a Ruby system. It <a href="https://kenai.com/projects/jruby/pages/RedBridge">looks</a> like you can embed Ruby in a Java program.</p>
  
  <p>Question: Can I use gems in embedded Ruby, i. e. create a Java program that could execute the tests on <strong>any</strong> machine (Windows, Linux, Mac) and wouldn't require that I install several gems on it manually? If yes, how?</p>
  
  <p>Note: They need to be real gems, mocks are fine.</p>
  
  <p><strong>Update 1 (25.01.2017 13:14):</strong> One obvious solution is to extract the logic of that script into a separate Ruby file <strong>without</strong> dependencies. That probably would be 80 % of the code. Then I could test that logic file even without having the gems.</p>