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
VCR.configure do |vcr| | |
normalized_uri = lambda do |uri| | |
uri = URI(uri) | |
path_parts = uri.path.split('/') | |
# put a deterministic value in place of the non-deterministic username | |
path_parts[2] = '__username__' | |
uri.path = path_parts.join('/') | |
uri.to_s | |
end |
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
➜ irb | |
1.9.3p194 :001 > string = "This is a string" | |
=> "This is a string" | |
1.9.3p194 :003 > require 'stringio' | |
=> true | |
1.9.3p194 :004 > io = StringIO.new(string) | |
=> #<StringIO:0x007f988402a890> | |
1.9.3p194 :005 > io.read(2) | |
=> "Th" | |
1.9.3p194 :006 > string.slice!(2, -1) |
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
# A sample Gemfile | |
source "https://rubygems.org" | |
gem 'typhoeus', git: 'git://github.com/typhoeus/typhoeus.git' | |
gem 'sinatra' | |
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
# From: https://github.com/seomoz/interpol/blob/5108f29eadf52c4401785d86f4bc75f590813792/Rakefile#L42-51 | |
desc "Import the twitter bootstrap assets from the compass_twitter_bootstrap gem" | |
task :import_bootstrap_assets do | |
# when the gem installed as a :git gem, it has "-" as a separator; | |
# when it's installed as a released rubygem, it has "_" as a separator. | |
gem_lib_path = $LOAD_PATH.grep(/compass[-_]twitter[-_]bootstrap/).first | |
assets = Dir[File.join(gem_lib_path, '..', 'vendor', 'assets', '**')] | |
destination_path = File.expand_path("../lib/interpol/documentation_app/public", __FILE__) |
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.configure do |c| | |
{ unit: 0.1, integration: 0.5 }.each do |type, max_time| | |
c.after(:each, example_group: { file_path: %r|spec/#{type}| }) do | |
run_time = Time.now - example.metadata.fetch(:execution_result).fetch(:started_at) | |
if run_time > max_time | |
raise "Example took too long: #{run_time} seconds (max is #{max_time} seconds)." | |
end | |
end | |
end | |
end |
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' | |
def memoized_symbol | |
@memoized_symbol ||= :memoized_symbol | |
end | |
def raw_symbol | |
:raw_symbol | |
end |
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
class Shock | |
def intialize(type) | |
@type = type | |
end | |
def cost | |
coster_for(type).compute | |
end | |
private |
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
class Foo | |
def method_missing(name, *args) | |
puts "in #{name}" | |
self | |
end | |
def respond_to_missing?(name, include_private) | |
true | |
end | |
end |
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
rvm use 1.9.3 |
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 'httpclient' | |
require 'vcr' | |
require 'webmock' | |
require 'test/unit' | |
# To allow us to do real HTTP requests in a VCR.turned_off, we | |
# have to tell webmock to let us. | |
WebMock.allow_net_connect! | |
VCR.configure do |c| |