Skip to content

Instantly share code, notes, and snippets.

View tochman's full-sized avatar
💭
Coding on my own SaaS project (Rails + React)

Thomas Ochman tochman

💭
Coding on my own SaaS project (Rails + React)
View GitHub Profile
def choices(array)
'[' + array.join('|') + ']'
end
greetings = choices(%w[Hello Hi Hey])
titles = choices(%w[friend dear])
concerns = choices(
[
"are you #{choices(['today', 'these days'])}",
"is your #{choices(%w[sister mother father brother])}"
require 'addressable/uri'
#Accepts options[:message] and options[:allowed_protocols]
class UriValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
uri = parse_uri(value)
if !uri
record.errors[attribute] << generic_failure_message
elsif !allowed_protocols.include?(uri.scheme)
record.errors[attribute] << "must begin with #{allowed_protocols_humanized}"

Capybara

save_and_open_page

Matchers

have_button(locator)
echo "Install and configure github/tochman/website in current dir."
echo "On Ubuntu 13.10 64-bit, clean VM image from "
echo "http://virtualboximages.com/Ubuntu+13.10+amd64+VirtualBox+VDI+Virtual+Appliance"
echo "Dec 31, 2013"
read -p "Hit any key to continue.. "
if [ -d "website" ] ; then
read -p 'Directory ./website exists. Exiting.'
return 0
fi
# RSpec
require 'spec/expectations'
# Webrat
require 'webrat'
require 'test/unit/assertions'
World(Test::Unit::Assertions)
Webrat.configure do |config|