ライブラリ
- ビルトイン (262)
-
minitest
/ unit (2) - mkmf (11)
- rake (11)
- shell (12)
-
shell
/ command-processor (12) -
shell
/ filter (12) -
test
/ unit (1)
クラス
-
ARGF
. class (33) - File (33)
- IO (11)
- Shell (12)
-
Shell
:: CommandProcessor (12) -
Shell
:: Filter (12) - Thread (22)
モジュール
- FileTest (11)
- Kernel (163)
-
MiniTest
:: Assertions (2) -
Test
:: Unit (1)
キーワード
-
NEWS for Ruby 2
. 2 . 0 (10) -
NEWS for Ruby 2
. 7 . 0 (5) -
NEWS for Ruby 3
. 0 . 0 (4) -
NEWS for Ruby 3
. 1 . 0 (3) - Proc (11)
- Rubyの起動 (3)
- Ruby用語集 (11)
- [] (18)
-
assert
_ throws (1) -
backtrace
_ locations (22) -
caller
_ locations (22) - chomp (11)
- chop (11)
-
create
_ makefile (11) - desc (11)
- gets (33)
- gsub (33)
- identical? (11)
- lambda (17)
-
minitest
/ autorun (11) -
minitest
/ unit (1) - new (11)
- open (22)
- proc (18)
- puts (11)
-
ruby 1
. 6 feature (11) -
ruby 1
. 8 . 2 feature (11) -
ruby 1
. 8 . 4 feature (11) -
setup
_ argv (1) - skip (1)
- warn (7)
- クラス/メソッドの定義 (11)
- 手続きオブジェクトの挙動の詳細 (11)
検索結果
先頭5件
-
Kernel
. # proc { . . . } -> Proc (21048.0) -
与えられたブロックから手続きオブジェクト (Proc のインスタンス) を生成して返します。Proc.new に近い働きをします。
...生します。][ruby]{
pr = Proc.new { break }
(1..5).each(&pr)
//}
===[a:lambda_proc] lambda と proc と Proc.new とイテレータの違い
Kernel.#lambda と Proc.new はどちらも Proc クラスのインスタンス(手続きオブジェクト)を生成しますが、
生成された手......。 lambda の生成する手続きオブジェクトのほうが
よりメソッドに近い働きをするように設計されています。
Kernel.#proc は Proc.new と同じになります。
引数に & を付けることで手続きオブジェクト化したブロックは、Proc.new で......ruby]{
def test_proc
f = Proc.new { return :from_proc }
f.call
return :from_method
end
def test_lambda
f = lambda { return :from_lambda }
f.call
return :from_method
end
def test_block
tap { return :from_block }
return :from_method
end
p test_proc() #=> :from_proc
p test_lambda()... -
Kernel
. # warn(*message , uplevel: nil) -> nil (21048.0) -
message を 標準エラー出力 $stderr に出力します。 $VERBOSE フラグ が nil のときは何も出力しません。
...い
//}
//emlist[uplevel の例][ruby]{
def foo
warn("test message", uplevel: 0) # => test.rb:2: warning: test message
warn("test message", uplevel: 1) # => test.rb:6: warning: test message
warn("test message", uplevel: 2) # => test message
end
foo
//}
@see Warning#warn, $stderr,$VERBOSE... -
Kernel
. # warn(*message , uplevel: nil , category: nil) -> nil (21048.0) -
message を 標準エラー出力 $stderr に出力します。 $VERBOSE フラグ が nil のときは何も出力しません。
...い
//}
//emlist[uplevel の例][ruby]{
def foo
warn("test message", uplevel: 0) # => test.rb:2: warning: test message
warn("test message", uplevel: 1) # => test.rb:6: warning: test message
warn("test message", uplevel: 2) # => test message
end
foo
//}
//emlist[category の例][ruby]{
Warnin... -
Kernel
. # chomp(rs = $ / ) -> String (21042.0) -
$_.chomp とほぼ同じですが、置換が発生したときは、$_の内容を置き換える点が異なります。 コマンドラインオプションで -p または -n を指定した時のみ定義されます。
...//emlist[例: ruby -n で "test" を入力][ruby]{
$_ # => "test\n"
chomp # => "test"
//}
//emlist[例: ruby -n で "test," を入力し、 rs に "," を指定][ruby]{
$_ # => "test\n"
chomp # => "test,"
chomp(",") # => "test"
//}
@see String#chomp,$_,$/... -
Kernel
# desc(description) -> String (21006.0) -
直後の Rake タスクの説明を登録します。
...直後の Rake タスクの説明を登録します。
@param description 直後のタスクの説明を指定します。
例:
desc "Run the Unit Tests"
task :test => [:build] do
runtests
end... -
Kernel
. # gsub(pattern) -> Enumerator (21006.0) -
$_.gsub とほぼ同じですが、置換が発生したときは、$_の内容を置き換える点が異なります。 コマンドラインオプションで -p または -n を指定した時のみ定義されます。
...規表現。
文字列を指定した場合は全く同じ文字列にだけマッチする
@param replace pattern で指定した文字列と置き換える文字列
//emlist[例][ruby]{
$_ # => "test\n"
gsub(/es/, '!!') # => "t!!t\n"
//}
@see String#gsub,$_... -
Kernel
. # gsub(pattern) {|matched| . . . } -> String (21006.0) -
$_.gsub とほぼ同じですが、置換が発生したときは、$_の内容を置き換える点が異なります。 コマンドラインオプションで -p または -n を指定した時のみ定義されます。
...規表現。
文字列を指定した場合は全く同じ文字列にだけマッチする
@param replace pattern で指定した文字列と置き換える文字列
//emlist[例][ruby]{
$_ # => "test\n"
gsub(/es/, '!!') # => "t!!t\n"
//}
@see String#gsub,$_... -
Kernel
. # gsub(pattern , replace) -> String (21006.0) -
$_.gsub とほぼ同じですが、置換が発生したときは、$_の内容を置き換える点が異なります。 コマンドラインオプションで -p または -n を指定した時のみ定義されます。
...規表現。
文字列を指定した場合は全く同じ文字列にだけマッチする
@param replace pattern で指定した文字列と置き換える文字列
//emlist[例][ruby]{
$_ # => "test\n"
gsub(/es/, '!!') # => "t!!t\n"
//}
@see String#gsub,$_... -
Shell
# test(command , file1 , file2 = nil) -> bool | Time | Integer | nil (15157.0) -
Kernel.#test や FileTest のメソッドに処理を委譲します。
...
Kernel.#test や FileTest のメソッドに処理を委譲します。
@param command 数値、またはサイズが 1 の文字列の場合は Kernel.#test に処理委譲します。
2 文字以上の文字列の場合は FileTest のメソッドとして実行します。
@para......ell'
Shell.verbose = false
sh = Shell.new
begin
sh.mkdir("foo")
rescue
end
p sh[?e, "foo"] # => true
p sh[:e, "foo"] # => true
p sh["e", "foo"] # => true
p sh[:exists?, "foo"] # => true
p sh["exists?", "foo"] # => true
@see Kernel.#test, FileTest... -
Shell
:: CommandProcessor # test(command , file1 , file2 = nil) -> bool | Time | Integer | nil (15157.0) -
Kernel.#test や FileTest のメソッドに処理を委譲します。
...
Kernel.#test や FileTest のメソッドに処理を委譲します。
@param command 数値、またはサイズが 1 の文字列の場合は Kernel.#test に処理委譲します。
2 文字以上の文字列の場合は FileTest のメソッドとして実行します。
@para......ell'
Shell.verbose = false
sh = Shell.new
begin
sh.mkdir("foo")
rescue
end
p sh[?e, "foo"] # => true
p sh[:e, "foo"] # => true
p sh["e", "foo"] # => true
p sh[:exists?, "foo"] # => true
p sh["exists?", "foo"] # => true
@see Kernel.#test, FileTest... -
Shell
:: Filter # test(command , file1 , file2 = nil) -> bool | Time | Integer | nil (15157.0) -
Kernel.#test や FileTest のメソッドに処理を委譲します。
...
Kernel.#test や FileTest のメソッドに処理を委譲します。
@param command 数値、またはサイズが 1 の文字列の場合は Kernel.#test に処理委譲します。
2 文字以上の文字列の場合は FileTest のメソッドとして実行します。
@para......ell'
Shell.verbose = false
sh = Shell.new
begin
sh.mkdir("foo")
rescue
end
p sh[?e, "foo"] # => true
p sh[:e, "foo"] # => true
p sh["e", "foo"] # => true
p sh[:exists?, "foo"] # => true
p sh["exists?", "foo"] # => true
@see Kernel.#test, FileTest... -
minitest
/ unit (6114.0) -
ユニットテストを行うためのライブラリです。
...ラリです。
=== 使い方
minitest/unit は以下のように使います。
テスト対象のソース (foo.rb) を用意します。
class Foo
def foo
"foo"
end
def bar
"foo"
end
end
次にユニットテスト (test_foo.rb) を書きます。
テストを......前はすべて "test" で始まる必要があります。
テストメソッドが実行される前には setup メソッドが必ず実行されます。
テストメソッドが実行された後には teardown メソッドが必ず実行されます。
minitest/unit を Kernel.#require した......ません。
require 'minitest/unit'
require 'foo'
MiniTest::Unit.autorun
class TestFoo < MiniTest::Unit::TestCase
def setup
@foo = Foo.new
end
# teardown はあまり使わない
def teardown
@foo = nil
end
def test_foo
assert_equal "foo",... -
minitest
/ autorun (6032.0) -
このファイルを Kernel.#require するとテストが test/unit と同じように自動実行されます。
...このファイルを Kernel.#require するとテストが test/unit と同じように自動実行されます。... -
Test
:: Unit . setup _ argv(original _ argv = ARGV) { |files| . . . } -> [String] (3036.0) -
original_argvで指定されたオプションを解析して、テスト対象になるファイル をrequireします。
...にあるtest_*.rbを全てrequireします。
このメソッド自体は、オプションを解析してrequireを行う以外の処理は行いま
せんが、test/unit.rbをrequireして呼び出すメソッドのため、結果的にユニッ
トテストが実行されます。testrbコマ......使えます。なお、--name=test_fooのような指定は行えません。--name test_foo
のように指定してください。
: -x
指定されたファイルを除外します。ファイルの指定に正規表現も使えます。
: -s, --seed
Kernel.#rand の乱数の種を指定......ess に true を設定します。
: --no-gc-stress
GC.stress に false を設定します。
===== 注意
Test::Unit.setup_argvはoriginal_argvの指定に関わらず、ARGVをfilesで置き
換えます。置き換えられたARGVはminitest/unitによってもう1度解析されます。... -
MiniTest
:: Assertions # assert _ throws(tag , message = nil) { . . . } -> true (3034.0) -
与えられたブロックを評価中に、与えられたタグが Kernel.#throw された場合、検査にパスしたことになります。
...与えられたブロックを評価中に、与えられたタグが Kernel.#throw された場合、検査にパスしたことになります。
@param tag 与えられたブロック評価中に Kernel.#throw されるタグを任意のオブジェクトとして指定します。
@param mess......ージを指定します。
文字列か Proc を指定します。Proc である場合は Proc#call した
結果を使用します。
@raise MiniTest::Assertion 与えられたタグが Kernel.#throw されなかった場合に発生します。
@see Kernel.#throw... -
FileTest
. # identical?(file1 , file2) -> bool (3012.0) -
file1 と file2 が同じファイルを指している時に真を返します。 そうでない場合、ファイルが存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
...が存在しない場合、あるいはシステムコールに失敗した場合などには false を返します。
ruby 1.8.3 以前ではKernel.#test(?-, file1, file2)を使ってください。
open("a", "w") {}
p File.identical?("a", "a") #=> true
p File.identical?("a", "./a")...