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
Two ways for testing preloading/eager-loading of ActiveRecord associations in Rails … and check why 5600+ Rails engineers read also this Two ways for testing preloading/eager-loading of ActiveRecord associations in Rails As a developer who cares about performance you know to avoid N+1 queries by using #includes, #preload or #eager_load methods . But is there a way of checking out that you are doin
はじめに 2015年6月12日にRSpec 3.3がリリースされました。 APIが大きく変更されたり、派手な新機能が追加されたりはしていませんが、うまく活用するとテストを効率よく書いていけそうな実践的な新機能がたくさん導入されています。 この記事ではそんなRSpec 3.3の新機能を紹介していきます。 新機能一覧 RSpec 3.3で追加された主な新機能は以下の11個です。 これから各新機能の内容を紹介していきます。 特定のエクスペクテーション群をまとめて検証できる(aggregate_failures メソッド) グループやexampleをID指定して実行できる 失敗したテストだけを再実行できる(--only-failures オプション) 失敗したテストを1件ずつ修正できる(--next-failure オプション) テストが増減しても seed を指定したランダム実行が同じ順序で実行
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
ジョブの実行をテストしたいとき、キューに入ったことをテストしたいだけのときと、その実行結果まで含めてテストしたいとき(つまり同期実行したいとき)がある。 前者であればRails.application.config.active_job.queue_adapter = :testで足りるが、後者を実現するためにはどうすればよいだろう。 方法はいくつかあって、まずはRails.application.config.active_job.queue_adapter = :inlineとする方法。 これは簡単に同期実行は実現できるが、こんどはキューに入ったことが確認できなくなってしまうし、他の非同期のままにしておきたいところまで影響がでてしまう。 またSidekiqを使っているのであればSidekiq::Testing.inline!やSidekiq::Testing.fake! で制御すること
Active Jobの導入手順と、Active Job周りのRSpecの書き方をちゃんと理解していなかったので、英語の勉強も兼ねて、 『Active Job Basics — Ruby on Rails Guides』 を読んでみました! 🚌 Active JobとはActive Jobはジョブを宣言し、バックエンドでキュー操作を抽象化して実行するためのフレームワーク。 🗻 ジョブの作成ジョブの作成コマンドはこちら。 $ bin/rails generate job guests_cleanup invoke test_unit create test/jobs/guests_cleanup_job_test.rb create app/jobs/guests_cleanup_job.rb class GuestsCleanupJob < ActiveJob::Base queue_a
TDD was getting painful. Switching back and forth from my terminal to text editor running my latest RSpec tests saw me spending way too much time waiting not for my tests to run, but RSpec to load. Here is an example running RSpec with one new test packaged with a feature: Good lord! I understand the 15 seconds as this was quite a hefty feature test, but waiting 30 extra seconds every time I want
At Appaloosa, most of our tests are written with Rspec, but we still have a certain amount of legacy Test Unit tests. Our Rspec and Test-Unit suites take up to 10 minutes each, so a full test suite runs in around 20 minutes. That’s a lot. We recently decided to invest time on improving our tests to gain time when developing. Recurring problems and how to avoid thembuild vs build_stubbed vs createW
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く