Skip to content

Instantly share code, notes, and snippets.

View hindenbug's full-sized avatar
💻

Manoj hindenbug

💻
View GitHub Profile
# Video: http://rubyhoedown2008.confreaks.com/08-chris-wanstrath-keynote.html
Hi everyone, I'm Chris Wanstrath.
When Jeremy asked me to come talk, I said yes. Hell yes. Immediately. But
then I took a few moments and thought, Wait, why? Why me? What am I supposed
to say that's interesting? Something about Ruby, perhaps. Maybe the
future of it. The future of something, at least. That sounds
keynote-y.

Parallelize Your RSpec Suite

We all have multi-core machine these days, but most rspec suites still run in one sequential stream. Let's parallelize it!

The big hurdle here is managing multiple test databases. When multiple specs are running simultaneously, they each need to have exclusive access to the database, so that one spec's setup doesn't clobber the records of another spec's setup. We could create and manage multiple test database within our RDBMS. But I'd prefer something a little more ... ephemeral, that won't hang around after we're done, or require any manual management.

Enter SQLite's in-memory database, which is a full SQLite instance, created entirely within the invoking process's own memory footprint.

(Note #1: the gist for this blog is at http://gist.github.com/108780)

@gus
gus / index.txt
Created November 30, 2009 21:55 — forked from toothrot/index.txt
Ruby/Clojure analogs
For each Ruby module/class, we have Ruby methods on the left and the equivalent
Clojure functions and/or relevant notes are on the right.
For clojure functions, symbols indicate existing method definitions, in the
clojure namespace if none is explicitly given. clojure.contrib.*/* functions can
be obtained from http://github.com/kevinoneill/clojure-contrib/tree/master,
ruby-to-clojure.*/* functions can be obtained from the source files in this
gist.
If no method symbol is given, we use the following notation:
@TomK32
TomK32 / album_spec.rb
Created April 12, 2010 21:17
Example for testing mongoid assocications with Rspec/shoulda
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe Album do
before :each do
@website = Factory(:website)
@album = @website.albums.build(Factory(:album).attributes)
@album.save
end
it "should be valid" do
@album.should be_valid
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
class Feature
include Mongoid::Document
field :body, :type => String
embedded_in :suggestion, :inverse_of => :features
has_many_related :votes, :as => :votable
end
@lucashungaro
lucashungaro / links.textile
Created August 14, 2010 16:36
Links de referência utilizados em minha palestra
@iamnader
iamnader / gist:641569
Created October 22, 2010 23:58
Mongoid Set Defaults Rake Task
require 'config/environment'
require 'mongo'
namespace :mongoid do
desc 'Update defaults'
task :defaults do
db = Mongoid.config.master
models.each do |m|
m = eval m
@dnagir
dnagir / rspec-syntax-cheat-sheet.rb
Created November 5, 2010 09:29
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")
@yuribossa
yuribossa / gist:716577
Created November 26, 2010 11:17
Simple Popup Message based on jQuery Mobile
function jqmSimpleMessage(message) {
$("<div class='ui-loader ui-overlay-shadow ui-body-b ui-corner-all'><h1>" + message + "</h1></div>")
.css({
display: "block",
opacity: 0.96,
top: window.pageYOffset+100
})
.appendTo("body").delay(800)
.fadeOut(400, function(){
$(this).remove();