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,595,069稼ぎ、80% royalties儲けました。最大2500万ポンドのCO2を節約し、最大46,000本の木を助ける事が出来ました。
Leanpubでの執筆についてもっと知る
無料更新。無料アップデート。 DRMフリー。
Leanpubの本を購入すると、著者が本を更新している限り、無料で更新されます!多くの著者は、Leanpubを使用して、執筆中の書籍を出版しています。いつ本を購入したか、いくら支払ったかに関係なく、すべての読者は無料のアップデートを入手できます(無料も含む)。
Leanpubの本はPDF(コンピューター用)、EPUB(iPad用)、MOBI(Kindle用)のフォーマットに対応してます。本に含まれるフォーマットは、このページの右上隅に表示されます。
Leanpubの本には、DRMコピー防止のナンセンスがないため、サポートされているデバイスで簡単に読むことができます
Top Books
C++20 - The Complete Guide
Nicolai M. JosuttisAll the new language and library features of C++20 (for those who know previous 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:
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.
SignalR on .NET 6 - the Complete Guide
Fiodar SazanavetsLearn everything there is to learn about SignalR and how to integrate it with the latest .NET 6 and C# 10 features. Learn how to connect any type of client to SignalR, including plain WebSocket client. Learn how to build interactive applications that can communicate with each other in real time without making excessive calls.
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.
R Programming for Data Science
Roger D. PengThis book brings the fundamentals of R programming to you, using the same material developed as part of the industry-leading Johns Hopkins Data Science Specialization. The skills taught in this book will lay the foundation for you to begin your journey learning data science. Printed copies of this book are available through Lulu.
The easiest way to learn design patterns
Fiodar SazanavetsLearn design patterns in the easiest way possible. You will no longer have to brute-force your way through each one of them while trying to figure out how it works. The book provides a unique methodology that will make your understanding of design patterns stick. It can also be used as a reference book where you can find design patterns in seconds.
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.
CCIE Service Provider Version 4 Written and Lab Exam Comprehensive Guide
Nicholas RussoThe service provider landscape has changed rapidly over the past several years. Networking vendors are continuing to propose new standards, techniques, and procedures for overcoming new challenges while concurrently reducing costs and delivering new services. Cisco has recently updated the CCIE Service Provider track to reflect these changes; this book represents the author's personal journey in achieving that certification.
Cronache di Domain-Driven Design
Francesco Strazzullo, Matteo Baglini, Gianluca Padovani, Emanuele DelBono, Marco Consolaro, Alessandro Colla, Uberto Barbini, Alberto Acerbis, Julie Camosseto, DDD Open, and Alberto BrandoliniCronache di Domain-Driven Design: un libro corale in italiano fatto di storie indipendenti tra loro, che sono il risultato dell’applicazione di Domain-Driven Design su progetti reali.
Functional event-driven architecture: Powered by Scala 3
Gabriel VolpeExplore the event-driven architecture (EDA) in a purely functional way, mainly powered by Fs2 streams in Scala 3!
Leverage your functional programming skills by designing and writing stateless microservices that scale, powered by stateful message brokers.
Top Bundles
- #1
Practical FP in Scala + Functional event-driven architecture
2 Books
Practical FP in Scala (A hands-on approach) & Functional event-driven architecture, aka FEDA, (Powered by Scala 3), together as a bundle! The content of PFP in Scala is a requirement to understand FEDA so why not take advantage of this bundle!? - #2
Software Architecture for Developers: Volumes 1 & 2 - Technical leadership and communication
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... - #3
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... - #4
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... - #6
Modern C++ Collection
3 Books
Get All about Modern C++C++ Standard Library, including C++20Concurrency with Modern C++, including C++20C++20Each book has about 200 complete code examples. Updates are included. When I update one of the books, you immediately get the updated bundle. You can expect significant updates to each new C++ standard (C++23, C++26, .. ) and also... - #7
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...