Skip to content
Thuy Le edited this page Apr 22, 2016 · 6 revisions

We use Rspec, Capybara, FactoryGirl & Poltergeist for testing and Pry for debugging. If you are new to Test Driven Development (TDD), welcome & thank you! Here are some helpful infos.

1. Directories:

You can find the folders to test in this directory:

https://github.com/sozialhelden/wheelmap/tree/master/spec
.
├── controllers
├── factories
├── features
├── fixtures
├── helpers
├── importer
├── jobs
├── mailers
├── models
├── rails_helper.rb
├── shared_context
├── spec_helper.rb
├── teaspoon_env.rb
├── validators
└── views

2. How to:

Rspec

If you want to run the test for all files of our wheelmap app, do:

$ bundle exec rake spec

If you want to run the test for only the spec folder (with all the files in it), do:

$ bundle exec rspec spec

If you are in the root directory and want to run the test for only single files, do:

$ bundle exec rspec spec/foldername/filename.rb

If you are in the root directory and want to run the test in a single file at line 34, do:

$ bundle exec rspec spec/foldername/filename.rb:34

If you are in the same directory where the file is located, then just run:

$ bundle exec rspec filename.rb

Pry

If you want to debug to find out why something doesn't work, add following code snippets:

require 'pry' (at the top of each file)
binding.pry (at the place where you need to inspect the file)

Then run the file again if you are in the root directory:

$ bundle exec rspec spec/foldername/filename.rb

As soon as Rspec hits the line where binding.pry is executed, it will set a break point. At this line you can start to work on the console with pry and test the line interactively.

Note: You can set as many break points as you like, it will stop at each point. If you have multiple break points in your file, just run exitin the console and it will bring you to the next break point.