Skip to content

Instantly share code, notes, and snippets.

View jwood's full-sized avatar

John Wood jwood

View GitHub Profile
@jwood
jwood / tenacity_example.rb
Created December 24, 2010 15:12
An example using the Tenacity gem
class Car
include MongoMapper::Document
include Tenacity
t_has_many :wheels
t_has_one :dashboard
end
class Wheel < ActiveRecord::Base
include Tenacity
@jwood
jwood / fetch_pgbackups.rb
Created November 17, 2010 14:28
Create a pgbackup on Heroku for a given project, and then download it for local storage
#!/usr/bin/ruby
#
# This script assumes that you have either 0 or 1 pgbackups stored
# on Heroku, and that you already have the heroku gem installed
# and configured on your system.
#
PROJECT_DIRECTORY = "/home/jwood/dev/myproj"
BACKUP_FILE = "/home/jwood/backup/myproj.dump"
@jwood
jwood / backup.rb
Created July 12, 2010 18:35
A simple backup script that FTPs files to some safe place
#!/usr/bin/ruby
#
# Usage: ftp-backup.rb <directory> <filename>
# Example: ftp-backup.rb /home/jwood/backup/ my_important_file
require 'net/ftp'
NUM_BACKUPS = 7
directory_name = ARGV[0]
@jwood
jwood / account.rb
Created July 10, 2015 13:57
Rails uniqueness validation
class Account < ActiveRecord::Base
validates :email, uniqueness: true
end
require "rails_helper"
class CompanyOfficePage < SitePrism::Page
set_url "/company"
element :select_office, ".select-office"
element :office_name, "#office-name"
element :save_office_button, "#save-office-btn"
element :company_tasks, ".company-tasks"
element :company_faqs, ".company-faqs"
require "rails_helper"
feature "Company/Office page spec", js: true do
let(:company) { FactoryGirl.create(:company) }
let(:employee) { FactoryGirl.create(:employee, full_city: "Chicago, IL", company: company) }
let!(:office_1) { FactoryGirl.create(:office, company: company, address: FactoryGirl.attributes_for(:chicago_address)) }
let!(:office_2) { FactoryGirl.create(:office, company: company, address: FactoryGirl.attributes_for(:chicago_address)) }
let!(:office_task) { FactoryGirl.create(:task, company: company, office: office_1) }
let!(:office_faq) { FactoryGirl.create(:faq, company: company, office: office_1) }
SitePrism.configure do |config|
config.use_implicit_waits = true
end
my_page_object.wait_until_blah_visible
expect(page).to have_selector("#blah", visible: true)
expect(my_page_object).to have_blah