Skip to content

Instantly share code, notes, and snippets.

View pjmelling's full-sized avatar

Peter Melling pjmelling

View GitHub Profile
@pjmelling
pjmelling / gist:2320447fb10581c75fd22d9b9977cf1b
Created July 17, 2017 20:11
print browser errors from within a rspec with capybara test
puts page.driver.browser.manage.logs.get('browser')
@pjmelling
pjmelling / capybara cheat sheet
Created July 7, 2017 22:06 — forked from zhengjia/capybara cheat sheet
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@pjmelling
pjmelling / relativeUrl.js
Created January 26, 2017 20:03 — forked from tkw1536/relativeUrl.js
Resolve a relative URL in client-side JavaScript with jQuery.
/*
Resolves a relative url
@param url Url to resolve
@param base Optional. Base url to use.
@param isDir Optional. If set to true, will return a directory name ending with a slash.
*/
var resolve = function(url, base, isDir){
var resolveWithBase = false;
var baseUrl, oldBase, newBase;
@pjmelling
pjmelling / random_base_36.rb
Created March 23, 2016 15:09
random_base_36.rb
length = 8
(36**(length-1) + rand(36**length - 36**(length-1))).to_s(36).upcase