Minitest is a beautifully made test suite for writing tests to verify your expectations from your code base. According to the website, it "provides a complete suite of testing facilities supporting TDD, BDD, mocking, and benchmarking." The way it's implemented is rather straightforward, as you can see in creator Ryan Davis' walk-through of Minitest's design/implementation. Fundamentally, it has be
minitest には標準で mock や stub の機能が付いています。それらの挙動について学んだのでメモ。 コード例 下記のような Person クラスと Whisky クラスがあるとします。これらについて minitest の mock と stub を使ってテストを書いてみます。 class Person def eat(food) food.taste end def drink(whisky) whisky.alcohol.upcase end end class Whisky def alcohol # まだ実装されていない end end mock minitest では下記のように mock を書きます。 describe Person do subject { Person.new } describe '#eat' do it '引数にとったオブジェクトの #tas
こんにちは。 DMM.comラボでプラットフォームの開発をしておりますいっちーです。 PHPやJAVAを使うことが多いDMMですが、 最近ではRubyやNode.jsなどチームやプロジェクトごとに様々な言語を使うようになってきました。 今回はRubyに関してのブログを書きます。 Rubyのテストフレームワークは色々ありますが、その中のminitest というフレームワークのプラグインとしてminitest-names というものを作成したのでgemを公開しました。 ソースコードはdmm.com laboのgithubリポジトリにあります。 作成したのはプラグインですがgem形式なのでrubygems.orgにも置きました。 どんな機能なのか? 端的に説明するとテストケース名を複数指定して、それらを実行するものです。 minitestのテストは以下のようにtest_で始まる関数で、実行時にこ
Rails4からはActiveSupport::TestCaseがTest::UnitからMiniTest::Unit::TestCaseのサブクラスに変わっている。 MiniTestはSpecなDSLをサポートしているので、RSpecを入れずともBDDスタイルでテストが書けるようになる。 ということで、いろいろtest_helper.rbをゴニョってたらminitest-rails-specというズバリなGemを見つけたので(><)これを使う。 minitest-spec-railsでやってくれることは、ざっくりいうと、RailsのActiveSupport::TestCaseにMinitest::Spec::DSLをextendして、ControllerとかHelperクラスをテスト対象クラスに追加して、beforeとかafterとかのDSLを使えるようにしてくれるだけというシンプルな
ICANN, the Internet Corporation for Assigned Names and Numbers, requires us to ask you as a Registrant of a domain name to verify your contact information for this domain with your provider. As a Registrant of a domain name, a new domain registration or changes to the first name, last name, contact address or email address of an existing domain name, requires verification of the information within
追記 2014-12-10 === この記事ですが、Ruby on Rails 3.2.x 系を前提にした内容となっており、 新しい Rails 4.0.x、4.1.x 系では少しやり方が異なります。 取り急ぎで申し訳ございませんが、とりあえず下記に、最新の Minitest の記事を紹介いたします。 A Guide to Testing Rails Applications — Ruby on Rails Guides (※英文) 追記ここまで === Ruby や Ruby on Rails で使用されるテストフレームワークは、何がポピュラーか? The Ruby Toolbox - Unit Test Frameworks RSpec が第1党で、次に Minitest という Test::Unit から置き換えられたフレームワークが人気だ。個人的には RSpec を使う機会が多かっ
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く