This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generate a password that is 8 - 20 characters in length, and which contains at least one number and one special character | |
# Requires Ruby >= 1.9 | |
def random_password | |
specials = ((32..47).to_a + (58..64).to_a + (91..96).to_a + (123..126).to_a).pack('U*').chars.to_a | |
numbers = (0..9).to_a | |
alpha = ('a'..'z').to_a + ('A'..'Z').to_a | |
%w{i I l L 1 O o 0}.each{ |ambiguous_character| | |
alpha.delete ambiguous_character | |
} | |
characters = (alpha + specials + numbers) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Then /^I should see each item listed in alphabetical order in the items section$/ do | |
@items.each_with_index do |item, index| | |
find(:xpath, "//*[@id='items']/ul[@class='items']/li[#{index+1}]").inspect.should eq(find("li#item-#{item.friendly_id}").inspect) | |
@item = item | |
step "I should see the item listed in the items section" | |
end | |
end | |
Then /^I should( not)? see the item listed in the items section$/ do |negation| | |
assertion = negation ? :should_not : :should |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# GENERAL COMMANDS | |
alias l='ls -AHhlp' | |
alias c='clear' | |
alias cx='chmod +x' | |
alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'" | |
alias reload='source ~/.bash_profile' | |
alias release='xattr -d com.apple.quarantine' | |
alias flushdns='sudo discoveryutil udnsflushcaches' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A contrived example | |
def a (dividend, divisor) | |
puts "-- Entering!" | |
if dividend >= 5 | |
puts "-- Dividend >= 5!" | |
begin | |
puts "-- Beginning!" | |
puts "-- #{dividend.to_i / divisor.to_i}" | |
rescue => e | |
puts "-- Exception! #{e}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if Rails.env.development? | |
# Make sure we preload the parent and children class in development | |
# since classes aren't pre-cached. Otherwise we get an error when | |
# accessing a child class before we access the parent. | |
%w[kase coaching_kase training_kase alpha_kase].each do |c| | |
require_dependency File.join("app","models","#{c}.rb") | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% | |
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : "" | |
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}" | |
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip" | |
%> | |
default: <%= std_opts %> features | |
wip: --drb -tags @wip:3 --wip features | |
autotest: --drb --color --format progress --strict | |
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assumes you have a factory named :customer defined with attributes first_name and last_name | |
Feature: Testing customized factory_girl step definitions | |
As an open source advocate | |
I | |
Want to make sure that my customized step definitions don't throw any errors | |
Scenario: Generating factories from a table | |
Given the following customers exist: | |
| first_name | last_name | | |
| Bob | Smith | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Recursively `tail` new and changed files | |
# See https://gist.github.com/1313404#file_watch_recursive.sh for usage | |
watch -d -n 5 'tail `find . -type f \( ! -iname ".*" ! -ipath "*.svn*" \) -newerct "'"15 minutes ago"'" -print`' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com | |
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below) | |
module Player | |
describe MovieList, "with optional description" do | |
it "is pending example, so that you can write ones quickly" | |
it "is already working example that we want to suspend from failing temporarily" do | |
pending("working on another feature that temporarily breaks this one") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe "hash comparison tests" do | |
context "comparing single hashes with same keys, different values" do | |
let(:me) { { :foo => 'bar' } } | |
let(:me2) { { :foo => 'baz' } } | |
it "should fail gracefully when using ==" do | |
me.should == me2 | |
end |