How would one create a Codecademy/RubyMonk style website?

I was wondering how one could create an interactive coding education application.
I’m aware of how to create a REPL in the browser using something like OPAL, but I was wondering how we could run tests against the code submitted in the REPL to display errors etc.

Thanks for any help.