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 🎉.
cp .env.test .env
docker-compose up -d
docker-compose exec web bundle exec rake db:migrate
I created this project to demonstrate how to run tests inside Docker using RubyMine IDE or IntellijIdea.
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
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 👍.
- Open settings -> Ruby SDK and Gems -> Add (+)
- Select docker-compose, setup Docker server and select
web
service (from docker-compose file)
3. Right click on a test to add as a run configuration 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 5. Execute the run configuration in debug mode ✌️