Created
October 20, 2008 15:20
-
-
Save yhara/18089 to your computer and use it in GitHub Desktop.
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
# 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