We prepared an application skeleton for you that has a failing test case.
To pass the exercise, follow these steps:
- You need to be logged-in with your Github account.
- Click the "Fork" button in the upper right.
- In your repository's settings, enable issue tracking.
- Log-in to Travis CI and
- Enable automatic builds for your exercise repository.
- Clone the repository to your local machine
- Change into the newly created directoy
- Inside the directory, check the used Ruby version using
ruby --version
. It should be2.2.2
. Other Ruby versions might work, but this is the one that was tested. - If the correct Ruby version is not used, install a ruby version manager, for example rbenv using the instructions for rbenv installation and ruby-build installation.
- WARNING: If you already have the Ruby version manager RVM installed, please use that or uninstall it prior to rbenv installation, as the two version managers are incompatible.
- Install Ruby version 2.2.2 with
rbenv install 2.2.2
- The
.ruby_version
file in the repository instructs the ruby version manager to use the correct version.
- Install Virtualbox (the VM provider) and Vagrant (to manage VMs) for your platform.
- Download the prepared VM image and install the dependencies:
vagrant up # download the image and start the VM
vagrant ssh # connect via ssh
cd hpi-swt2
bundle install # install dependencies
exit # restarting the session for changes to take effect
- In order to start the development server:
vagrant ssh #connect with VM
cd hpi-swt2
rails s -b 0 #starting rails server, the -b part is necessary since the app is running in a VM and would otherwise drop the requests coming from the host OS
- Edits to files in the local folder will be mirrored into the VM's
hpi-swt2
folder as the folders are synced.
- Run
bundle install
to install the dependencies of the project (they are stored in theGemfile
) - Run
rspec
to run the tests (RSpec is a test framework for Ruby) - Try to get the failing test green.
- When you are done, push your changes.
- Travis CI will now try to build your project.
- You will be notified of problems via Github issues.
- While you wait, see if your code can use some refactorings, continue reading the tutorial, or plan the next steps.
- Write a test that documents the missing or failing behavior.
- Unit tests are preferred.
- Commit the failing test and reference the issue.
- The commit message could be
Failing test for #<ISSUE NUMBER>
. - There is no need to push the failing commit.
- The commit message could be
- Fix the issue and commit all changes.
- The commit message could be
<CHANGED THE THING>. Closes #<ISSUE NUMBER>
.
- The commit message could be
Tips:
- This exercise is designed to be solved while reading the official Rails tutorial
- run
rspec spec/<path_to_spec>.rb
to only run one set of specs - have a look at
/spec/factories
to get 'inspiration' for your data model - Besides simple scaffolds, associations and validations are needed ...
- occasionally start up the server (
rails s
) and have a look at the app in your browser (http://localhost:3000
) - Look at the Mockup: https://gomockingbird.com/mockingbird/index.html?project=v890g6l#v890g6l/OQMURm
- Make sure that all local changes are committed (
git status
) and pushed to the upstream repository (i.e., the one on GitHub) before the deadline