Skip to content

Latest commit

History

History
77 lines (56 loc) 路 2.56 KB

File metadata and controls

77 lines (56 loc) 路 2.56 KB

Ruby on Rails 4.2 docker-compose example project

I wanted to run tests and have breakpoints in RubyMine in a Ruby on Rails 4.2 application running inside docker-compose. Current code base is based on the sample project Rails Stripe Membership Saas. I added docker-compose support and RubyMine setup instructions 馃帀.

Getting started

cp .env.test .env
docker-compose up -d
docker-compose exec web bundle exec rake db:migrate

RubyMine

I created this project to demonstrate how to run tests inside Docker using RubyMine IDE or IntellijIdea.

Important files

What to add to your Gemfile:

group :development, :test do
  gem 'ruby-debug-ide'
  gem 'debase'
end

I personally had to also maintain local versions of gems for the ruby-debug-ide gem to get loaded into the IDE. This repository has a .ruby-version which is used by rbenv.

rbenv installation commands on MacOS:

brew install rbenv ruby-build ruby
rbenv init

For the current repository:

rbenv install
rbenv version
rbenv local
gem install bundler
bundle install

RubyMine step by step

Edit: 馃敶 This is not working on Intellij IDEA, ruby is being ran locally on my system instead. See #1

Tested on RubyMine 2017.3.2 EAP 馃憤.

  1. Open settings -> Ruby SDK and Gems -> Add (+)
  2. Select docker-compose, setup Docker server and select web service (from docker-compose file)

01-configure-remote-debug-interpreter-docker-compose 02-ruby-sdk-and-gems 3. Right click on a test to add as a run configuration 03-right-click-add-test 4. Tweak the run configuration by adding environment variables. Hint on macos:

cat .env | pbcopy

Then hit the clipboard icon to paste all env variables at the same time 04-edit-run-configuration 5. Execute the run configuration in debug mode 鉁岋笍 05-successful-test-with-breakpoint

License

MITGabriel Le Breton