Skip to content

Instantly share code, notes, and snippets.

@jwashke
Forked from rrgayhart/1602-testing-homework.markdown
Last active July 4, 2016 22:32
Show Gist options
  • Save jwashke/8a819cedd0ed3cf9965e631e7af8027b to your computer and use it in GitHub Desktop.
Save jwashke/8a819cedd0ed3cf9965e631e7af8027b to your computer and use it in GitHub Desktop.
Testing Homework

Testing Homework - Rails/JS

  • Choose one of the following tracks:
  • Skim/Read through the associated links
  • Attempt to hook up and implement unit or feature js tests in your IdeaBox or this sample idea-bin project
  • Fork this gist
  • Respond with:
    • Your experience implementing
    • Were you successful?
    • Links to commits on Github or copy and pasted code snippits of a test

My experience

I tried to feature test my idea box using capybara and selenium, and then I tried webkit and poltergeist too. At first I tried testing a user can see the index of ideas, but that wasn't successful. The ideas weren't showing on the page. I thought this might have something to do with using factory girl and my database being different for JS tests. So i switched to a test for user creating an idea. That still didn't work. Ultimately it seems like my ajax calls just are not firing in my tests, I used wait for ajax detailed by thoughtbot, and confirmed it was running with byebug, but still nothing happened in the firefox window that popped up.

Was I successful?

Yes and no, I never figured out how to get AJAX working in the test, but wednesday I rewrote my app, originally it was wiping the screen and refetching through ajax on every change the user made. I rewrote it to keep the state of the app in JS on the front end and only fetch data on the first page load. This allowed me to use the feature testing without relying on the ajax request for that initital load. Still annoyed I couldn't get AJAX working though.

Code

My first test that could not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment