Skip to content

Commit e25d738

Browse files
authored
Merge pull request rails#54299 from memorycancel/small-fix-of-testing-guide
Doc: Using assert_select in guide of testing
2 parents e201aab + 4b91aa8 commit e25d738

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

guides/source/testing.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,15 +1334,15 @@ require "test_helper"
13341334
class BlogFlowTest < ActionDispatch::IntegrationTest
13351335
test "can see the welcome page" do
13361336
get "/"
1337-
assert_selector "h1", "Welcome#index"
1337+
assert_select "h1", "Welcome#index"
13381338
end
13391339
end
13401340
```
13411341

13421342
If you visit the root path, you should see `welcome/index.html.erb` rendered for
13431343
the view. So this assertion should pass.
13441344

1345-
NOTE: The assertion `assert_selector` is available in integration tests to check
1345+
NOTE: The assertion `assert_select` is available in integration tests to check
13461346
the presence of key HTML elements and their content. It is similar to
13471347
`assert_dom`, which should be used when [testing views](#testing-views) as
13481348
outlined in the section below.
@@ -1439,7 +1439,7 @@ class UsersTest < ApplicationSystemTestCase
14391439
# test "visiting the index" do
14401440
# visit users_url
14411441
#
1442-
# assert_selector "h1", text: "Users"
1442+
# assert_select "h1", text: "Users"
14431443
# end
14441444
end
14451445
```
@@ -1578,7 +1578,7 @@ require "application_system_test_case"
15781578
class ArticlesTest < ApplicationSystemTestCase
15791579
test "viewing the index" do
15801580
visit articles_path
1581-
assert_selector "h1", text: "Articles"
1581+
assert_select "h1", text: "Articles"
15821582
end
15831583
end
15841584
```
@@ -1654,7 +1654,7 @@ require "mobile_system_test_case"
16541654
class PostsTest < MobileSystemTestCase
16551655
test "visiting the index" do
16561656
visit posts_url
1657-
assert_selector "h1", text: "Posts"
1657+
assert_select "h1", text: "Posts"
16581658
end
16591659
end
16601660
```
@@ -1671,7 +1671,7 @@ which can be used in system tests.
16711671
| `assert_current_path(string, **options)` | Asserts that the page has the given path. |
16721672
| `assert_field(locator = nil, **options, &optional_filter_block)` | Checks if the page has a form field with the given label, name or id. |
16731673
| `assert_link(locator = nil, **options, &optional_filter_block)` | Checks if the page has a link with the given text or id. |
1674-
| `assert_selector(*args, &optional_filter_block)` | Asserts that a given selector is on the page. |
1674+
| `assert_select(*args, &optional_filter_block)` | Asserts that a given selector is on the page. |
16751675
| `assert_table(locator = nil, **options, &optional_filter_block` | Checks if the page has a table with the given id or caption. |
16761676
| `assert_text(type, text, **options)` | Asserts that the page has the given text content. |
16771677

0 commit comments

Comments
 (0)