Skip to content

Instantly share code, notes, and snippets.

@chris-ramon
chris-ramon / rake.rb
Created August 12, 2014 22:57
rake and grunt
unless Rails.env.production?
require 'colorize'
end
REPO_ROOT = File.dirname(__FILE__)
TESTS_LOG = File.join(REPO_ROOT, 'tests.log')
namespace :test do
task all: ['program:all', 'server:all', 'rspec', 'js:all']
@them0nk
them0nk / rspec_rails_cheetsheet.rb
Created March 23, 2012 03:39
Rspec Rails cheatsheet (include capybara matchers)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
#!/usr/bin/env ruby
require 'csv'
require 'json'
if ARGV.size != 2
puts 'Usage: csv_to_json input_file.csv output_file.json'
puts 'This script uses the first line of the csv file as the keys for the JSON properties of the objects'
exit(1)
end
@dwt
dwt / app.rb
Created November 29, 2011 20:02
Testing jquery-ui sortable with capybara
# Run via: ruby -rubygems app.rb
require 'sinatra'
require 'haml'
disable :logging
get '/' do
title = "Drag'n'drop issue reduction"
haml :index
end