Skip to content

Instantly share code, notes, and snippets.

View revans's full-sized avatar
🤠
Building Businesses

Robert Evans revans

🤠
Building Businesses
View GitHub Profile
#!/usr/bin/ruby -w
require 'minitest/autorun'
module Kernel
if defined?(MiniTest::Spec)
alias :feature :describe
alias :context :describe
end
end
# get memory size
def memstats
size = `ps -o size= #{$$}`.strip.to_i
end
# run from the root of your app
echo “port: 7000” > .foreman
echo 7000 > $HOME/.pow/`basename $PWD`
# Author:: Adam Jacob <[email protected]>
# Author:: Joshua Timberman <[email protected]>
#
# Copyright 2009-2010, Opscode, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
require 'test_helper'
shared_examples_for 'An Adapter' do
describe '#read' do
before do
@adapter.write(@key = 'whiskey', @value = "Jameson's")
end
it 'reads a given key' do
@adapter.read(@key).must_equal(@value)
@revans
revans / jbuilder-test.rb
Created December 7, 2012 23:53
jbuilder issue #72
# ran with ruby 1.9.3-p372
require 'jbuilder'
require 'json'
json = Jbuilder.new
json.barf '1/10'.to_r
sample = json.target! # kaboom
puts sample # => {"barf":"1/10"}
@revans
revans / active_record_test_helper.rb
Created December 3, 2012 17:04 — forked from tenderlove/.rspec
Active Record Spec Helper - Loading just active record
require 'active_record'
# MiniTest Version
connection_info = YAML.load_file("config/database.yml")["test"]
ActiveRecord::Base.establish_connection(connection_info)
class MiniTest::Spec
after(:each) do
ActiveRecord::Base.subclasses.each(&:delete_all)
end
@revans
revans / login_acceptance_spec.rb
Created November 21, 2012 20:06
MiniTest Spec Feature - SO we can use Capybara like you would in rspec
require 'test_helper'
feature "logging into an application" do
specify "submit my credentials to login" do
visit login_path
fill_in 'Email', with: '[email protected]'
fill_in 'Password', with: 'secret'
click_button 'Login'
end
end
@revans
revans / 0. nginx_setup.sh
Created November 21, 2012 00:32 — forked from mikhailov/0. nginx_setup.sh
Nginx+Unicorn
# Nginx+Unicorn best-practices congifuration guide. Now with SPDY!
# We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies.
# Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module
#
# Deployment structure
#
# SERVER:
# /etc/init.d/nginx (1. nginx)
# /home/app/public_html/app_production/current (Capistrano directory)
#
@revans
revans / base.rb
Created October 2, 2012 00:02
Rails Base class for Generators
# railties/lib/rails/generators/base.rb
module Rails
module Generators
class Base
....
# Line #165
def self.hook_for(*names, &block)
return if is_an_asset_and_disabled(*names)? # Does something like this make sense to skip asset creation if Rails.application.config.assets.enabled is false
....