This shows how different approaches to memoization work (or don't) in different Ruby engines.
If you're using the idiomatic Ruby approach to memoization, like this:
def data
@memo ||= expensive_action
end
require 'spec_helper' | |
describe ArticlesController, :type => :controller do | |
describe "GET index" do | |
get :index | |
response.should be_successful | |
end | |
end |
require 'base64' | |
require 'socket' | |
require 'fileutils' | |
# UnixSocketForker is an experiment of inter-process communication using | |
# plain unix sockets to communicate between forked processes and the | |
# parent process. This can also be done via IO.pipe. In this experiment, | |
# the jobs are simply random arrays whose sums are calculated in the forked | |
# worker processes. | |
class UnixSocketForker |
#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) |
# Support for Rspec / Capybara subdomain integration testing | |
# Make sure this file is required by spec_helper.rb | |
# | |
# Sample subdomain test: | |
# it "should test subdomain" do | |
# switch_to_subdomain("mysubdomain") | |
# visit root_path | |
# end | |
DEFAULT_HOST = "lvh.me" |
gem 'database_cleaner', group: :test |
module CarrierWave | |
module MiniMagick | |
def toaster_filter | |
manipulate! do |img| | |
img.modulate '150,80,100' | |
img.gamma 1.1 | |
img.contrast | |
img.contrast | |
img.contrast | |
img.contrast |
class AccountsController < ApplicationController | |
def update | |
@account = Account.find(params[:id]) | |
respond_to do |format| | |
if @account.update_attributes(account_params) | |
format.html { redirect_to @account, notice: 'Account was successfully updated.' } | |
else | |
format.html { render action: "edit" } | |
end |
require 'capistrano/calendar/recipes' | |
require 'bundler/capistrano' | |
require "rvm/capistrano" | |
load 'deploy/assets' | |
set :user, 'deployuser' | |
set :application, 'applicationname' | |
set :rvm_type, :system | |
set :rvm_ruby_string, "ruby-1.9.3-p392@#{application}" |
# download docx2txt by Sandeep Kumar | |
wget -O docx2txt.pl http://www.cs.indiana.edu/~kinzler/home/binp/docx2txt | |
# make a wrapper | |
echo '#!/bin/bash | |
docx2txt.pl $1 -' > docx2txt | |
chmod +x docx2txt | |
# make sure docx2txt.pl and docx2txt are your current PATH. Here's a guide | |
http://shapeshed.com/using_custom_shell_scripts_on_osx_or_linux/ |