Skip to content

Instantly share code, notes, and snippets.

@yhara
Created October 20, 2008 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yhara/18088 to your computer and use it in GitHub Desktop.
Save yhara/18088 to your computer and use it in GitHub Desktop.
日本語でRSpecしてみた
# coding: utf-8
module Japanespec
def 仕様(&block); end
def 例外(*args); end
def なる; end
def 含む; end
def を持つ; end
def に応答する; end
def マッチする; end
def 満たす; end
def 変える(*args); end
def を投げる; end
end
class Object
def (*args)
end
def (arg)
end
def (*args)
end
def から(arg)
end
def (arg)
end
end
class Integer
def 個の(prop, arg)
end
end
include Japanespec
"Ruby". 仕様{
# ==
Math.sqrt(4). 2. なる
Math.sqrt(4). 3. ならない
Math.sqrt(4). 2, である
Math.sqrt(4). 3, ではない
# be
[1,2,3].include?(3). 正しい
[1,2,3].include?(4). 正しくない
[].first. nil. なる
[1].first. nil. ならない
# equal
5. 5. 同一である
"5". "5". 同一ではない
# change
obj = 1
lambda{ }. obj. :prop. 変える
lambda{ }. obj. :prop. 1.から 2. 変える
# has, include
ary = [1,2,3]
ary. 2. 含む
ary. 3.個の :item, を持つ
ary. 3.個以上の :item, を持つ
ary. 3.個未満の :item, を持つ
# respond_to
ary. :size, :length, に応答する
# raise
lambda{ }. 例外 を投げる
lambda{ }. 例外 ArgumentError, を投げる
lambda{ }. 例外 ArgumentError, "foobar", を投げる
#match
str = "abcde"
str. /abc/. マッチする
# satisfy
obj = 1
obj. {|o| o<3 and o%3 == 1 }. 満たす
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment