Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

2014-04-16から1日間の記事一覧

Ruby | 二次元配列の各先頭の任意のindexに値を追加する

概要 二次元配列の各先頭の任意のindexに値を追加する 詳細 tbpgr_utils gemのArray#together_insert(別名でtinsertもあり) 二次元配列の各先頭の任意のindexに値を追加します。index指定を負の数にすると、Array#insertと同様に後ろから数えた位置に挿入…

Ruby | 二次元配列の各先頭の値のindexを取得する

概要 二次元配列の各先頭の値のindexを取得する 詳細 tbpgr_utils gemのArray#together_index(別名でtindexもあり) 二次元配列の各先頭の値のindexを取得します。 事前準備 gem install tbpgr_utils 主な用途 二次元配列の各先頭の値のindexを取得したい場…

TbpgrUtils | 追加要件 Numeric to_oct_html_table 追加

概要 追加要件 Numeric to_oct_html_table 追加 詳細 追加要件 Numeric to_oct_html_table 仕様 ・10/16進数をHTMLの表形式の文字列で取得します ※より詳細についてはGitHubのREADMEおよびテストケース参照 GitHub https://github.com/tbpgr/tbpgr_utils Rub…

RSpec | rspec command | tag option

概要 rspec command | tag option 詳細 rspec commandのtag optionで行数指定で実行します。 サンプルテストコード(hige_spec.rb) # encoding: utf-8 require "spec_helper" require "hige" describe Hige do it "hige1 1", :hige1 => "hige", hige: true do…

RSpec | rspec command | line_number option

概要 rspec command | line_number option 詳細 rspec commandのline_number optionで行数指定で実行します。 サンプルテストコード(hoge_spec.rb) # encoding: utf-8 require "spec_helper" require "hoge" describe Hige do it "hoge1 1" do # some spec e…

RSpec | rspec command | init option

概要 rspec command | init option 詳細 rspec commandのinit optionで 前提 RSpec 2.14.7で動作確認 動作確認 rspec --init か rspec -i コマンドで 「.rspec」「spec」「spec/spec_helper.rb」を生成してくれます。 $rspec -i create spec/spec_helper.rb …

RSpec | rspec command | format option

概要 rspec command | format option 詳細 rspec commandのformat optionで出力フォーマットを制御できます。 サンプルテストコード(hoge_spec.rb) # encoding: utf-8 require "spec_helper" require "hoge" describe Hige do it "hoge1 1" do # some spec e…

RSpec | rspec command | fail fast option

概要 rspec command | fail fast option 詳細 rspec commandのfail fast optionでテスト失敗時に即実行を終了できます。 rspec --fail-fast サンプルコード(hoge.rb) 100メソッド定義 # encoding: utf-8 class Hoge (1..100).each do |i| define_method "hog…

RSpec | rspec command | exit status

概要 rspec command | exit status 詳細 rspec commandによるテスト実行時に 全テストが成功ならexit statusは0 そうでなければexit statusは1 になります。 サンプルコード1(hoge_spec.rb) # encoding: utf-8 require "spec_helper" require "hoge" descr…

RSpec | rspec command | example option とRSpecPiccoloの組み合わせ

概要 example option とRSpecPiccoloの組み合わせ 詳細 example option とRSpecPiccoloの組み合わせについて。 RSpecPiccoloは私が自作したgemで、パラメタライズドテストに利用します。https://rubygems.org/gems/rspec_piccolo https://github.com/tbpgr/r…

RSpec | rspec command | example option

概要 rspec command | example option 詳細 rspec commandのexample optionで ・特定の一つのexampleのみ実行 ・特定の名前に一致するexampleを全て実行 ・example optionを複数回指定して複雑な条件で任意のテストを実行する などのようなことができます。 …

Ruby | Integer | gcd

概要 Integer#gcd 詳細 最大公約数を取得します。 gcd = the Greatest Common Divisor サンプルコード # encoding: utf-8 require 'tbpgr_utils' bulk_puts_eval binding, <<-EOS 2.gcd 4 2.gcd -4 2.gcd 0 0.gcd 2 12.gcd 24 EOS __END__ 下記はTbpgrUtils …

CodeIQ 第2回デスマコロシアム解答チェック用 Greasemonkeyユーザースクリプト の公開

概要 CodeIQ 第2回デスマコロシアム解答チェック用 Greasemonkeyユーザースクリプト の公開 詳細 CodeIQ 第2回デスマコロシアム解答チェック用 Greasemonkeyユーザースクリプトを下記に置いておきました。https://github.com/tbpgr/codeiq_q835_checker設定…