Cool tests in the Java Maven platform now possible with rspec-maven-plugin

I don’t like Maven at all but sometimes depending of the project and the people you need to use this. After playing with RSpec I stop considering any Java language framework acceptable for testing so for this project I’m working on right now I needed to find a solution that could integrate RSpec with Maven.

After googling I found this post from Bob McWhirter where he presented a official rspec-maven-plugin. I tried to use it but it wasn’t working so I forked it, fixed it and changed some things.

The forked version of rspec-maven-plugin is at GitHub and to use it you should:

install the plugin in the local repository (this is necessary only one time):

git clone git://github.com/dcrec1/rspec-maven-plugin.git
cd rspec-maven-plugin
mvn install

configure your project’s pom.xml adding this:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>rspec-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>test</id>
            <phase>test</phase>
            <goals>
                <goal>spec</goal>
            </goals>
        </execution>
    </executions>
</plugin>

set the JRUBY_HOME system variable, for example:

export JRUBY_HOME=/opt/jruby-1.1.6/

The plugin will run in the test phase of the Maven build cycle.

Happy testing!

18 thoughts on “Cool tests in the Java Maven platform now possible with rspec-maven-plugin

    • Thank you for taking the time to work on this pgliun.. It’s *almost* exactly what I need. I plan on adding some shortcode options to it, but I’m having trouble getting started. It worked okay on a live, not-music-related blog, but I can’t do the dev there. I’ve been working on a new blog using a local install, but there is an error message I’m having trouble getting past:Warning: array_pop() [function.array-pop]: The argument should be an array in C:\Documents and Settings\…\public_html\wp-content\plugins\discography\discography.php on line 25It also errors on the other lines where the following code is present:ereg(‘/wp\-content/plugins/(.*)/discography\.php’, __FILE__, $folder);$folder = get_bloginfo(‘wpurl’) . ‘/wp-content/plugins/’ . array_pop($folder) . ‘/’;I’ve tried commenting out the ereg function and changing the $folder var to eliminate the array_pop function and instead write /plugins/discography.php/ it didn’t work. What am I missing here, or is it just not possible on a local install?Apache 2.2.3PHP 5.2MySQL: 5.0.27Wordpress: 2.6.2Running on a local dev install on Windows XP.

    • This is good. It will drive more people to youutbe to watch Michael Jackson, Jay-Z, Tyler The Creator, Ray William Johnson, And SxEPhil who pay the bills. And leave the rest of us the “F” alone to make creative content, that doesn’t pander to the lowest common denominator – that is the key to success in media.

  1. Hello,

    I got following error when executing this on win 7.
    Is this pluging not supporting win os, or what could be the problem?
    Have not tried on linux.

    regards, Matti

    [INFO] — rspec-maven-plugin:1.0-beta-6:spec (test) @ vse_mppscripts —
    [INFO] Running RSpec tests from D:\subversion\vse\vse_mppscripts\test\
    [ERROR] error emitting .sh
    java.lang.NullPointerException
    at org.codehaus.mojo.rspec.ShellScriptFactory.getScript(ShellScriptFactory.java:26)
    at org.codehaus.mojo.rspec.AbstractScriptFactory.emit(AbstractScriptFactory.java:44)
    at org.codehaus.mojo.rspec.RspecRunnerMojo.execute(RspecRunnerMojo.java:120)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)

    • I foresee futrehr deterioration of the medium, with advertising overpowering the screen, to the likes of which can only be imagined. If you find the current watermarks and pop-ups on cable TV annoying, you ain’t seen nothin’ yet. The big advertising companies will ruin YouTube unless Google sets some guidelines. Unfortunately, their management of Android has been pretty lacking, and I don’t see YouTube being any better. The stock market’s respons to this news does not appear to be favourable. The stock closed at $600 on Friday and opened at $579, today.

    • Hey, how’d you get this plugin to keep wokinrg in WP 2.0.2? Are you using a PHP plugin to run the code within a WP page? I’m running Exec-PHP 2.0 and 1.5, but it’s puking for me.If you’re wondering why I’m asking, I was reading the latest comments in that plugin post, and saw that you might’ve modified it.Thanks!

  2. I got the NPE also. It is caused by a bug in the rspec-maven-plugin. It expects that there is always at least one systemproperty setting in the configuration. Workaround:


    org.codehaus.mojo
    rspec-maven-plugin


    ${env.JRUBY_HOME}

    ${basedir}/src/test/specs

    ${basedir}/target

    true

    • hi, I try to give a feedback to youtbue, but this is frustrating, all the help forum contact us, I just can’t find a email address or mail form to specific reception to send my idea or suggestion. shouldn’t this works as a operator forward my message to relate department? I strongly suggest that a floating feedback link at the corner at every page just like google+ besides just report a bug.

    • using safari and fierfox on macintosh ox 10.5.5 and I can not figure out how to get the songs to show up in the song list. I don’t have a little add sign anywhere. I’ve made pages and put them in media library and everything. help. this is exactly what we need.

  3. Darn, my response was broken by apparently the blogging tool used by this site. Anyway, to fix the NPE add a configuration under rspec-maven-plugin, put systemproperties under it and put any value there.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">