Rails 5 がリリースされました。多分目玉としては ActionCable の導入なのですが、既存コードベースのアップグレードに関して一番重要な問題は、コントローラーテストが廃止されるというものになるのではないでしょうか。 というわけで気持ちになってやっていきます。 一般的に今でも Rails のテストの記述には RSpec が用いられることが多いのではないでしょうか。僕も以前 RSpec の記法のメリットについて書きました。ですが私達のチームでは RSpec ではなく test-unit を使っています。理由としては RSpec のマッチャーとかの記法がヤバくなった(こういう話) xUnit のアサーションの方が書きやすくね?という RSpec の context は確かに強力な機能だが実際には特に生かされていなかった RSpec のメンテナのアイコンがキモい というわけですから私達
目的 以下の2点により、本記事をまとめました。 いろいろググって試したりしたけど、なんだかうまくいかなかった Deviseの公式を翻訳してみたけど、公式としてIntegration Testはできないよって書いてあった 参考にしたところ 最終的には、このサイトの通りでうまく行きました。 やったこと spec/spec_helper.rbのRSpec.configure do |config|のところに以下を追加した。 RSpec.configure do |config| # Devise config.include Warden::Test::Helpers config.before :suite do Warden.test_mode! end end
rspec_rails_cheetsheet.rb ���6V P �6V #Model @user.should have(1).error_on(:username) # Checks whether there is an error in username @user.errors[:username].should include("can't be blank") # check for the error message #Rendering response.should render_template(:index) #Redirecting response.should redirect_to(movies_path) #Capybara Matchers response.body.should have_content("Hello world") respons
みなさんはこんなふうにRailsアプリケーションを作ったことはありませんか?たとえば、ブラウザをポチポチとクリックするだけでテストを終わらせて「たぶん大丈夫」と思い込んだり、「とにかく全部うまくいきますように」とただ祈るだけだったり……。 心配しないでください。それは誰もが通る道です。アプリケーションのテストやテスト駆動開発はRails開発における重要なトピックですが、巷の参考書を見ると適当な説明で済ませているものも多かったりします。本書「Everyday Rails - RSpecによるRailsテスト入門」では、どのようにして私がそうしたテクニックを身につけたのか、そして、どのようにしてコードの信頼性を上げ、ブラウザ上で延々とテストしなくて済むようにしたきたのかをみなさんに説明します。 対応バージョンについて2024年1月のアップデートで、本書のコンテンツをRails 7.1とRSpe
はじめに 先日、MinitestとRSpecを比較するこんな記事を書きました。 blog.jnito.com MinitestとRSpecの比較記事はネットにたくさんありますが、その中の一つにRSpecのメイン開発者であるMyron Marston氏によって書かれた記事(回答)がStackoverflowに載っています。 ruby on rails - Minitest and Rspec - Stack Overflow 2012年9月の回答なので現在では状況が変わっている点も多少あるかもしれませんが、なかなか興味深い内容だったので翻訳してみました。 質問:MinitestとRSpecについて ついさっきMinitestを解説しているRailscastを視聴しました。 Railsアプリケーションをテストする場合、RSpecとMinitestではどのような長所と短所がありますか? RSpe
translations Documentation RSpec is a great tool in the behavior-driven development (BDD) process of writing human readable specifications that direct and validate the development of your application. On the web there are many resources that give complete overview of _what_ you can do with RSpec. But there are fewer resources devoted to how to create a great RSpec test suite. Better Specs tries to
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く