Skip to content

Instantly share code, notes, and snippets.

View achiurizo's full-sized avatar
🌞

Arthur Chiu achiurizo

🌞
View GitHub Profile
require 'sinatra'
require 'padrino-helpers'
helpers Padrino::Helpers
get "/" do
"Click my link: #{link_to 'here', '#'}"
end
require File.expand_path(File.dirname(__FILE__) + '/../test_config.rb')
describe "MainController" do
it 'returns text at root' do
get "/"
last_response.body.should == "main app"
end
end
require File.expand_path(File.dirname(__FILE__) + '/../../test_config.rb')
context "PagesController" do
context "GET :index" do
setup { get '/pages' }
# These two are the same
asserts_body.matches %r{Something} # My custom helper
asserts("that it shows something") { last_response.body }.matches %r{Something}
---
:mock: rr
:script: jquery
:test: riot
:orm: mongoid
:stylesheet: scss
:renderer: haml
@achiurizo
achiurizo / RESULTS
Created May 17, 2011 18:49
benchmarking File.stat(f).mtime vs. File.mtime(f)
# ree-1.8.7-2011.03
user system total real
#stat 0.020000 0.010000 0.030000 ( 0.022279)
#mtime 0.050000 0.040000 0.090000 ( 0.087421)
# ruby-1.9.2-p180
user system total real
#stat 0.020000 0.000000 0.020000 ( 0.017624)
require 'resque/tasks'
namespace :resque do
desc "Load the Application Development for Resque"
task :setup => :environment do
ENV['QUEUE'] = '*'
# ENV['VERBOSE'] = '1' # Verbose Logging
end
end
Admin.controllers :website, :navigation_items do
# /navigation/:navigation_id/website/navigation_items
get :index, :parent => :navigation do
'bleh'
end
end
MyApp.helpers do
include MyHelperModule
end
class Riot::Context
# Test Helper to check if route needs authentication
#
# asserts_must_authenticate { post '/photos/new' }
#
def asserts_must_authenticate(&block)
context "without being authenticated" do
setup(&block)
setup { follow_redirect! }
context "GET :index" do
setup { get '/' }
asserts(:body).matches %r{hello world}
asserts(:status).equals 200
context "changing stuff" do
hookup { Something.create :stuff => 'this' }
asserts(:body).matches %r{this}