Skip to content

Instantly share code, notes, and snippets.

@GKhalsa
Forked from rrgayhart/1602-testing-homework.markdown
Last active July 3, 2016 22:44
Show Gist options
  • Save GKhalsa/71778fe11f30c1abb8dae1fd86e44931 to your computer and use it in GitHub Desktop.
Save GKhalsa/71778fe11f30c1abb8dae1fd86e44931 to your computer and use it in GitHub Desktop.
Testing Homework

Testing Homework - Rails/JS

  • Your experience implementing

I chose to feature test by using webkit. Adding wait for ajax and database cleaner was relatively painless. Lot's of small issues, but once I got the syntax right and in the right place it was fine.

  • Were you successful?

I was successfull

  • Links to commits on Github or copy and pasted code snippits of a test
require "rails_helper"

feature "user can add idea", :js => true do
   scenario "the page displays the idea" do
     visit "/"

     expect(page).to_not have_content("Cool Title")
     expect(page).to_not have_content("Cool Body")
     expect(page).to have_selector('li', count: 0)

     fill_in 'Title', with: "Cool Title"
     fill_in 'Body', with: "Cool Body"
     click_on('Save')
     wait_for_ajax

     expect(page).to have_content('Cool Title')
     expect(page).to have_content('Cool Body')
     expect(page).to have_selector('li', count: 1)
   end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment