gem install rails
rails new my_app -T
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com | |
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below) | |
module Player | |
describe MovieList, "with optional description" do | |
it "is pending example, so that you can write ones quickly" | |
it "is already working example that we want to suspend from failing temporarily" do | |
pending("working on another feature that temporarily breaks this one") |
#!/bin/bash -e | |
### BEGIN INIT INFO | |
# Provides: thinking_sphinx | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Start/stop Sphinx daemon for Thinking Sphinx | |
### END INIT INFO | |
CONFIG_FILE=/etc/default/thinking_sphinx.conf | |
. $CONFIG_FILE || exit |
require 'test/unit/assertions' | |
include Test::Unit::Assertions | |
assert_equal "1.9.2", RUBY_VERSION | |
# A Ruby meta-programming puzzle for polite programmers. | |
# This puzzle was created by Matt Wynne (@mattwynne) on 2011-04-10 inspired by Jim Weirich's | |
# talk at the Scottish Ruby Conference 2011. | |
# | |
# The challenge is: you have a class Foo which you want to monkey-patch, but politely. |
A consumer needs to lookup a single user by their github name (jordanbyron). That consumer doesn't know the user's ID. There is a possibility to also search by email and twitter.
"/users.json?github=jordanbyron"
=> [{github: "jordanbyron", id: 1}]
When there are no results an empty array is returned
"/users.json?github=noexist"
Then /^(?:|I )should see "([^\"]*)"(?: within "([^\"]*)")?$/ do |text, selector| | |
with_scope(selector) do | |
if defined?(Spec::Rails::Matchers) | |
page.should have_xpath("//*[text()='#{text}']", :visible => true) | |
else | |
assert page.has_xpath("//*[text()='#{text}']", :visible => true) | |
end | |
end | |
end |
# Make gems available | |
require 'rubygems' | |
# http://drnicutilities.rubyforge.org/map_by_method/ | |
begin | |
require 'map_by_method' | |
rescue LoadError | |
puts "map_by_method is not installed. To enable, run: gem install map_by_method" | |
end |
class A | |
@@a = 1 | |
@a = 2 | |
a = 3 | |
end |
def tip(msg); puts; puts msg; puts "-"*100; end | |
# | |
# 30 Ruby 1.9 Tips, Tricks & Features: | |
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/ | |
# | |
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2" | |
tip "Ruby 1.9 supports named captures in regular expressions!" |
class A | |
end | |
puts "--" + A.instance_methods(false).join(', ') | |
class A | |
def otro | |
end | |
end |