This Rails and React application is the starting point for our Voting app interview exercise. You may not need all the various files included to complete the assignment, but they are here in case they help you move faster! Please modify anything you need to in order to meet the requirements and show us your own approach.
Your development environment should have:
Initialize git, install the application, and initialize the database:
# First, download the zip file, unzip the directory,
# and navigate into the project directory. Then:
git init
git add .
git commit -m "Initial files provided"
bundle install
bundle exec rake db:migrate
# Install JS packages, including React
yarn install
bundle exec rails server
Visit http://localhost:3000 in your browser
For asset live reloading, run:
./bin/shakapacker-dev-server
If the assets ever get out of sync, delete /public/packs
and restart your
Rails server (and your shakapacker-dev-server if it was running).
The included test suite uses Rspec and Capybara.
Check out spec/requests/
for example tests.
# Run all tests
bundle exec rspec
# Run one test file
bundle exec rspec <path/to/the/file.rb>
# Run one test case inside a test file
bundle exec rspec <path/to/the/file.rb>:<line_number>
bundle exec rails console
You can open up a debugging console by adding binding.pry
anywhere in test or
application code.
Example:
def show
binding.pry
render json: { data: @my_object }, status: :ok
end
In this example, when the show
method is hit during click testing or a test,
a debugger will open up in the terminal, where you can inspect values:
@my_object.id
@my_object.valid?
Step to the next line with next
. Resume regular code execution or tests with
continue
.