Everyday Rails - RSpecによるRailsテスト入門 (パーソナル(シングルユーザーライセンス))
Everyday Rails - RSpecによるRailsテスト入門
テスト駆動開発の習得に向けた実践的アプローチ
本書について
みなさんはこんなふうにRailsアプリケーションを作ったことはありませんか?たとえば、ブラウザをポチポチとクリックするだけでテストを終わらせて「たぶん大丈夫」と思い込んだり、「とにかく全部うまくいきますように」とただ祈るだけだったり……。
心配しないでください。それは誰もが通る道です。アプリケーションのテストやテスト駆動開発はRails開発における重要なトピックですが、巷の参考書を見ると適当な説明で済ませているものも多かったりします。本書「Everyday Rails - RSpecによるRailsテスト入門」では、どのようにして私がそうしたテクニックを身につけたのか、そして、どのようにしてコードの信頼性を上げ、ブラウザ上で延々とテストしなくて済むようにしたきたのかをみなさんに説明します。
対応バージョンについて
2022年1月のアップデートで、本書のコンテンツをRails 7.0とRSpec Rails 5.0に対応させました。これは日本語版独自のアップデートです。詳細はこちらのブログ記事をご覧ください。
チームパッケージについて
チームパッケージは本書をチーム内で共有するためのパッケージです。シングルユーザーライセンスよりもお求めやすい価格設定になっています。ご利用方法は以下の通りです。
- パッケージを購入された方(代表者)が電子書籍ファイル(PDF、EPUB、MOBI)をダウンロードして下さい。
- ダウンロードしたファイルをチーム内で共有して下さい。
- パッケージで指定された人数までであれば、誰でも本書を自由に読むことが可能です。
ライセンスに関する備考
- ライセンス数は「最大同時貸出人数」を表します。
- たとえば3コピーライセンスの場合、5人のチームであっても同時に3人以内であれば、自由にメンバーを変えて読むことができます。
- 電子書籍ファイルはDRMフリーであるため、システム的な制限(ネット経由のアクティベーション等)は特にありません。
ライセンスに関して何かご不明な点があれば、以下のGitHub issuesにてお問い合わせ下さい。
https://github.com/JunichiIto/everydayrails-rspec-jp-2022/issues
パッケージ
パーソナル(シングルユーザーライセンス)
個人で購入される場合はこちらを選択して下さい。
Includes:
RSpec 2.14-2.99 edition
RSpec 2.14-2.99に対応した以前の版です。
Rails 4.2 / RSpec 3.1 edition
Rails 4.2 / RSpec 3.1に対応した以前の版です。 日本語版独自の追加コンテンツとして提供していた「RSpecユーザのためのMinitestチュートリアル」も含まれます。
Rails 5.1 / RSpec Rails 3.6 edition
Rails 5.1 / RSpec Rails 3.6に対応した以前の版(原著と同じ内容の版)です。
PDF
EPUB
MOBI
WEB
日本語
スモールチームパッケージ(3コピーライセンス)
小規模チーム向けのパッケージです。このパッケージには3人分のライセンスが含まれます。
Includes:
RSpec 2.14-2.99 edition
RSpec 2.14-2.99に対応した以前の版です。
Rails 4.2 / RSpec 3.1 edition
Rails 4.2 / RSpec 3.1に対応した以前の版です。 日本語版独自の追加コンテンツとして提供していた「RSpecユーザのためのMinitestチュートリアル」も含まれます。
Rails 5.1 / RSpec Rails 3.6 edition
Rails 5.1 / RSpec Rails 3.6に対応した以前の版(原著と同じ内容の版)です。
PDF
EPUB
MOBI
WEB
日本語
ラージチームパッケージ(10コピーライセンス)
大規模チーム向けのパッケージです。このパッケージには10人分のライセンスが含まれます。
Includes:
RSpec 2.14-2.99 edition
RSpec 2.14-2.99に対応した以前の版です。
Rails 4.2 / RSpec 3.1 edition
Rails 4.2 / RSpec 3.1に対応した以前の版です。 日本語版独自の追加コンテンツとして提供していた「RSpecユーザのためのMinitestチュートリアル」も含まれます。
Rails 5.1 / RSpec Rails 3.6 edition
Rails 5.1 / RSpec Rails 3.6に対応した以前の版(原著と同じ内容の版)です。
PDF
EPUB
MOBI
WEB
日本語
目次
- この版のまえがき
- 日本語版のまえがき
- 謝辞
- 日本語版独自のアップデート内容について
-
1. イントロダクション
- なぜRSpecなのか?
- 対象となる読者
- 私が考えるテストの原則
- 本書の構成
- サンプルコードのダウンロード
- コードの方針
- 間違いを見つけた場合
- gemのバージョンに関する注意点
- サンプルアプリケーションについて
- サンプルアプリケーションのセットアップ手順
-
2. RSpecのセットアップ
- Gemfile
- テストデータベース
- RSpecの設定
- 試してみよう!
-
rspec
binstubを使って短いコマンドで実行できるようにする - ジェネレータ
- まとめ
- Q&A
- 演習問題
-
3. モデルスペック
- モデルスペックの構造
- モデルスペックを作成する
- RSpecの構文
- バリデーションをテストする
- インスタンスメソッドをテストする
- クラスメソッドとスコープをテストする
- 失敗をテストする
- マッチャについてもっと詳しく
- describe、context、before、afterを使ってスペックをDRYにする
- まとめ
- Q&A
- 演習問題
-
4. 意味のあるテストデータの作成
- ファクトリ対フィクスチャ
- Factory Botをインストールする
- アプリケーションにファクトリを追加する
- シーケンスを使ってユニークなデータを生成する
- ファクトリで関連を扱う
- ファクトリ内の重複をなくす
- コールバック
- ファクトリを安全に使うには
- まとめ
- 演習問題
-
5. コントローラスペック
- コントローラスペックの基本
- 認証が必要なコントローラスペック
- ユーザー入力をテストする
- ユーザー入力のエラーをテストする
- HTML以外の出力を扱う
- まとめ
- Q&A
- 演習問題
-
6. システムスペックでUIをテストする
- なぜシステムスペックなのか?
- システムスペックで使用するgem
- システムスペックの基本
- CapybaraのDSL
- システムスペックをデバッグする
- JavaScriptを使った操作をテストする
- ヘッドレスドライバを使う
- JavaScriptの完了を待つ
- スクリーンショットを使ってデバッグする
- システムスペックとフィーチャスペック
- まとめ
- 演習問題
-
7. リクエストスペックでAPIをテストする
- リクエストスペックとシステムスペックの比較
- GETリクエストをテストする
- POSTリクエストをテストする
- コントローラスペックをリクエストスペックで置き換える
- まとめ
- 演習問題
-
8. スペックをDRYに保つ
- サポートモジュール
-
let
で遅延読み込みする - shared_context (contextの共有)
- カスタムマッチャ
- aggregate_failures (失敗の集約)
- テストの可読性を改善する
- まとめ
- 演習問題
-
9. 速くテストを書き、速いテストを書く
- RSpecの簡潔な構文
- エディタのショートカット
- モックとスタブ
- タグ
- 不要なテストを削除する
- テストを並列に実行する
- Railsを取り外す
- まとめ
- 演習問題
-
10. その他のテスト
- ファイルアップロードのテスト
- バックグラウンドワーカーのテスト
- メール送信をテストする
- Webサービスをテストする
- まとめ
- 演習問題
-
11. テスト駆動開発に向けて
- フィーチャを定義する
- レッドからグリーンへ
- 外から中へ進む(Going outside-in)
- レッド・グリーン・リファクタのサイクル
- まとめ
- 演習問題
-
12. 最後のアドバイス
- 小さなテストで練習してください
- 自分がやっていることを意識してください
- 短いスパイクを書くのはOKです
- 小さくコードを書き、小さくテストするのもOKです
- 統合スペックを最初に書こうとしてください
- テストをする時間を作ってください
- 常にシンプルにしてください
- 古い習慣に戻らないでください!
- テストを使ってコードを改善してください
- 自動テストのメリットを周りの人たちに売り込んでください
- 練習し続けてください
- それではさようなら
-
Railsのテストに関するさらなる情報源
- RSpec
- Railsのテスト
-
訳者あとがき
- 伊藤淳一
-
日本語版の謝辞
- 改訂版(2017年)の謝辞
- 初版の謝辞
- Everyday Railsについて
- 著者について
-
訳者紹介
- 伊藤淳一
- カバーの説明
- 変更履歴
Leanpubは無条件かつノーリスクで100%の満足を保証します
Leanpubでお買い上げいただいた書籍は、ご購入後60日以内であれば全額返金いたします。払い戻しはわずか2クリックで完了します。払い戻し処理は手作業で行うため、完了まで数日かかる場合があります。詳しくは利用規約をご覧ください。
Do Well. Do Good.
著者はLeanpubで執筆、出版、販売を利用して$11,714,583稼ぎ、80% royalties儲けました。最大2500万ポンドのCO2を節約し、最大46,000本の木を助ける事が出来ました。
Leanpubでの執筆についてもっと知る
無料更新。無料アップデート。 DRMフリー。
Leanpubの本を購入すると、著者が本を更新している限り、無料で更新されます!多くの著者は、Leanpubを使用して、執筆中の書籍を出版しています。いつ本を購入したか、いくら支払ったかに関係なく、すべての読者は無料のアップデートを入手できます(無料も含む)。
Leanpubの本はPDF(コンピューター用)、EPUB(iPad用)、MOBI(Kindle用)のフォーマットに対応してます。本に含まれるフォーマットは、このページの右上隅に表示されます。
Leanpubの本には、DRMコピー防止のナンセンスがないため、サポートされているデバイスで簡単に読むことができます
Top Books
Recipes for Decoupling
Matthias NobackWrite software that survives
OpenIntro Statistics
David Diez, Christopher Barr, Mine Cetinkaya-Rundel, and OpenIntroA complete foundation for Statistics, also serving as a foundation for Data Science.
Leanpub revenue supports OpenIntro (US-based nonprofit) so we can provide free desk copies to teachers interested in using OpenIntro Statistics in the classroom and expand the project to support free textbooks in other subjects.
More resources: openintro.org.
C++20 - The Complete Guide
Nicolai M. JosuttisAll new language and library features of C++20 (for those who know previous C++ versions).
The book presents all new language and library features of C++20. Learn how this impacts day-to-day programming, to benefit in practice, to combine new features, and to avoid all new traps.
Buy early, pay less, free updates.
Other books:
CQRS by Example
Carlos Buenosvinos, Christian Soronellas, and Keyvan Akbary- Leverage your Software Architecture skills by learning everything about CQRS in detail with lots of examples
- Develop faster applications by applying CQRS and fostering Read Models and Projections
- Learn how to apply CQRS into a brownfield project from a pragmatic approach
Ansible for DevOps
Jeff GeerlingAnsible is a simple, but powerful, server and configuration management tool. Learn to use Ansible effectively, whether you manage one server—or thousands.
Maîtriser Apache JMeter
Philippe Mouawad, Bruno Demion (Milamber), and Antonio Gomes RodriguesToute la puissance d'Apache JMeter expliquée par ses commiteurs et utilisateurs experts. De l'intégration continue en passant par le Cloud, vous découvrirez comment intégrer JMeter à vos processus "Agile" et Devops.
If you're looking for the newer english version of this book, go to Master JMeter : From load testing to DevOps
Jetpack Compose internals
Jorge CastilloJetpack Compose is the future of Android UI. Master how it works internally and become a more efficient developer with it. You'll also find it valuable if you are not an Android dev. This book provides all the details to understand how the Compose compiler & runtime work, and how to create a client library using them.
The PowerShell Scripting and Toolmaking Book
Don Jones and Jeff HicksLearn the patterns, practices, and details of PowerShell Scripting and Toolmaking from the industry's two most recognized experts on the subject.
Mastering STM32 - Second Edition
Carmine NovielloWith more than 1200 microcontrollers, STM32 is probably the most complete ARM Cortex-M platform on the market. This book aims to be the most complete guide around introducing the reader to this exciting MCU portfolio from ST Microelectronics and its official CubeHAL and STM32CubeIDE development environment.
Introduction to Data Science
Rafael A IrizarryThe demand for skilled data science practitioners in industry, academia, and government is rapidly growing. This book introduces concepts from probability, statistical inference, linear regression and machine learning and R programming skills. Throughout the book we demonstrate how these can help you tackle real-world data analysis challenges.
Top Bundles
- #1
Software Architecture
2 Books
"Software Architecture for Developers" is a practical and pragmatic guide to modern, lightweight software architecture, specifically aimed at developers. You'll learn:The essence of software architecture.Why the software architecture role should include coding, coaching and collaboration.The things that you really need to think about before... - #2
CCIE Service Provider Ultimate Study Bundle
2 Books
Piotr Jablonski, Lukasz Bromirski, and Nick Russo have joined forces to deliver the only CCIE Service Provider training resource you'll ever need. This bundle contains a detailed and challenging collection of workbook labs, plus an extensively detailed technical reference guide. All of us have earned the CCIE Service Provider certification... - #4
Pattern-Oriented Memory Forensics and Malware Detection
2 Books
This training bundle for security engineers and researchers, malware and memory forensics analysts includes two accelerated training courses for Windows memory dump analysis using WinDbg. It is also useful for technical support and escalation engineers who analyze memory dumps from complex software environments and need to check for possible... - #6
All the Books of The Medical Futurist
6 Books
We put together the most popular books from The Medical Futurist to provide a clear picture about the major trends shaping the future of medicine and healthcare. Digital health technologies, artificial intelligence, the future of 20 medical specialties, big pharma, data privacy, digital health investments and how technology giants such as Amazon...