Everyday Rails - RSpecによるRailsテスト入門 (パーソナル(シングルユーザーライセンス))
Everyday Rails - RSpecによるRailsテスト入門
テスト駆動開発の習得に向けた実践的アプローチ
本書について
みなさんはこんなふうにRailsアプリケーションを作ったことはありませんか?たとえば、ブラウザをポチポチとクリックするだけでテストを終わらせて「たぶん大丈夫」と思い込んだり、「とにかく全部うまくいきますように」とただ祈るだけだったり……。
心配しないでください。それは誰もが通る道です。アプリケーションのテストやテスト駆動開発はRails開発における重要なトピックですが、巷の参考書を見ると適当な説明で済ませているものも多かったりします。本書「Everyday Rails - RSpecによるRailsテスト入門」では、どのようにして私がそうしたテクニックを身につけたのか、そして、どのようにしてコードの信頼性を上げ、ブラウザ上で延々とテストしなくて済むようにしたきたのかをみなさんに説明します。
対応バージョンについて
2022年1月のアップデートで、本書のコンテンツをRails 7.0とRSpec Rails 5.0に対応させました(さらに2022年11月のアップデートでRSpec Rails 6.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
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
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
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クリックで完了します。払い戻し処理は手作業で行うため、完了まで数日かかる場合があります。詳しくは利用規約をご覧ください。
80% Royalties. Earn $16 on a $20 book.
We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earned$12,307,240writing, publishing and selling on Leanpub.
Learn more about writing on Leanpub
無料更新。無料アップデート。 DRMフリー。
Leanpubの本を購入すると、著者が本を更新している限り、無料で更新されます!多くの著者は、Leanpubを使用して、執筆中の書籍を出版しています。いつ本を購入したか、いくら支払ったかに関係なく、すべての読者は無料のアップデートを入手できます(無料も含む)。
Leanpubの本はPDF(コンピューター用)、EPUB(iPad用)、MOBI(Kindle用)のフォーマットに対応してます。本に含まれるフォーマットは、このページの右上隅に表示されます。
Leanpubの本には、DRMコピー防止のナンセンスがないため、サポートされているデバイスで簡単に読むことができます
Top Books
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.
Personal Finance
Jason AndersonThis textbook provides an in-depth analysis on personal finance that is both practical and straightforward in its approach. It has been written in such a way that the readers can gain knowledge without getting overwhelmed by the technical terms. Suitable for both beginners and advanced learners.
Getting to Know IntelliJ IDEA
Trisha Gee and Helen ScottIf we treat our IDE as a text editor, we are doing ourselves a disservice. Using a combination of tutorials and a questions-and-answers approach, Getting to Know IntelliJ IDEA will help you find ways to use IntelliJ IDEA that enable you to work comfortably and productively as a professional developer.
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:
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.
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.
Machine Learning Q and AI
Sebastian Raschka, PhDHave you recently completed a machine learning or deep learning course and wondered what to learn next? With 30 questions and answers on key concepts in machine learning and AI, this book provides bite-sized bits of knowledge for your journey to becoming a machine learning expert.
Stats One
William FooteThe Rails 7 Way
Obie Fernandez, Lucas Dohmen, and Tom Henrik AadlandThe Rails™ 7 Way is the comprehensive, authoritative reference guide for professionals delivering production-quality code using modern Ruby on Rails. It illuminates the entire Rails 7 API, its most powerful idioms, design approaches, and libraries. Building on the previous editions, this edition has been heavily refactored and updated.
Gradual Modularization for Ruby and Rails
Stephan HagemannGet yourself a new tool to manage your Rails application and your growing engineering organization! Prevent the ball-of-mud (and fix it!). Go for microservices or SOA if it makes sense not just because you don't have any other tool. Do all this through a low-overhead tool: packages. Enable better conversations to make practical changes today.
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... - #3
1500 QUIZ COMMENTATI (3 libri)
3 Books
Tre libri dei QUIZ MMG Commentati al prezzo di DUE! I QUIZ dei concorsi ufficiali di Medicina Generale relativi agli anni: 2000-2001-2003-2012-2013-2014-2015-2016-2017-2018-2019-2020-2021 +100 inediti Raccolti in unico bundle per aiutarvi nello studio e nella preparazione al concorso. All'interno di ogni libro i quiz sono stati suddivisi per... - #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... - #5
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!? - #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
Linux Administration Complet
4 Books
Ce lot comprend les quatre volumes du Guide Linux Administration :Linux Administration, Volume 1, Administration fondamentale : Guide pratique de préparation aux examens de certification LPIC 1, Linux Essentials, RHCSA et LFCS. Administration fondamentale. Introduction à Linux. Le Shell. Traitement du texte. Arborescence de fichiers. Sécurité... - #9
Development and Deployment of Multiplayer Online Games, Part ARCH. Architecture (Vol. I-III)
3 Books
What's the Big Idea? The idea behind this book is to summarize the body of knowledge that already exists on multiplayer games but is not available in one single place.And quite a fewof the issues discussed within this series (planned as three nine volumes ~300 pages each), while known in the industry, have not been published at all (except for... - #10
Growing Agile: The Complete Coach's Guide
7 Books
Growing Agile: Coach's Guide Series This bundle provides a collection of training and workshop plans for a variety of agile topics. The series is aimed at agile coaches, trainers and ScrumMasters who often find themselves needing to help teams understand agile concepts. Each book in the series provides the plans, slides, handouts and activity...