Skip to content

Instantly share code, notes, and snippets.

View mikegehard's full-sized avatar

Mike Gehard mikegehard

  • Chattanooga, TN
  • 20:30 (UTC -04:00)
View GitHub Profile
@mikegehard
mikegehard / gist:935825
Created April 22, 2011 01:13
Mocking fog for use with carrierwave
# drop this into a file in spec/support or feature/support and you should be all set.
unless Kernel.const_defined?("S3_CONFIG")
S3_CONFIG = YAML.load_file("#{Rails.root}/config/s3.yml")[Rails.env].try(:symbolize_keys)
end
Fog.mock!
connection = ::Fog::Storage.new(
:aws_access_key_id => S3_CONFIG[:access_key_id],
@mikegehard
mikegehard / gist:954537
Created May 4, 2011 00:35
Waiting until all jquery ajax calls are done
//Useful if you have a slow CI server...
When /^I wait until all Ajax requests are complete$/ do
wait_until do
page.evaluate_script('$.active') == 0
end
end
@mikegehard
mikegehard / 0_README.md
Created May 5, 2011 02:39 — forked from netzpirat/0_README.md
Continuous CoffeeScript testing with Guard and Jasmine

Continuous CoffeeScript testing with Guard and Jasmine

This Gist shows how to set up a Rails project to practice BDD with CoffeeScript, Guard and Jasmine. You can see this setup in action on Vimeo

  • Install Gems with Bundler with bundle install
  • Define your guards with mate Guardfile
  • Initialize Jasmine with bundle exec jasmine init
  • Configure Jasmine with mate spec/support/yasmine.ym
  • Start Guard with bundle exec guard
@mikegehard
mikegehard / gist:983110
Created May 20, 2011 15:08
Javascript Pattern for Namespacing javascript
// This is a good pattern to namespace javascript.
// Passing in jQuery assures that $ in our functions always refers to jquery
// Also a good pattern to pass in event to handers as that is the default for jQuery
// in a handler the "this" refers to the DOM element that caused the element.
window.Hello = {};
(function($, namespace){
namespace.Bar = {};
// Use jQuery to add your methods.
$.extend(namespace.Bar, {
@mikegehard
mikegehard / config.ru
Created March 5, 2012 20:05
Rails Lightweight Stack. Most of this is detailed on Crafting Rails Applications - http://pragprog.com/book/jvrails/crafting-rails-applications
# Run this file with `RAILS_ENV=production rackup -p 3000 -s thin`
# Be sure to have rails and thin installed.
require "rubygems"
# We are not loading Active Record, nor the Assets Pipeline, etc.
# This could also be in your Gemfile.
gem "actionpack", "~> 3.2"
gem "railties", "~> 3.2"
# The following lines should come as no surprise. Except by
@mikegehard
mikegehard / sketch.rb
Created July 5, 2012 00:02 — forked from mattwynne/sketch.rb
Responders implemented using a block instead of another class
class Organization
def to_param
"42"
end
def saved?
rand > 0.5
end
end
@mikegehard
mikegehard / code.scala
Created December 15, 2012 20:17
Problems with JSON API tests in Play2
object BetaInvitationRequestController extends Controller {
val successResponse = Map("success" -> true)
val betaInvitationRequestMapping = Forms.mapping(
"email" -> Forms.email
)(BetaInvitationRequest.apply)(BetaInvitationRequest.unapply)
val betaInvitationRequestForm = Form(betaInvitationRequestMapping)
def create = Action {
@mikegehard
mikegehard / application.js
Last active December 22, 2016 13:43
Lineman questions
/* Exports an object that defines
* all of the configuration needed by the projects'
* depended-on grunt tasks.
*
* You can find the parent object in: node_modules/lineman/config/application.js
*/
module.exports = require('lineman').config.extend('application', {
appTasks: {
common: [
@mikegehard
mikegehard / Test File
Last active December 17, 2015 03:39
Test file and errors encountered when trying to run two browser based tests in the same Play test file.
package test.features
import org.specs2.mutable.Specification
import play.api.test.{Helpers, FakeApplication, WithBrowser}
import java.util.concurrent.TimeUnit
import play.api.db.DB
import slick.session.Database
import slick.jdbc.StaticQuery
import Database.threadLocalSession
import models.{BetaInvitationRequests, BetaInvitationRequest}
Books
TDD by Example
Extreme Programming Explained
Videos
http://vimeo.com/68375232