Skip to content

Instantly share code, notes, and snippets.

View tooky's full-sized avatar

Steve Tooke tooky

View GitHub Profile
@tooky
tooky / 1-presentations.md
Last active August 29, 2015 14:16
otb-homework-mar-2015
  1. Ruby - what is bundler? - Tom Clark
  2. git - tags vs branches - Tom Bates
  3. git - rebase vs merge - Tom Altree
  4. Ruby modules and include, extend, prepend - Duncan Smith
  5. Ruby's Enumerable and Enumerators - John Foulkes
  6. Ruby's blocks, procs and lambdas - Chris Rigby
  7. Inheritance vs Composition, with examples in Ruby - James Walsh
Feature: Tag logic
In order to conveniently run subsets of features
As a Cuker
I want to select features using logical AND/OR of tags
Background:
Given a file named "features/test.feature" with:
"""
@feature
Feature: Sample
puts "*" * 100
require 'cucumber/wire_support/wire_language'
class WireFilter < Cucumber::Core::Filter.new(:wire)
def test_case(test_case)
wire.begin_scenario(test_case)
test_case.describe_to receiver
wire.end_scenario
end
end
r.match('/designer/:photo_id/crop').name(:cropper) do |cropper|
cropper.match(:method => :get).to(:controller => 'crops', :action => 'new')
cropper.match(:method => :post).to(:controller => 'crops', :action => 'create')
end
def create
only_provides :json
if params[:Filedata]
@photo = Photo.new_from_filedata(params[:Filedata])
if @photo.save
render '', :status => 200
else
raise NotAcceptable
end
else
class Items < ActiveRecord::Base
def update
@item = Items.find(params[:id])
raise NotFound unless @item
if @item.update_attributes(params[:item])
redirect url(:item, item)
else
raise BadRequest
end
end
RESULTS = %w(H H H H H H A A A A A D)
def result
RESULTS[rand(RESULTS.length)]
end
require 'readline'
def prompt(prompt="> ")
input = nil
@tooky
tooky / init.rb
Created October 20, 2008 12:56
workling.rb
Merb::BootLoader.after_app_loads do
config_path = Merb.root / 'config' / 'starling.yml'
load_path = Merb.root / 'app' / 'workers'
if File.exists?(config_path)
Workling::Client.options = YAML.load_file(config_path)[Merb.environment.to_sym]
Dir.glob(load_path / '**' / '*.rb').each { |wling| require wling }
else
Merb.logger.error! "No starling.yml file found in #{Merb.root}/config."
exit(1)
# works
gem('activemerchant'); require 'active_merchant'
# fails with FATAL: The file activemerchant was not found
dependency('activemerchant') { require 'active_merchant' }
@tooky
tooky / Rakefile
Created February 5, 2009 10:42
Sinatra + Cucumber + Webrat
require 'rubygems'
require 'cucumber/rake/task'
Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = "--format pretty"
end