Skip to content

Instantly share code, notes, and snippets.

John Wood jwood

Block or report user

Report or block jwood

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:1261c2b4fbd1451d8a02
Installing cocaine 0.5.7
Installing crack 0.4.2
Installing chronic 0.10.2
Installing hitimes 1.2.2 with native extensions
Installing bourbon 4.2.3
@jwood
jwood / questions.rake
Created Jul 13, 2015
Example of rake task that migrates production data
View questions.rake
namespace :question do
desc "Update Questions and Tasks to support newly added validations"
task :update_for_validations => :environment do
ActiveRecord::Base.transaction do
# Set question_type to "yesno" for following questions:
%w(need_long_term_rental need_short_term_rental find_eye_doctor cleaning need_home).each do |identifier|
q = Question.find_by_identifier(identifier)
q.update_attributes!(question_type: "yesno") if q.present?
end
@jwood
jwood / account.rb
Created Jul 10, 2015
Rails uniqueness validation
View account.rb
class Account < ActiveRecord::Base
validates :email, uniqueness: true
end
View site_prism_spec.rb
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"
View capybara_spec.rb
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) }
View site_prism_implicit_waits.rb
SitePrism.configure do |config|
config.use_implicit_waits = true
end
View capybara_visibility.rb
expect(page).to have_selector("#blah", visible: true)
@jwood
jwood / css_existence.rb
Last active Aug 29, 2015
Testing for existence using CSS
View css_existence.rb
expect(page).to have_css("#blah")
You can’t perform that action at this time.