289件ヒット
[1-100件を表示]
(0.018秒)
別のキーワード
ライブラリ
- ビルトイン (75)
- erb (12)
-
irb
/ inspector (12) - json (24)
-
json
/ add / exception (12) -
minitest
/ unit (7) -
net
/ http (12) - objspace (12)
- rake (36)
- set (9)
- strscan (24)
-
test
/ unit (1) - win32ole (12)
クラス
- ERB (12)
- Exception (12)
- File (12)
- IO (12)
-
IRB
:: Inspector (12) -
Net
:: HTTPGenericRequest (12) -
ObjectSpace
:: WeakMap (12) -
Rake
:: TaskArguments (12) - Set (12)
- StringScanner (24)
- WIN32OLE (12)
モジュール
- GC (12)
- JSON (12)
-
JSON
:: Generator :: GeneratorMethods :: String (12) -
MiniTest
:: Assertions (7) - ObjectSpace (12)
-
Rake
:: Cloneable (24) -
Test
:: Unit (1)
オブジェクト
- ENV (24)
キーワード
- RTEST (12)
- Rubyの起動 (4)
- Ruby用語集 (12)
- [] (12)
- []= (12)
-
allocation
_ sourcefile (12) -
assert
_ empty (1) -
assert
_ includes (1) -
assert
_ instance _ of (1) -
assert
_ kind _ of (1) -
assert
_ nil (1) -
assert
_ respond _ to (1) -
body
_ stream (12) - clone (12)
-
def
_ class (12) -
def
_ inspector (12) - dump (12)
- dup (12)
- invoke (12)
-
latest
_ gc _ info (12) -
mu
_ pp (1) - open (12)
- puts (12)
- reject (24)
- reject! (12)
-
ruby 1
. 6 feature (12) -
scan
_ full (12) -
search
_ full (12) -
setup
_ argv (1) -
test
/ unit (1) -
to
_ json (24)
検索結果
先頭5件
-
test
/ unit (26210.0) -
ユニットテストを行うためのライブラリです。
...参照してください。
* Test::Unit - Ruby用単体テストフレームワーク: https://test-unit.github.io/
なお、2.2.0より前のtest/unit は当時バンドルしていた minitest/unit を使って再実装し
ていましたが、上記のtest/unitと完全な互換性がある......史(2014年版) https://www.clear-code.com/blog/2014/11/6.html
* RubyKaigi 2015:The history of testing framework in Ruby https://www.clear-code.com/blog/2015/12/12.html
=== 使い方
Test::Unit は以下のように使います。
まずテスト対象のソース(foo.rb)が必要です......require 'test/unit'
require 'foo'
class TC_Foo < Test::Unit::TestCase
def setup
@obj = Foo.new
end
# def teardown
# end
def test_foo
assert_equal("foo", @obj.foo)
end
def test_bar
assert_equal("bar", @obj.bar)
en... -
JSON
:: Generator :: GeneratorMethods :: String # to _ json(state _ or _ hash = nil) -> String (9112.0) -
自身から生成した JSON 形式の文字列を返します。
...から生成した JSON 形式の文字列を返します。
自身のエンコードは UTF-8 であるべきです。
"\u????" のように UTF-16 ビッグエンディアンでエンコードされた文字列を返すことがあります。
@param state_or_hash 生成する JSON 形式の文...... JSON::State のインスタンスか、
JSON::State.new の引数と同じ Hash を
指定します。
//emlist[例][ruby]{
require "json"
puts "test".to_json # => "test"
puts '"'.to_json # => "\""
puts "\\".to_jso......n # => "\\"
puts "𤘩宮城".to_json(ascii_only: true) # => "\ud851\ude29\u5bae\u57ce"
//}... -
GC
. latest _ gc _ info(key) -> object (6200.0) -
最新のGCの情報を返します。
...//emlist[例][ruby]{
latest = GC.latest_gc_info
latest # => {:major_by=>nil, :gc_by=>:newobj, :have_finalizer=>false, :immediate_sweep=>false, :state=>:sweeping}
stat = GC.stat
merged = GC.latest_gc_info(stat)
merged == latest.merge(stat) # => true
GC.latest_gc_info(:gc_by) # => :newobj
//}... -
int RTEST(VALUE obj) (6200.0)
-
obj が Qfalse でも Qnil でもないとき真。
...obj が Qfalse でも Qnil でもないとき真。... -
ENV
. reject -> Enumerator (6124.0) -
環境変数のうち、ブロックを評価した値が真であるものをとり除きます。 Enumerable#reject と異なり Hash を返します。また、とり除いた結果 は実際の環境変数に影響を与えません。
...除きます。
Enumerable#reject と異なり Hash を返します。また、とり除いた結果
は実際の環境変数に影響を与えません。
//emlist[][ruby]{
ENV['TEST'] = 'foo'
result = ENV.reject { |key, value| key == 'TEST' }
result['TEST'] # => nil
ENV['TEST'] # => "foo"
//}... -
ENV
. reject {|key , value| . . . } -> Hash (6124.0) -
環境変数のうち、ブロックを評価した値が真であるものをとり除きます。 Enumerable#reject と異なり Hash を返します。また、とり除いた結果 は実際の環境変数に影響を与えません。
...除きます。
Enumerable#reject と異なり Hash を返します。また、とり除いた結果
は実際の環境変数に影響を与えません。
//emlist[][ruby]{
ENV['TEST'] = 'foo'
result = ENV.reject { |key, value| key == 'TEST' }
result['TEST'] # => nil
ENV['TEST'] # => "foo"
//}... -
Exception
# to _ json(*args) -> String (6112.0) -
自身を JSON 形式の文字列に変換して返します。
...自身を JSON 形式の文字列に変換して返します。
内部的にはハッシュにデータをセットしてから JSON::Generator::GeneratorMethods::Hash#to_json を呼び出しています。
@param args 引数はそのまま JSON::Generator::GeneratorMethods::Hash#to_json に渡......れます。
//emlist[例][ruby]{
require "json/add/core"
begin
0/0
rescue => e
e.to_json # => "{\"json_class\":\"ZeroDivisionError\",\"m\":\"divided by 0\",\"b\":[\"/path/to/test.rb:4:in `/'\",\"/path/to/test.rb:4:in `<main>'\"]}"
end
//}
@see JSON::Generator::GeneratorMethods::Hash#to_json... -
Set
# reject! {|o| . . . } -> self | nil (3124.0) -
集合の各要素に対してブロックを実行し、その結果が真であるようなすべての 要素を削除します。
...ます。
reject! は、要素が 1 つ以上削除されれば self を、1 つも削除されなければ
nil を返します。
//emlist[][ruby]{
require 'set'
s1 = Set['hello.rb', 'test.rb', 'hello.rb.bak']
s1.delete_if {|str| str =~ /\.bak\z/}
p s1 # => #<Set: {"hello.rb", "test.rb"}>
s2 = S......et['hello.rb', 'test.rb', 'hello.rb.bak']
p s2.reject! {|str| str =~ /\.bak\z/} # => #<Set: {"hello.rb", "test.rb"}>
p s2.reject! {|str| str =~ /\.o\z/} # => nil
//}
@see Enumerable#reject......reject! は、要素が 1 つ以上削除されれば self を、1 つも削除されなければ
nil を返します。
//emlist[][ruby]{
s1 = Set['hello.rb', 'test.rb', 'hello.rb.bak']
s1.delete_if {|str| str =~ /\.bak\z/}
p s1 # => #<Set: {"hello.rb", "test.rb"}>
s2 = Set['hello.rb', 'test.rb......', 'hello.rb.bak']
p s2.reject! {|str| str =~ /\.bak\z/} # => #<Set: {"hello.rb", "test.rb"}>
p s2.reject! {|str| str =~ /\.o\z/} # => nil
//}
@see Enumerable#reject... -
JSON
. # dump(object , io = nil , limit = nil) -> String | IO (3112.0) -
与えられたオブジェクトを JSON 形式の文字列に変換してダンプします。
...与えられたオブジェクトを JSON 形式の文字列に変換してダンプします。
与えられたオブジェクトを引数として JSON.#generate を呼び出します。
@param object ダンプするオブジェクトを指定します。
@param io IO のように write メ......。
//emlist[例][ruby]{
require "json"
JSON.dump({ name: "tanaka", age: 19 }) # => "{\"name\":\"tanaka\",\"age\":19}"
//}
//emlist[例][ruby]{
require "json"
File.open("test.txt", "w") do |f|
JSON.dump([[[[[[[[[[]]]]]]]]]], f, 10) # => #<File:test.txt>
JSON.dump([[[[[[[[[[[]]]]]]]]]]], f,... -
ObjectSpace
. # allocation _ sourcefile(object) -> String (3112.0) -
objectの元となったソースファイル名を返します。
...objectの元となったソースファイル名を返します。
@param object 元となるソースファイル名を取得したいobjectを指定します。
@return objectの元となるソースファイル名を返します。存在しない場合はnilを返します。
//emlist[例:test.......y]{
require 'objspace'
ObjectSpace::trace_object_allocations_start
obj = Object.new
puts "file:#{ObjectSpace::allocation_sourcefile(obj)}" # => file:test.rb
ObjectSpace::trace_object_allocations_stop
//}
@see ObjectSpace.#trace_object_allocations_start,
ObjectSpace.#trace_object_allocations...