Navigation Menu

Skip to content

Commit

Permalink
New Cucumber feature: testing a Ruby project with a given JDK version.
Browse files Browse the repository at this point in the history
  • Loading branch information
loicfrering committed May 24, 2012
1 parent 134e1b8 commit 336cb63
Show file tree
Hide file tree
Showing 2 changed files with 157 additions and 4 deletions.
152 changes: 152 additions & 0 deletions features/test_ruby_with_given_jdk_version.feature
@@ -0,0 +1,152 @@
Feature: Testing a Ruby project with a given JDK version

Background:
Given the following test payload
| repository | travis-ci/travis-ci |
| commit | 1234567 |
| config | rvm: 1.9.2, jdk: openjdk6, env: FOO=foo, gemfile: gemfiles/Gemfile |

Scenario: A successful build
When it starts a job
Then it exports the given environment variables
And it successfully clones the repository to the build dir with git
And it successfully checks out the commit with git to the repository directory
And it exports the line TRAVIS_JDK_VERSION=openjdk6
And it exports the line TRAVIS_RUBY_VERSION=1.9.2
And it successfully switches to the jdk version: openjdk6
And it announces active jdk version
And it successfully switches to the ruby version: 1.9.2
And it announces active ruby version
And it does not find the file gemfiles/Gemfile
And it successfully runs the script: rake
And it closes the ssh session
And it returns the result 0
And it has captured the following events
| name | data |
| job:test:start | started_at: [now] |
| job:test:log | log: /Using worker/ |
| job:test:log | log: cd ~/builds |
| job:test:log | log: export FOO=foo |
| job:test:log | log: git clone |
| job:test:log | log: cd travis-ci/travis-ci |
| job:test:log | log: git checkout |
| job:test:log | log: /export TRAVIS_JDK_VERSION=openjdk6/ |
| job:test:log | log: /export TRAVIS_RUBY_VERSION=1.9.2/ |
| job:test:log | log: sudo jdk-switcher use openjdk6 |
| job:test:log | log: java -version |
| job:test:log | log: javac -version |
| job:test:log | log: rvm use 1.9.2 |
| job:test:log | log: ruby --version |
| job:test:log | log: gem --version |
| job:test:log | log: rake |
| job:test:log | log: /Done.* 0/ |
| job:test:finish | finished_at: [now], result: 0 |

Scenario: A successful build with a Gemfile
When it starts a job
Then it exports the given environment variables
And it successfully clones the repository to the build dir with git
And it successfully checks out the commit with git to the repository directory
And it exports the line TRAVIS_JDK_VERSION=openjdk6
And it exports the line TRAVIS_RUBY_VERSION=1.9.2
And it successfully switches to the jdk version: openjdk6
And it announces active jdk version
And it successfully switches to the ruby version: 1.9.2
And it announces active ruby version
And it finds a file gemfiles/Gemfile and successfully installs dependencies with bundle
And it successfully runs the script: bundle exec rake
And it closes the ssh session
And it returns the result 0
And it has captured the following events
| name | data |
| job:test:start | started_at: [now] |
| job:test:log | log: /Using worker/ |
| job:test:log | log: cd ~/builds |
| job:test:log | log: export FOO=foo |
| job:test:log | log: git clone |
| job:test:log | log: cd travis-ci/travis-ci |
| job:test:log | log: git checkout |
| job:test:log | log: /export TRAVIS_JDK_VERSION=openjdk6/ |
| job:test:log | log: /export TRAVIS_RUBY_VERSION=1.9.2/ |
| job:test:log | log: sudo jdk-switcher use openjdk6 |
| job:test:log | log: java -version |
| job:test:log | log: javac -version |
| job:test:log | log: rvm use 1.9.2 |
| job:test:log | log: ruby --version |
| job:test:log | log: gem --version |
| job:test:log | log: /export BUNDLE_GEMFILE=/ |
| job:test:log | log: bundle install |
| job:test:log | log: bundle exec rake |
| job:test:log | log: /Done.* 0/ |
| job:test:finish | finished_at: [now], result: 0 |

Scenario: The repository can not be cloned
When it starts a job
Then it exports the given environment variables
And it fails to clone the repository to the build dir with git
And it closes the ssh session
And it returns the result 1

Scenario: The commit can not be checked out
When it starts a job
Then it exports the given environment variables
And it successfully clones the repository to the build dir with git
And it fails to check out the commit with git to the repository directory
And it closes the ssh session
And it returns the result 1

Scenario: The jdk version can not be activated
When it starts a job
Then it exports the given environment variables
And it successfully clones the repository to the build dir with git
And it successfully checks out the commit with git to the repository directory
And it exports the line TRAVIS_JDK_VERSION=openjdk6
And it exports the line TRAVIS_RUBY_VERSION=1.9.2
And it fails to switch to the jdk version: openjdk6
And it closes the ssh session
And it returns the result 1

Scenario: The ruby version can not be activated
When it starts a job
Then it exports the given environment variables
And it successfully clones the repository to the build dir with git
And it successfully checks out the commit with git to the repository directory
And it exports the line TRAVIS_JDK_VERSION=openjdk6
And it exports the line TRAVIS_RUBY_VERSION=1.9.2
And it successfully switches to the jdk version: openjdk6
And it announces active jdk version
And it fails to switch to the ruby version: 1.9.2
And it closes the ssh session
And it returns the result 1

Scenario: The bundle can not be installed
When it starts a job
Then it exports the given environment variables
And it successfully clones the repository to the build dir with git
And it successfully checks out the commit with git to the repository directory
And it exports the line TRAVIS_JDK_VERSION=openjdk6
And it exports the line TRAVIS_RUBY_VERSION=1.9.2
And it successfully switches to the jdk version: openjdk6
And it announces active jdk version
And it successfully switches to the ruby version: 1.9.2
And it announces active ruby version
And it finds a file gemfiles/Gemfile but fails to install dependencies with bundle
And it closes the ssh session
And it returns the result 1

Scenario: The build fails
When it starts a job
Then it exports the given environment variables
And it successfully clones the repository to the build dir with git
And it successfully checks out the commit with git to the repository directory
And it exports the line TRAVIS_JDK_VERSION=openjdk6
And it exports the line TRAVIS_RUBY_VERSION=1.9.2
And it successfully switches to the jdk version: openjdk6
And it announces active jdk version
And it successfully switches to the ruby version: 1.9.2
And it announces active ruby version
And it does not find the file gemfiles/Gemfile
And it fails to run the script: rake
And it closes the ssh session
And it returns the result 1

9 changes: 5 additions & 4 deletions lib/travis/build/job/test/ruby.rb
Expand Up @@ -13,13 +13,14 @@ class Config < Hashr

def setup
super
setup_ruby
announce_ruby
setup_bundler if uses_bundler?

if !!config[:jdk]
setup_jdk
end

setup_ruby
announce_ruby
setup_bundler if uses_bundler?
end

def install
Expand Down Expand Up @@ -51,8 +52,8 @@ def announce_ruby
end

def export_environment_variables
shell.export_line("TRAVIS_RUBY_VERSION=#{config.rvm}")
export_jdk_environment_variables if !!config[:jdk]
shell.export_line("TRAVIS_RUBY_VERSION=#{config.rvm}")
end
end
end
Expand Down

0 comments on commit 336cb63

Please sign in to comment.