This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! s:Ruby(l1,l2,fn) | |
exe a:l1 . ',' . a:l2 .'!ruby -n ' . a:fn | |
endfunction | |
command! -nargs=1 -range -complete=file Ruby call s:Ruby(<line1>,<line2>,<q-args>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Given(/^the URL of the platform$/) do | |
@password = something_correct | |
# ... | |
end | |
### | |
### Bad example, just to show the technique | |
### | |
Given (/^the URL of the platform with a bad password$/) do | |
@password = something_less_correct |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The pattern for using alias | |
alias_method :__behavior__, :behavior | |
remove_method :behavior | |
define_method :behavior do | |
# ... | |
__behavior__ | |
# ... | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def iterate *a, &b | |
cons_stream a do | |
iterate( b[*a], &b ) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Pourquoi collect dans ce cas: | |
# | |
<% x.collect{ |y| %> | |
<% if f(y) then %> | |
<%= g(y) %> | |
<% end %> | |
<% } %> | |
# | |
# il serait mieux de ne pas construire cet objet Array qui ne |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test/unit' | |
class Array | |
def get idx | |
fetch idx, :undefined | |
# fonctionne également | |
# fetch( idx ){ :undefined }, mais cet idiome est plus utile en cas de traitement | |
# plus complex, et biensur: | |
# fetch( idx ) raises une exception IndexError si l'élément n'existe pas | |
# Hash a un #fetch pratiquement identique, il me semble plus connu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30, 33, 36, 39, 42, 52, 60, 110, 132, ? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "shoulda" | |
class Test1 < Test::Unit::TestCase | |
context "a user" do | |
setup do | |
puts "setting up" | |
end | |
should "be true" do | |
puts "true" | |
assert true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class << Factory | |
alias_method :__build__, :build | |
def build *args, &blk | |
__log__( *args ) | |
__build__( *args, &blk ) | |
end | |
private | |
def __log__ *args | |
@__logfile__ ||= File::new( "xxx", "w" ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "shoulda" | |
class Test1 < Test::Unit::TestCase | |
context "outer" do | |
setup do | |
puts "outer setup" | |
end | |
context "inner" do | |
setup do | |
puts " inner setup" |
OlderNewer