Skip to content

Instantly share code, notes, and snippets.

View dcolthorp's full-sized avatar

Drew Colthorp dcolthorp

View GitHub Profile
module DynamicActiveRecords
def ar_class_for_table table
klass = Class.new ActiveRecord::Base
unique_module = Module.new
DynamicActiveRecords.const_set "Id#{DynamicActiveRecords.unique_id}", unique_module
unique_module.const_set table.classify, klass
klass.class_eval "set_table_name '#{table}'"
klass
end
it "should combine complex parameters" do
session = Webrat::MerbSession.new
session.stub!(:response_body).and_return <<-EOS
<form method="get" action="url">
<input name="a[b][c][x]" value="foo" />
<input name="a[b][c][y]" value="bar" />
<input type="submit" />
</form>
EOS
dslfkjdsafjsdalfs
# run very flat apps with merb -I <app file>.
# Uncomment for DataMapper ORM
# use_orm :datamapper
# Uncomment for ActiveRecord ORM
# use_orm :activerecord
# Uncomment for Sequel ORM
# use_orm :sequel
function! Run(command, ...)
let command = a:command . " 2>&1"
execute "botright copen"
setlocal wrap
setlocal modifiable
normal ggdG
if a:0 > 0
execute "normal ggi" . a:1
else
Given %r{I should see these strings in order} do |table|
doc = Nokogiri.HTML(response.body)
strings = table.raw.flatten
# find all instances of the passed in strings
escaped_strings = table.raw.flatten.map {|string| Regexp.escape(string)}
snippet_regexp = Regexp.new escaped_strings.join("|"), Regexp::MULTILINE
snippets = doc.inner_text.scan(snippet_regexp)
# look for each string in order
require 'spec_helper'
require 'lib/static_map_uri'
describe StaticMapURI do
let(:address){ "123 foo st, grand rapids mi" }
let(:width){ 200 }
let(:height){ 100 }
subject{ StaticMapURI.new address, width, height }
its(:host){ should == "maps.google.com" }
(defmacro let-match [matches & code]
`(if-match ~matches
(do ~@code)
(throw (UnsupportedOperationException. "Destructuring failed."))))
############################################
# spec/spec_helper.rb, in RSpec.configure block
config.before do
MongoidCleaner.start
end
config.after do
MongoidCleaner.clean
end
Register .NET 4 framework with IIS 7:
● Run cmd.exe
● cd C:\windows\microsoft.net\framework\v4.0.30319
● aspnet_regiis.exe -r
Install Web Deployment Tool
● http://www.iis.net/download/WebDeploy
● I chose to install "Complete" instead of the default "Typical" but
I'm not sure this is
necessary