I Can’t Get No Satisfaction (From Fixtures) Here at thoughtbot, we’ve had it with fixtures. Is Susie an admin? Which user owns the Exciting Test post? Are there any categories without posts, or should I add that fixture for this test? How did this post end up in the future? Do you like asking these questions when writing tests? I don’t. I also don’t like tests that don’t tell you anything about th
On a recent project, a client’s test suite had slowed down to a painful 15 minutes even when running with parallelization. It was great to see that the team maintained a balanced testing pyramid, but we were surprised by the completion times of even the simplest unit specs. # spec/models/user_spec.rb describe "associations" do subject(:user) { User.new } it { should have_many(:orders) } # 12 addit
System Testing System tests let you test applications in the browser. Because system tests use a real browser experience, you can test all of your JavaScript easily from your test suite. To create a system test in your application, extend your test class from ApplicationSystemTestCase. System tests use Capybara as a base and allow you to configure the settings through your application_system_test_
Rails プラグイン Gem を作る方法の紹介です。現在の Rails では、プラグインを Gem としてビルドします。通常の Ruby Gem と異なるのは、Rails プラグイン Gem は Rails のコアフレームワーク自体を拡張することができる点です。Rails 自身を拡張して機能を追加したい場合は、Rails プラグインとして Gem を作成すると良いでしょう。 通常の Ruby Gem の作り方は、以下を参照お願いいたします。 Gemの作り方(Ruby Gem) | EasyRamble また、Rails でライブラリとして組み込むことができる gem には、通常の Ruby Gem、Rails プラグイン、Rails エンジンの3種類があります。それぞれの違いについては、以下の解説がとても分かりやすいです。 Gem、Railtieプラグイン、Engine(full/mou
I’ve recently journeyed back into the world of Rails development after an extended stay in more functional languages. One aspect of Ruby that always delights me is its focus on readability. With this focus, along with the ability to fold certain structures, I set out to improve a wordy test. The original test looked like this: select_multiple_from "Which of these apply to you?", [ "I read the New
だいたいぼくは Rails のプロジェクトではテストフレームワークとして Minitest を使っているのですが、だいたい「RSpec しか書いたことなくて Minitest わかんねー」という苦情をいただくので、なんとなく Minitest について、なんか使い方だとか、書き方のコツだとか、なんかそんなようなやつをまとめていこうと思います。 内容は「Minitest Cookbook」の「Rails Recipes」の章を思いっきり参考にさせてもらっています。なので Minitest 自体の説明は少なくて Rails のテストに特化した内容となっています。この本はほとんど唯一の Minitest 本だと思うし、ここで紹介する Rails 絡み以外の部分も良い内容なので読んでおくといいでしょう (そこそこ高いけど) 。 ちなみにこれは「その1」で、まだまだ続く予定ですがいつ書くかは未定です
本ガイドは、Railsでテストを書く方法について解説します。 このガイドの内容: Railsテスティング用語 アプリケーションに対する単体テスト、機能テスト、結合テスト、システムテスト(system test)の実施 その他の著名なテスティング方法とプラグインの紹介 1 Railsアプリケーションでテストを作成する理由 自動実行されるテストを書いておけば、ブラウザやコンソールでの手動テストよりも、コードが期待どおりに動作していることをより短時間で確認できます。テストが失敗すれば問題がすぐに明らかになり、開発プロセスの早い段階でバグを特定して修正できるようになります。テストの自動化によって、コードの信頼性が向上するだけでなく、変更に対する信頼性も向上します。 Railsでは、テストを簡単に記述できます。Railsに組み込まれているテストのサポートについては、次のセクションで詳しく説明します。
Railsのプラグインは、コアフレームワークの拡張や変更に使われます。プラグインは以下の機能を提供します。 安定版コードベースを変更せずに、最先端のアイデアを共有できます。 アーキテクチャを分割して、修正や更新を異なるスケジュールで進められます。 コア開発者が新機能の一部のみを共有するのに使えます。 このガイドの内容: プラグインをゼロから作成する方法 プラグイン用のテストの作成方法と実行方法 本ガイドでは以下を理解するために、テスト駆動方式によるプラグイン開発方法を解説します。 HashやStringなどのコアRubyクラスを拡張する acts_asプラグインと同様の手法でApplicationRecordにメソッドを追加する ジェネレータをプラグインのどこに配置するかを理解する ここからは説明上、自分のことを熱烈なバードウォッチャーであるとお考えください。 あなたは鳥の中でも特にYaf
I tend to use before blocks to set instance variables. I then use those variables across my examples. I recently came upon let(). According to RSpec docs, it is used to ... to define a memoized helper method. The value will be cached across multiple calls in the same example but not across examples. How is this different from using instance variables in before blocks? And also when should you use
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く