Skip to content

Commit

Permalink
[JENKINS-48116] Smoke test for the rvm plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Nov 21, 2017
1 parent 76d4c8c commit 3b8f705
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/main/java/org/jenkinsci/test/acceptance/plugins/rvm/Rvm.java
@@ -0,0 +1,41 @@
/*
* The MIT License
*
* Copyright 2017 CloudBees, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package org.jenkinsci.test.acceptance.plugins.rvm;

import org.jenkinsci.test.acceptance.po.BuildWrapper;
import org.jenkinsci.test.acceptance.po.Control;
import org.jenkinsci.test.acceptance.po.Job;

/** "Run the build in a RVM-managed environment" */
public class Rvm extends BuildWrapper {

/** "Implementation" */
public final Control implementation = control("impl");

public Rvm(Job context) {
super(context, "/rvm-RvmWrapper");
}

}
52 changes: 52 additions & 0 deletions src/test/java/plugins/RvmPluginTest.java
@@ -0,0 +1,52 @@
/*
* The MIT License
*
* Copyright 2017 CloudBees, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/

package plugins;

import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.*;
import org.jenkinsci.test.acceptance.junit.AbstractJUnitTest;
import org.jenkinsci.test.acceptance.junit.WithPlugins;
import org.jenkinsci.test.acceptance.plugins.rvm.Rvm;
import org.jenkinsci.test.acceptance.po.Build;
import org.jenkinsci.test.acceptance.po.FreeStyleJob;
import org.jenkinsci.test.acceptance.po.ShellBuildStep;
import org.junit.Test;

@WithPlugins("rvm")
public class RvmPluginTest extends AbstractJUnitTest {

@Test
public void smokes() throws Exception {
FreeStyleJob job = jenkins.jobs.create();
job.configure();
// Could also use "jruby", though it seems to be more intrusive (tries to install openjdk-jre-headless).
job.addBuildWrapper(Rvm.class).implementation.set("2.4.2");
job.addBuildStep(ShellBuildStep.class).command("ruby --version");
job.save();
Build build = job.startBuild().shouldSucceed();
assertThat(build.getConsole(), containsString("ruby 2.4.2"));
}

}

0 comments on commit 3b8f705

Please sign in to comment.