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
namespace :heroku do | |
def app_name | |
@app_name ||= Heroku::Command::BaseWithApp.new([]).app | |
end | |
def latest_bundle(timeout = 30) | |
puts "Attempting to get latest bundle..." | |
get_bundle = lambda do | |
bundles = Heroku::Command.run('bundles', {}) | |
bundles.sort { |b1, b2| b1[:created_at] <=> b2[:created_at] } |
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
def find_element(xpath_expression, text, case_insensitive = false) | |
exp = if case_insensitive | |
xpath_expression % ["translate(text(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvqxyz')", text.downcase] | |
else | |
xpath_expression % ["text()", text] | |
end | |
unless elem = find(exp) | |
if case_insensitive | |
raise "Failed to find element using locator #{text}" |
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
~/projects/dgnetwork[bundler]% ruby --version | |
ruby 1.9.1p376 (2009-12-07 revision 26041) [i386-darwin10.2.0] |
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
source :gemcutter | |
gem 'rails', '2.3.5' | |
gem 'httparty' | |
gem 'mad_mimi_mailer', '0.0.8' | |
gem 'fastercsv' | |
gem 'crummy' | |
gem 'prawn' | |
gem 'barby' | |
gem 'friendly_id' |
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
# The idea for this technique taken from: http://blog.wolfman.com/articles/2007/07/14/using-rspec-to-test-haml-helpers | |
module HelperHamlSupport | |
def new(*args, &block) | |
super.tap do |obj| | |
obj.extend Haml | |
obj.extend Haml::Helpers | |
obj.init_haml_helpers | |
end | |
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
# Rack::Test doesn't support hitting external webservers. However, when a user enters their credit card info, | |
# it is submitted directly to braintree, so we need to intregration test with hitting an external server. | |
# This hack enabled this, by swapping out the Rack::Test's rack app with a Rack::Client instance. | |
# Rack::Client acts just like a rack app, but under the covers it delegates to Net::HTTP. | |
require 'rack/client' | |
module RackTestHack | |
def new(*a, &b) |
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
--- | |
- !ruby/struct:VCR::HTTPInteraction | |
request: !ruby/struct:VCR::Request | |
method: :get | |
uri: http://maps.google.com:80/maps/geo?q=Seattle%2C+WA&output=xml&key=ABQIAAAAM1mKqHK9XdhE_YEkQ7oqnhR8EBP7TfhOOIrsLnV5Hk7LABXvFhRRL3Y8fJfBk0KFeIkQgKLdCVcFCQ&oe=utf-8 | |
body: | |
headers: | |
accept: | |
- "*/*" | |
host: |
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
>> puts User.first.methods.select { |m| m =~ /_with(out)?_/ }.sort | |
destroy_with_callbacks | |
destroy_with_transactions | |
destroy_without_callbacks | |
destroy_without_transactions | |
extend_with_included_modules_from | |
load_with_new_constant_marking | |
reload_with_autosave_associations | |
reload_with_dirty | |
reload_without_autosave_associations |
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
>> p = Proc.new { |a, b| a } | |
=> #<Proc:0x00000001036962f8@(irb):2> | |
>> p.call(5) | |
=> 5 | |
>> l = lambda { |a, b| a } | |
=> #<Proc:0x000000010368e8c8@(irb):4> | |
>> l.call(5) | |
ArgumentError: wrong number of arguments (1 for 2) | |
from (irb):4 | |
from (irb):5:in `call' |
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
class DocumentAnalyzer | |
SPLIT_STRATEGY = lambda { |doc| doc.split(' ').size } | |
def initialize(document) | |
@document = document | |
end | |
def word_count(counting_strategy = SPLIT_STRATEGY) | |
counting_strategy.call(@document) | |
end |
OlderNewer