Skip to content

Instantly share code, notes, and snippets.

View maxschulze's full-sized avatar

maxschulze maxschulze

View GitHub Profile
@maxschulze
maxschulze / LocationAssociation.rb
Created December 9, 2010 15:12
Proposal for Radio Locations / Stations
##
# This way a radio location/station can have many cities, countries and continents, e.g.
# for a global online radio channel.
#
# A Radio Location can have just a city or country etc.
#
class RadioStation
belongs_to :radio_location
end
@maxschulze
maxschulze / watchr_script.rb
Created May 21, 2011 12:05 — forked from markbates/watchr script
A Watchr script for rails, rspec, and cucumber
ENV["WATCHR"] = "1"
system 'clear'
def growl(message)
growlnotify = `which growlnotify`.chomp
title = "Watchr Test Results"
puts message
image = message.match(/\s0\s(errors|failures)/) ? "~/.watchr_images/passed.png" : "~/.watchr_images/failed.png"
options = "-w -n Watchr --image '#{File.expand_path(image)}' -m '#{message}' '#{title}'"
system %(#{growlnotify} #{options} &)
@maxschulze
maxschulze / html_aware_truncate_helper.rb
Created June 5, 2011 19:55
HTML Aware truncate for Ruby / Rails using nokogiri
# Source:
# http://blog.madebydna.com/all/code/2010/06/04/ruby-helper-to-cleanly-truncate-html.html
require "rubygems"
require "nokogiri"
module TextHelper
def truncate_html(text, max_length, ellipsis = "...")
ellipsis_length = ellipsis.length
@maxschulze
maxschulze / Gemfile
Created July 16, 2011 14:46
Cover me configuration for Hudson
gem 'cover_me', '>= 1.0.0.rc6', :group => :test
@maxschulze
maxschulze / Gemfile
Created July 17, 2011 20:28
Gemfile with cover_me
gem 'cover_me', '>= 1.0.0.rc6', :group => :test
@maxschulze
maxschulze / cover_me.rake
Created July 17, 2011 20:29
Cover_me rake task with Emma Formatter config
namespace :cover_me do
task :report do
puts "Reporting!"
CoverMe.config.formatter = CoverMe::EmmaFormatter
CoverMe.config.at_exit = Proc.new {}
CoverMe.complete!
end
end
task :spec do
@maxschulze
maxschulze / hudson.sh
Created July 17, 2011 20:30
Hudson run script for rspec/cucumber and ruby-1.9.2-p136 with RVM
#!/bin/bash -l
source "$HOME/.rvm/scripts/rvm"
# Use the correct ruby
rvm --create "1.9.2-p136@project"
gem install bundler
export RAILS_ENV=test
export DISPLAY=:99
# cumulative line chart
cumulativeChart = buildCumulativeChart(rows, "start_date")
cumulativeChart.addLine("CTR" ,"ctr")
cumulativeChart.addLine("CR", "cr")
cumulativeChart.addLine("ROI", "roi")
cumulativeChart.draw("#chart1")
class Credentials
include Support::Base
attribute :password, String
attribute :password_confirmation, String
with_options allow_blank: true do |v|
v.validates :password, confirmation: { message: proc{ error_msg(:password, :passwords_dont_match) } }
v.validates :password, length: { minimum: 8, maximum: 50, message: proc{ error_msg(:password, :invalid) } }
# v.validates :password, format: { with: /[^[:alpha:]]/ }
describe VotesController do
describe "POST 'create'" do
it "should return json success" do
user_vote = stub_model(UserVote, :save => true)
UserVote.stub(:new).with({ip_address: "127.0.0.1", mics: 2, round_id: 1, rapper_id: 1}) { user_vote }
post :create, user_vote: { ip_address: "127.0.0.1", mics: 2, round_id: 1, rapper_id: 1 }