Skip to content

Commit 3b53b94

Browse files
committed
word-smithing
1 parent c961bc9 commit 3b53b94

1 file changed

Lines changed: 36 additions & 16 deletions

File tree

README.md

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ What it does:
1919
app**
2020

2121
* Exposes a simple API for ensuring that your data will be pristine for each of
22-
your tests, whether the test depends on test_data, an empty database, or Rails
23-
fixtures
22+
your tests, whether the test depends on test_data, factories, fixtures, or an
23+
empty database
2424

2525
* Safeguards your tests from flaky failures and supercharges your build by
2626
providing a sophisticated transaction manager that isolates each test while
@@ -41,11 +41,11 @@ are required**—so it may not work for every project just yet.]_
4141

4242
This gem requires a lot of documentation—not because `test_data` does a lot of
4343
things, but because managing one's test data is an inherently complex task. If
44-
one reason Rails apps chronically suffer from slow tests is that other
45-
approaches oversimplify test data management, it stands to reason that any
46-
discomfort caused by `test_data`'s scope may not be _unnecessary complexity_ but
47-
instead be an indication of how little of the problem's _essential complexity_
48-
we have reckoned with to this point.
44+
there's one reason Rails apps often suffer from slow tests, it's that the most
45+
popular approaches to test data management oversimplify the problem—they might
46+
save time up front, but tend to cost you later. The `test_data` gem, meanwhile,
47+
is designed to tackle the problem head on: it takes longer to set up, but it'll
48+
scale along with your application for years to come.
4949

5050
1. [Getting Started Guide](#getting-started-guide)
5151
1. [Install and initialize `test_data`](#step-1-install-and-initialize-test_data)
@@ -106,22 +106,42 @@ And if you get stuck or need help as you're getting started, please feel free to
106106

107107
### Step 1: Install and initialize `test_data`
108108

109-
#### Adding the gem
109+
#### Adding a `:test_data` group to your Gemfile
110+
111+
Before even installing anything, it's important to understand that because
112+
`test_data` defines a new Rails environment and because Rails expects
113+
a gem group (like `:development`, `:test`, and `:production`) for each
114+
environment, any gems we want to be available to the `test_data` gem need to be
115+
installed with a `:test_data` group.
110116

111-
First, add `test_data` to your Gemfile. Either include it in all groups or add
112-
it to the `:development`, `:test`, and (the all new!) `:test_data` gem groups:
117+
Since the `test_data` environment is designed to be used similarly to
118+
`development` (i.e. with a running server and interacting via a browser), any
119+
gems in your `:development` gem group should likely be included in a
120+
`:test_data` gem group as well.
121+
122+
For example, this:
113123

114124
```ruby
115-
group :development, :test, :test_data do
125+
group :development, :test do
126+
gem "standard"
127+
gem "cypress-rails"
116128
gem "test_data"
117-
# … other gems available to development & test
118129
end
119130
```
120131

121-
Since the `test_data` environment is designed to be used similarly to
122-
`development` (i.e. with a running server and interacting via a browser), any
123-
gems in your `:development` gem group should likely be included in a
124-
`:test_data` gem group as well.
132+
Should have its first line changed to:
133+
134+
```ruby
135+
group :development, :test, :test_data do
136+
```
137+
138+
#### Adding the gem
139+
140+
Finally, add `test_data` to your Gemfile and `bundle install` it:
141+
142+
```ruby
143+
gem "test_data"
144+
```
125145

126146
#### Configuring the gem and initializing the database
127147

0 commit comments

Comments
 (0)