dev branch:
, deployed staging app: Heroku
main branch:
, deployed app: Heroku
A web application for keeping track of items and loaning them out, written in Ruby on Rails. Created in the Scalable Software Engineering course at the HPI in Potsdam.
Branch names have the following structure: <type>/<team>-<issue-number>-<issue-name>
-
<type>gets replaced with feature or fix, depending on the type of changes introduced by the branch -
<team>gets replaced with the abbreviation (e.g. BR) of the team that mostly develops on the branch -
<issue-number>gets replaced with the number of the issue the branch aims to close -
<issue-name>gets replaced with the name of the issue the branch aims to close, or a shortened form of it
Experimental branches may use the structure experimental/<anything>
Ensure you have access to a Unix-like environment through:
- Your local Linux / MacOS installation
- Using the Windows Subsystem for Linux (WSL)
- Using a VM, e.g. Virtualbox and Vagrant
- Using a docker container
ruby --versionEnsure Ruby v2.7.4 using rbenv or RVMsqlite3 --versionEnsure SQLite3 database installationbundle --versionEnsure Bundler installation (gem install bundler)bundle config set without 'production' && bundle installInstall gem dependencies fromGemfilerails db:migrateSetup the database, run migrationsrails assets:precompile && rails sCompile assets & start dev server (default port 3000)bundle exec rspec --format documentationRun the tests (using RSpec framework)
- Stimulus JS as the default JavaScript framework, augmenting HTML (see the handbook and this detailed post for an introduction or have a look at #66)
- Bootstrap for layout, styling and icons
- Devise library for authentication
- FactoryBot to generate test data
- Capybara for feature testing
- shoulda for additional RSpec matchers
bundle exec rails db:migrate RAILS_ENV=development && bundle exec rails db:migrate RAILS_ENV=testMigrate both test and development databasesrails assets:clobber && rails assets:precompileRedo asset compilation
bundle exec rspecRun the full test suite--format docMore detailed test output-e 'search keyword in test name'Specify what tests to run dynamically--exclude-pattern "spec/features/**/*.rb"Exclude feature tests (which are typically fairly slow)
bundle exec rspec spec/<rest_of_file_path>.rbSpecify a folder or test file to runbundle exec rspec --profileExamine run time of tests- Code coverage reports are written to
coverage/index.htmlafter test runs (by simplecov)
bundle exec rubocopUse the static code analyzer RuboCop to find possible issues (based on the community Ruby style guide).--autocorrectto fix what can be fixed automatically.- RuboCop's behavior can be controlled using
.rubocop.yml
You can put the following script in .git/hooks/pre-commit to run RuboCop before each commit (run chmod +x .git/hooks/pre-commit to make it executable):
#!/bin/bash
# Exit if one of the following commands fails
set -e
# The branch we want to diff against
BASE=$(git merge-base origin/dev HEAD)
# Find all changed ruby files
FILES=$(git diff --name-only --diff-filter=d ${BASE} HEAD '*.rb')
# Execute Linters
bundle exec rubocop --force-exclusion --parallel $FILESdebuganywhere in the code to access an interactive consolesave_and_open_pagewithin a feature test to inspect the state of a webpage in a browserrails c --sandboxTest out some code in the Rails console without changing any datarails dbconsoleStarts the CLI of the database you're usingbundle exec rails routesShow all the routes (and their names) of the applicationbundle exec rails aboutShow stats on current Rails installation, including version numbers
rails g migration DoSomethingCreate migration _db/migrate/*DoSomething.rbrails generatetakes a--pretend/-poption that shows what will be generated without changing anything