Reputation: 18712
It so happened that I need to unit-test this Ruby script. It's a Sinatra-based web application that uses several gems.
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 looks like you can embed Ruby in a Java program.
Question: Can I use gems in embedded Ruby, i. e. create a Java program that could execute the tests on any machine (Windows, Linux, Mac) and wouldn't require that I install several gems on it manually? If yes, how?
Note: They need to be real gems, mocks are fine.
Update 1 (25.01.2017 13:14): One obvious solution is to extract the logic of that script into a separate Ruby file without dependencies. That probably would be 80 % of the code. Then I could test that logic file even without having the gems.
Upvotes: 7
Views: 396
Reputation: 2341
I am assuming you are using JRuby. Check this and this out. With this maybe you can do the opposite and use Junit from within Jruby itself.
Upvotes: 2