Skip to content

Instantly share code, notes, and snippets.

require_relative 'test_helper'
require 'rack/test'
require 'minitest/autorun'
require 'capybara'
require 'capybara/dsl'
include Capybara::DSL
def app
MyApp::Server
def hash_options(args, defaults)
args.assert_valid_keys(*defaults.keys)
defaults.merge(args).values
end
def my_method(args = {})
some, other, blah =
*hash_options(args, :some => 'value', other: 'value 2', blah: 'value 3')
# Use
@ashmoran
ashmoran / sketch.rb
Created June 29, 2012 16:04 — forked from mattwynne/sketch.rb
sketch for Matt Wynne
class Organization
def to_param
"42"
end
def saved?
rand > 0.5
end
end
class OrganizationCreator
@ashmoran
ashmoran / has_many_assignment_spec.rb
Created December 15, 2011 20:02 — forked from mrkurt/Gemfile
The magical document eating has_many assignment (now incorporating the dark arts): https://github.com/mongoid/mongoid/issues/1503
require 'bundler'
Bundler.setup
require 'mongoid'
require 'rspec/autorun'
Mongoid.configure do |config|
config.master = Mongo::Connection.new.db("has_many_bug")
end
class Kid
@ashmoran
ashmoran / gist:983711
Created May 20, 2011 20:17
MSpec nesting
/* What should the Resharper output of the current UI look like?
In my version (0.4.13) the following is shown:
EnumerableExtensions, and both enumerables contain the same items
should indicate that the enumerables are equal
I would have expected it to show something like:
EnumerableExtensions, when comparing two enumerables for item equality and both enumerables contain the same items
should indicate that the enumerables are equal
(define (my-for-each proc values)
(if (null? values)
#t
(let ()
(proc (car values))
(my-for-each proc (cdr values)))))
(import srfi-1)
(use srfi-1)
require 'rspec'
class Quiz
def self.answer(question)
42
end
end
# Test
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
ENV["RAILS_ENV"] ||= "test"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support