Skip to content

Instantly share code, notes, and snippets.

View chrisbloom7's full-sized avatar
💭
I may be slow to respond.

Chris Bloom chrisbloom7

💭
I may be slow to respond.
View GitHub Profile
@chrisbloom7
chrisbloom7 / rake_benchmark.rb
Created June 8, 2016 15:09 — forked from harley/rake_benchmark.rb
Benchmarking a rake task
# Put this in Rakefile (doesn't matter where)
require 'benchmark'
class Rake::Task
def execute_with_benchmark(*args)
bm = Benchmark.measure { execute_without_benchmark(*args) }
puts " #{name} --> #{bm}"
end
alias_method :execute_without_benchmark, :execute
@chrisbloom7
chrisbloom7 / Capfile
Last active June 14, 2016 07:37 — forked from toobulkeh/deploy.rb
Open a Rails console via Capistrano 3 (requires capistrano-rvm gem)
require 'capistrano/rvm'
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@chrisbloom7
chrisbloom7 / model.rb
Last active December 20, 2015 10:30 — forked from joshuap/environment.rb
ActiveRecord validator for URLs
require 'uri_validator'
class SomeModel < ActiveRecord::Base
validates :url, :presence => true, :uri => { :format => /(^$)|(^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?([\/].*)?$)/ix }
end
@chrisbloom7
chrisbloom7 / cucumber.yml
Created December 23, 2011 14:48 — forked from oliverbarnes/env.rb
Cucumber setup with spork and database_cleaner
<%
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
@chrisbloom7
chrisbloom7 / excercise_custom_factory_girl_steps.feature
Created December 23, 2011 09:16 — forked from blaix/factory_girl_steps.rb
A modified version of the cucumber steps included in factory_girl, which will set an instance variable based on the factory/factories being generated. Drop this file into the features/support folder and don't require the original factory_girl/step_definit
# 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 |
@chrisbloom7
chrisbloom7 / rspec-syntax-cheat-sheet.rb
Created July 22, 2011 00:53 — forked from dnagir/rspec-syntax-cheat-sheet.rb
RSpec 2 syntax cheat sheet by example
# 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")
.mouse{
position: absolute;
background-image: url('../images/cursor.png');
width: 15px;
height: 22px;
z-index: 100;
}