This repo is a copy of the example branch from the Week 4 Hacker News project. It includes a full set of feature tests.
Your task is to "AJAXify" the process of submitting a new comment (i.e. it should not cause a new page load), while keeping the rest of the app the same. All feature tests should still pass! Make sure you're inserting the new comment at the correct position in the list, given that comments are sorted by score.
To allow our feature tests to use JavaScript, we'll need to make some changes. These have already been made in this repository (and in the player tracker demo you should be using as a reference for setting up TDD Rails projects), but they are listed here for reference.
- Install PhantomJS (one-time, like installing Postgres)
- Mac:
brew install phantomjs
- Ubuntu:
sudo apt-get install phantomjs
- Install Poltergeist
- Add
gem 'poltergeist'
to the:test
group in theGemfile
- In
rails_helper.rb
, add:require 'capybara/poltergeist'
- In
rails_helper.rb
, add:Capybara.javascript_driver = :poltergeist
- Ensure
database_cleaner
is configured to use truncation for specs tagged:js
(our standard configuration file atspec/support/database_cleaner.rb
already does this)
- In
user_creates_comment_spec.rb
, changecontext 'when signed in' do
tocontext 'when signed in', :js do
. This tells RSpec to run the tests within this block using the configuredCapybara.javascript_driver
instead of the default driver. Runrspec
and you should see all the tests still passing.