Skip to content

Instantly share code, notes, and snippets.

@scudco
scudco / gist:7901
Created August 29, 2008 05:20
Manual Spec'ing
# Soon to be gemified
# http://github.com/scudco/horrible
require 'rubygems'
require 'spec'
require 'highline/import'
module Moonit
module Spec
def step(description,&block)
@scudco
scudco / x
Created October 27, 2008 06:37
Ubiquity command for sharing something to Google Reader
CmdUtils.makeBookmarkletCommand({
name: "Note in Reader",
url:"javascript:var%20b=document.body;var%20GR________bookmarklet_domain='http://www.google.com';if(b&&!document.xmlVersion){void(z=document.createElement('script'));void(z.src='http://www.google.com/reader/ui/link-bookmarklet.js');void(b.appendChild(z));}else{}"
})
require 'rubygems'
require 'taza'
class Google < Taza::Site
def initialize(brand)
brand_url = Google.settings["#{brand}_url".to_sym]
super(:url => brand_url)
end
end
module ForwardInitialization
module ClassMethods
def new(*args,&block)
# name in this case is very different from self.class.to_s
const_get("#{name.split("::").last}").new(*args,&block)
end
end
def self.included(klass)
klass.extend(ClassMethods)
describe "Foo" do
it "should pass" do
true.should be_true
end
it "should also pass" do
true.should be_false
end
describe "ShoppingCartPage" do
it "should update the shipping charges if a premium shipping option is selected" do
MyWidgetStore.new do |widget_store|
widget_store.shopping_cart_page do |cart|
initial_shipping_charges = cart.shipping_charges
cart.shipping_option.select "Super Same Day Shipping 5000"
cart.shipping_charges.should_not == initial_shipping_charges
cart.shipping_charges.should == '$75.00'
end
end
# this could be in a folder with other modules 'lib/sites/ecom/pages/checkout/'
module Ecom
class CheckoutPage < ::Taza::Site
filter :billing_ready?, :billing
page_module :billing do
element(:first_name) { browser.text_field(:id => 'billing_first_name') }
end
module Foo
const_set "Some", Module.new do
module Boo;end
end
end
puts Foo::Some # => Foo::Some
puts Foo::Some::Boo # => foo.rb:9: uninitialized constant Foo::Some::Boo (NameError)
class Foo
define_method("foo bar baz") do
p "lol methods with spaces m i rite?"
end
end
Foo.new.send("foo bar baz")
function! Ack(args)
let grepprg_bak=&grepprg
set grepprg=ack\ -H\ --nocolor\ --nogroup
execute "silent! grep " . a:args
botright copen
let &grepprg=grepprg_bak
endfunction
command! -nargs=* -complete=file Ack call Ack(<q-args>)