Not sure how to implement plugin for what I need


I have a plugin that I created which is working to execute tests using a custom unit test runner.  I wanted to also do something within the plug-in to enable better code completion.  Basically what is happening is that the test runner is expecting a ruby script, which it reads as text and calls exec on.  Because it is being executed in the context of the test runner class which is calling exec, I wanted to enable intellisense for that class, basically the equivalent of having a using statement in the ruby script: using MyClass

I can put the using statement in my script, and I then get code completion, however since it is not inside of a class or module, I get the 'NoMethodError: undefined method `include'' error at execution time.

So, what I am wondering is what is the correct tool to use to tell IntelliJ that any time it sees a test file for the test runner to act as though it has that include statement in it for code completion?


Comment actions Permalink

Hi Sam!

if would be great if you could elaborate a bit. You're working on a plugin in IDEA, how does the whole structure look like? Do you have Gemfile for your tests? And is your runner written in Ruby?




Comment actions Permalink

Sure.  The test runner is Beaker, which is Puppet Lab's test runner for testing Puppet.  It is written in Ruby.  The tests are also written in Ruby.  The test cases themselves are simply ruby files and are not a class or module, the content of the file is basically just a script like this:

require 'beaker'

# Do something:

on(master, 'puppet agent -t')

# Assert something:

assert(on(master, 'assert something'), 'failure')


Within the Beaker code, it reads the above file in as text and then runs it essentially like this:

class TestCase

  def run_test

    test =
    eval test,nil,path,1




So in effect, at runtime, the test code is executed in the context of the beaker TestCase class, so I can make calls to methods within TestCase, but since there is nothing in the test case script itself telling it to include TestCase, which is usually RubyMine's cue, users don't get any code completion for any of those methods that are available.  What I would like to do is essentially tell RubyMine that any file recognized as a beaker test case file should assume that it has an "include TestCase" in it for the purposes of code completion.


Please sign in to leave a comment.