This file contains hidden or 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 'benchmark' | |
RSpec::Matchers.define :take_less_than do |n| | |
chain :seconds do; end | |
match do |block| | |
@elapsed = Benchmark.realtime do | |
block.call | |
end | |
@elapsed <= n |
This file contains hidden or 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 "rr" | |
Cucumber::Rails::World.send(:include, RR::Adapters::RRMethods) |
This file contains hidden or 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 hidden or 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
module AdminSetup | |
def self.included(base) | |
base.send :include, InstanceMethods | |
end | |
module InstanceMethods | |
protected | |
def declarative_devise_scope | |
:admin |
This file contains hidden or 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
def visit_the page_to | |
visit page_to | |
end | |
def method_missing(method, *args, &block) | |
if method.to_s =~ /_page$/ | |
route_path = method.to_s.gsub /_page$/, "_path" | |
__send__ route_path, *args | |
else | |
super |
This file contains hidden or 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
.formtastic { | |
ol, ul { | |
list-style-type: none; | |
li { | |
font-family: "Lucida Grande", Lucida, Verdana, sans-serif; | |
margin-bottom: 10px; | |
label { | |
display: block; |
This file contains hidden or 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
jQuery.fn.capitalize_word = function() { | |
$(this).each(function() { | |
$(this).bind("keyup", function() { | |
$(this).val($(this).val().toLowerCase().replace(/\b[a-z]/g, function(letter) { | |
return letter.toUpperCase(); | |
})); | |
}) | |
}) | |
} |
This file contains hidden or 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
def states_collection | |
[ | |
['Alabama', 'AL'], | |
['Alaska', 'AK'], | |
['Arizona', 'AZ'], | |
['Arkansas', 'AR'], | |
['California', 'CA'], | |
['Colorado', 'CO'], | |
['Connecticut', 'CT'], | |
['Delaware', 'DE'], |
This file contains hidden or 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::Matchers.define :have_received_an_email do |expected| | |
def last_email | |
@last_email ||= ActionMailer::Base.deliveries.last | |
end | |
def inbox_size | |
ActionMailer::Base.deliveries.size | |
end | |
def to |
This file contains hidden or 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
gem 'chronic' | |
group :development, :test do | |
gem "foreman" | |
# group :test do | |
# Pretty printed test output | |
gem 'turn', '0.8.2', :require => false | |
gem "capybara" |