Skip to content

Instantly share code, notes, and snippets.

Riccardo Tacconi rtacconi

Block or report user

Report or block rtacconi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:286083
# render a file (image, video) inside the browser
def inline
@video = Video.find(params[:id])
send_file @video.filepath.path, :type => @video.filepath_content_type
end
# force the browser to show the download modal box and send the file to the browser
# you can use the :xsendfile => true option
# send_file @video.filepath.path, :type => @video.filepath_content_type
def download
View pickaxe_book_googgle_search_test.rb
require File.dirname(__FILE__) + '/../test_helper'
class PickaxeBookGooggleSearchTest < ActiveSupport::TestCase
include WatirOnRails
# Uncomment the following lines to specify a test server.
# WatirOnRails defaults to http://localhost:3000
#
# server "localhost"
# port 3001
View gist:324409
#!/usr/local/bin/ruby -w
require "rubygems"
require "highline/import"
# The old way, using ask() and say()...
choices = %w{ruby python perl}
say("This is the old way using ask() and say()...")
say("Please choose your favorite programming language:")
say(choices.map { |c| " #{c}\n" }.join)
View gist:492436
context "should destroy participation" do
setup do
@configuration = Factory.create :configuration, :status => 'LIVE'
@p = Factory.create :participation, :configuration => @configuration
@admin = Factory.create :participant, :admin => true
login_as @admin
end
should "delete :destroy participations" do
assert_difference('Participation.count', -1) do
View gist:492457
<html><body>You are being <a href="http://test.host/configurations/46/edit">redirected</a>.</body></html>
View gist:523101
begin
p = Participant.find params[:id]
render :nothing => true, :status => 200
rescue
render :nothing => true, :status => 404
end
View gist:569969
With this code:
browser.link(:text, "Move questions to...").click
browser.alert do
browser.button(:id => "alert").click
end #=> "the alert message"
I get this error:
View gist:584444
#!/bin/sh
echo "recursively removing .svn folders from"
pwd
rm -rf `find . -type d -name .svn`
@rtacconi
rtacconi / gist:708121
Created Nov 20, 2010
Test unique attributes with RSpec and accept_values_for, a custom matcher
View gist:708121
class CourseItem < ActiveRecord::Base
validates_presence_of :course_id, :day, :url
validates_uniqueness_of :course_id, :scope => :day, :message => "- this day has been already created."
end
describe CourseItem do
# check uniqueness using this matcher https://github.com/bogdan/accept_values_for
context "should create one item per day and per course only" do
before do
CourseItem.create! :day => 1, :course_id => 1, :url => '/courses/index.html'
@rtacconi
rtacconi / package-ubuntu-server-rvm.txt
Created Jun 20, 2011
Ubuntu server dependencies for Ruby 1.9.2 (rvm)
View package-ubuntu-server-rvm.txt
sudo aptitude install curl git-core ruby build-essential bison openssl libreadline5 libreadline-dev curl git-core zlib1g zlib1g-dev libssl-dev vim libsqlite3-0 libsqlite3-dev sqlite3 libreadline-dev libxml2-dev git-core subversion autoconf
You can’t perform that action at this time.