You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert
読み進めると、unit tests および functional tests で Mailer をテストすると説明してあります。 unit tests: 単体でテストを行い、入力値と出力値を比較して確認する。上記の 1, 2 の項目をテスト。 functional tests: Mailer を使うコントローラーやモデルが Mailer を正しく操作しているかテストする。正しいEメールが正しい時間に送られたかをテストする。上記 3 の項目をテスト。 Unit Testing ActionMailer::Base.deliveries に送信済みのメール(メールのオブジェクト)が配列で格納されます。 Action Mailer Basics — Ruby on Rails Guides Unit テストでは次を確認する。 ・Eメール を deliver(送信)した後に、ActionMaile
Railsアプリで、ActiveRecord::Base.transactionを使って、 トランザクションを明示的に張り、異常がある場合にロールバックする、 という実装は大いに有りますよね。 僕はRSpecを使ってテストしています。 RSpecを使って、DBがロールバックされることを確認する方法を書いておきます。 例えば、コントローラに次のような処理を書いたとします。 モデルの変更後、メールを送信する、という処理で、ここでは、メールの送信に失敗した場合は、 変更をロールバックする、という仕様とします。(その仕様は果たして妥当か?はここでは考えない。) def save_and_send_mail(model) begin ActiveRecord::Base.tansaction do model.save! SomeMailer.something.deliver end rescue
追記 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 を使う機会が多かっ
『るびま』は、Ruby に関する技術記事はもちろんのこと、Rubyist へのインタビューやエッセイ、その他をお届けするウェブ雑誌です。 Rubyist Magazine について 『Rubyist Magazine』、略して『るびま』は、Rubyist の Rubyist による、Rubyist とそうでない人のためのウェブ雑誌です。 最新号 Rubyist Magazine 0064 号 バックナンバー Rubyist Magazine 0064 号 Rubyist Magazine 0063 号 Rubyist Magazine 0062 号 Kaigi on Rails 特集号 RubyKaigi Takeout 2020 特集号 Rubyist Magazine 0061 号 Rubyist Magazine 0060 号 RubyKaigi 2019 直前特集号 Rubyist
This is the RSpec mono repo, it contains the core gems we think of as "rspec", they are: rspec-core provides the structure for writing executable examples of how your code should behave, and an rspec command with tools to constrain which examples get run and tailor the output. rspec-expectations lets you express expected outcomes on an object in an example. rspec-mocks is a test-double framework f
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く