Two questions - step definitions and custom gem repo

Hello!

I'm relatively new to Ruby Mine and Ruby in general. I was hoping to get an answer to two questions:

1) I have created a gem that contains a common set of functions and step definitions. I am able to generate and install the gem into my local machine just fine. When I import the gem (via adding it to my test project's Gemfile and running the Bundler install), the custom functions wire up to my steps in the test project. However, I am unable to get intellisense to recognize my step defitnitions that reside in the gem. They just show up as 'Undefined steps' inside my feature file. When I debug the project, it runs through the steps with no issue.

I was wondering if there was a specific file structure / naming convention / etc that I need to use in order for Ruby Mine to recognize these step definitions? I tried searching around, but all the exampls I found were for published gems (ex: cucumber, calabash, etc). I tried to mimick their setup with little success.

------------------
For a little clarity, here is an example:

Inside my gem I have these two things in two seperate files:

When (/^"([^"]*)" is visible$/) do |search_text|   
wait_for_element(search_text, 'android.widget.TextView')

    end

    # @param [String] object_id
    # @param [String] object_class
    # @param [String] timeout
    def wait_for_element(object_id, object_class, timeout = 40)
      wait_for_elements_exist([object_class+" marked:'"+object_id+"'"], :timeout => timeout)
    end

    When I install my gem in my other test project, I can see both the files just fine. If I use wait_for_element(), Ruby Mine gives me full intellisense and is able to navigate to the code snippet. However, if I try to use When "Some Text" is visible inside a feature file, the text is highlighted and Ruby Mine marks the step as undefined.
    ----------------

    2) We are exploring the idea of installing a private gem server to host these custom gems. I know Ruby Mine has the ability to build and publish gems, but I didn't see a place to overide where the gems get published too. Is it possible for me to specify our private server instead of rubygems.org?

    I appologize if any of the questions I have posed have already been asked/answered. I thank you for your time and assistance.

    Sincerely,
    Chris

    3 comments
    Comment actions Permalink

    I have spent the last day tying to figure out why canned steps from my custom gem I am building will not show up in auto complete.  I think I have found the unfortunate answer to the problem and will share here so that others will not spin their wheels like I have.

    RubyMine has step definition providers specificly written to certain, published gems.  In a moment of frustration I grepped throug the installed RubyMine files looking for calabash.  I came across a file called plugins/ruby-cucumber/lib/ruby-cucumber.jar.  Within the file manifest I found:

      <extensions defaultExtensionNs="org.jetbrains.plugins.ruby">
        <rake.rakeRunCommandLineModifierProvider implementation="org.jetbrains.plugins.ruby.cucumber.CucumberRakeCommandLineModifierProvider"/>
        <rubyElementNameAndDescriptionProvider
            implementation="org.jetbrains.plugins.ruby.cucumber.CucumberRubyElementNameAndDescriptionProvider"/>
        <cucumberInfoProvider implementation="org.jetbrains.plugins.ruby.cucumber.CucumberInfoProviderImpl"/>
        <runnableScriptFilter implementation="org.jetbrains.plugins.ruby.cucumber.run.CucumberRunnableScriptFilter"/>
        <generatorConfigurator implementation="org.jetbrains.plugins.ruby.cucumber.actions.generators.CucumberGeneratorActionConfigurator"/>

        <generatorAction id="cucumber"
                         actionClass="org.jetbrains.plugins.ruby.cucumber.actions.generators.ConfigureCucumberSupportAction"/>
        <generatorAction id="feature"
                         actionClass="org.jetbrains.plugins.ruby.cucumber.actions.generators.GenerateFeatureAction"/>

        <generatorAction id="cucumber:install"
                         actionClass="org.jetbrains.plugins.ruby.cucumber.actions.generators.ConfigureCucumberSupportAction"/>

        <generatorAction id="cucumber:feature"
                         actionClass="org.jetbrains.plugins.ruby.cucumber.actions.generators.GenerateFeatureAction"/>
        <generatorAction id="cucumber:skeleton"
                         actionClass="org.jetbrains.plugins.ruby.cucumber.actions.generators.ConfigureCucumberSupportAction"/>

        <!--Cucumber step defs libraries provided by gems-->
        <cucumberStepsDefsLibrary implementation="org.jetbrains.plugins.ruby.cucumber.steps.ArubaStepDefsProvider"/>
        <cucumberStepsDefsLibrary implementation="org.jetbrains.plugins.ruby.cucumber.steps.FactoryGirlStepDefsProvider"/>
        <cucumberStepsDefsLibrary implementation="org.jetbrains.plugins.ruby.cucumber.steps.CucumberApiStepDefsProvider"/>
        <cucumberStepsDefsLibrary implementation="org.jetbrains.plugins.ruby.cucumber.steps.JsonSpecStepDefsProvider"/>
        <cucumberStepsDefsLibrary implementation="org.jetbrains.plugins.ruby.cucumber.steps.RailsJqueryAutocomplete"/>
        <cucumberStepsDefsLibrary implementation="org.jetbrains.plugins.ruby.cucumber.steps.CalabashAndroidStepDefsProvider"/>
        <cucumberStepsDefsLibrary implementation="org.jetbrains.plugins.ruby.cucumber.steps.CalabashCucumberStepDefsProvider"/>
      </extensions>

    After seeing this it made sense why Calabash's steps would appear but mine would not.

    The code I am developing will never be published outside of my place of employment.  It would be great to be able to have RubyMine autocomplete our steps that we have pre-built for our organization.  RubyMine supports plugins so is there a document/procedure/recipie for building and configuring my own StepDefProvider plugin so that RubyMine will autocomplete my steps from a gem not listed above?  Is it possible to tell the IDE where to find my steps if I can't do a plugin?

    Thank you in advance!

    Ian

    0
    Comment actions Permalink

    Ian, you are right. At the moment you have to register each gem that had step definition in plugin.xml file. But I'm working on functionality that will allow you use gem with Cucumber step definitions without registration.

    When it ready I inform you.

    0
    Comment actions Permalink

    Chris, can u help about creating gem and use it for project? Can u send me some resource or source code for your own gem?

    0

    Please sign in to leave a comment.