Skip to content

Instantly share code, notes, and snippets.

View kyleroberthammond's full-sized avatar

Kyle Hammond kyleroberthammond

View GitHub Profile
@kyleroberthammond
kyleroberthammond / test.html
Created February 18, 2019 19:18
Hello World Html
<html>
<head>
<style>
h1 {
font-family: Calibri;
}
</style>
</head>
<body>
<h1>Hello World!</h1>
@kyleroberthammond
kyleroberthammond / test.md
Created February 18, 2019 19:18
Hello World Markdown

Hello World

This is content converted from Markdown!

Here's a JSON sample:

{
  "foo": "bar"
}
@kyleroberthammond
kyleroberthammond / gist:a544e0a4ee5f6380b6a22698fb585ba6
Created October 21, 2016 15:05
Test Dropzone.js File Uploads With Capybara
Test Dropzone.js File Uploads With Capybara
Dec 29, 2014
Integration tests involving complex JS interactions are a pain, especially with something like drag and drop file uploads (you can’t exactly drag something into a headless browser). My recent use case was an AngularJS application using Dropzone.js with Ruby on Rails on the backend, so I needed a way to make Dropzone play nicely with Capybara Webkit. Here is the spec helper I ended up with:
def drop_in_dropzone(file_path)
# Generate a fake input selector
page.execute_script <<-JS
fakeFileInput = window.$('<input/>').attr(
{id: 'fakeFileInput', type:'file'}
@kyleroberthammond
kyleroberthammond / gist:c86282b01254491309d3171d821a9ba0
Created October 21, 2016 15:05
Test Dropzone.js File Uploads With Capybara
Test Dropzone.js File Uploads With Capybara
Dec 29, 2014
Integration tests involving complex JS interactions are a pain, especially with something like drag and drop file uploads (you can’t exactly drag something into a headless browser). My recent use case was an AngularJS application using Dropzone.js with Ruby on Rails on the backend, so I needed a way to make Dropzone play nicely with Capybara Webkit. Here is the spec helper I ended up with:
def drop_in_dropzone(file_path)
# Generate a fake input selector
page.execute_script <<-JS
fakeFileInput = window.$('<input/>').attr(
{id: 'fakeFileInput', type:'file'}
Debugging Capybara
"save_and_open_page"
@kyleroberthammond
kyleroberthammond / gist:2952f3772d95f1126533794c44870571
Created April 6, 2016 02:06
Previous Path / Get path helper name of a url
Rails.application.routes.recognize_path(request.referrer) #=> {:controller => "posts", :action => "show"}
prev[:action] #=> "show"
prev = Rails.application.routes.recognize_path(request.referrer)
prev[:controller] #=> "posts"
To only run the next two migrations:
rake db:migrate STEP=2
To revert the previous two migrations:
rake db:rollback STEP=2
To revert the last two migrations and then migrate to the most current version:
rake db:migrate:redo STEP=2
To migrate to a given migration number, regardless of whether that means migrating up or down: