Skip to content

Instantly share code, notes, and snippets.

View timriley's full-sized avatar
🇺🇦
Standing with Ukraine

Tim Riley timriley

🇺🇦
Standing with Ukraine
View GitHub Profile
@timriley
timriley / string.rb
Created February 26, 2009 02:18 — forked from chrislloyd/string.rb
require 'singleton'
class String
class TextHelperSingleton
include Singleton
include ActionView::Helpers::TextHelper
end
def method_missing(method, *args)
Then /^I should be on the (.+?) page$/ do |page_name|
request.request_uri.should == send("#{page_name.downcase.gsub(' ','_')}_path")
response.should be_success
end
Then /^I should be redirected to the (.+?) page$/ do |page_name|
request.headers['HTTP_REFERER'].should_not be_nil
request.headers['HTTP_REFERER'].should_not == request.request_uri
Then "I should be on the #{page_name} page"
Feature: Users cannot access to the system without logging in
In order to protect the system from unauthorized access
An anonymous user
Should not have access to the system
Scenario: Visiting the login page
Given an anonymous user
When I go to the new login page
Then I should be on the new login page
When /^I go to (.+)$/ do |page_name|
visit path_to(page_name)
end
function sc {
if [ -x script/console ]; then
script/console
else
sinatra_rb=`egrep -l "^require.+sinatra.$" *.rb 2>/dev/null`
if [ -e $sinatra_rb ]; then
irb -r $sinatra_rb
else
irb
fi
# printf "\033[0m0 All attributes off\033[0m\n"
# printf "\033[1m1 Bold\033[0m\n"
# printf "\033[4m4 Underline\033[0m\n"
# printf "\033[5m5 Blink\033[0m\n"
# printf "\033[7m7 Invert\033[0m\n"
# printf "\033[8m8 Hide\033[0m8 = Hide\n"
# printf "\033[30m30 Black\033[0m30 = Black\n"
# printf "\033[31m31 Red\033[0m\n"
# printf "\033[32m32 Green\033[0m\n"
# printf "\033[33m33 Yellow\033[0m\n"
# 1. Create dirs for unpacking your source code and installing your apps
mkdir $HOME/src
mkdir $HOME/apps
# 2. Create dir for local python modules
mkdir -p $HOME/apps/lib/python2.4/site-packages
export PYTHONPATH=$HOME/apps/lib/python2.4/site-packages
# 3. Install setuptools python module
cd $HOME/src
if [ -f /opt/local/etc/bash_completion ]; then
. /opt/local/etc/bash_completion
fi
# Colors
# printf "\033[0m0 All attributes off\033[0m\n"
# printf "\033[1m1 Bold\033[0m\n"
# printf "\033[4m4 Underline\033[0m\n"
# printf "\033[5m5 Blink\033[0m\n"
# Three things to add:
# * before_filter call
# * action_has_layout? method (if you have one, combine them)
# * adjust_for_inline
#
class ApplicationController < ActionController::Base
# ...
before_filter :adjust_for_inline
# Bash snippet to open new shells in most recently visited dir.
# Useful if you want to open a new terminal tab at the present
# tab's location.
#
# Put this in your .bashrc or whatever.
pathed_cd () {
if [ "$1" == "" ]; then
cd
else