Skip to content

Instantly share code, notes, and snippets.

@balexand
balexand / Screenshot with phantomjs
Created April 23, 2012 17:02
screenshot.coffee
# install phantomjs using Homebrew (http://mxcl.github.com/homebrew/)
# by running `brew install phantomjs` then run this script with `phantomjs screenshot.coffee`
page = require('webpage').create()
page.viewportSize = { width: 768, height: 600 }
page.open 'http://bridgidgallagher.com/blog', (status) ->
console.log status
window.setTimeout ->
console.log "render"
@balexand
balexand / pages_spec.rb
Created July 24, 2011 01:30
Test both Ajax and Javascript-disabled version with the same test using RSpec, Capybara, and Selenium
describe "Pages" do
# a trivial example that follows a link from "Page A" to "Page B"
shared_examples "an example page" do
it "should follow link from Page A to Page B" do
visit page_a_path
click_link "Link to B"
page.should have_content("Page B")
current_path.should == page_b_path
end
# when I call Thing.count, it works and DISTINCT records are selected
# when I call Thing.scoped.count (or any other query), it doesn't work
class Thing < ActiveRecord::Base
class << self
def count_with_distinct
count_without_distinct(:distinct => true)
end
alias_method_chain :count, :distinct
end