diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2019-01-16 20:23:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-16 20:23:51 +0100 |
commit | 7e52e3b1c004eb22521c844b6adf69a2689cc1da (patch) | |
tree | cc79ff2e45951541fb8e2d2802c05adab0e5738a /guides/source | |
parent | 80873a49af6f52d48224d9c18c60e67c3f9d4731 (diff) | |
parent | d7097cf5e00faf2ac4d02bd1a5c37801671ce70c (diff) | |
download | rails-7e52e3b1c004eb22521c844b6adf69a2689cc1da.tar.gz rails-7e52e3b1c004eb22521c844b6adf69a2689cc1da.tar.bz2 rails-7e52e3b1c004eb22521c844b6adf69a2689cc1da.zip |
Merge pull request #34947 from bogdanvlviv/actioncable-testing-34933
Add `rails test:channels` and fix Action Cable templates
Diffstat (limited to 'guides/source')
-rw-r--r-- | guides/source/testing.md | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/guides/source/testing.md b/guides/source/testing.md index 576c4d768c..1a2f480407 100644 --- a/guides/source/testing.md +++ b/guides/source/testing.md @@ -1735,14 +1735,14 @@ Testing Action Cable -------------------- Since Action Cable is used at different levels inside your application, -you'll need to test both the channels and connection classes themsleves and that other +you'll need to test both the channels, connection classes themselves, and that other entities broadcast correct messages. ### Connection Test Case By default, when you generate new Rails application with Action Cable, a test for the base connection class (`ApplicationCable::Connection`) is generated as well under `test/channels/application_cable` directory. -Connection tests aim to check whether a connection's identifiers gets assigned properly +Connection tests aim to check whether a connection's identifiers get assigned properly or that any improper connection requests are rejected. Here is an example: ```ruby @@ -1765,9 +1765,8 @@ end You can also specify request cookies the same way you do in integration tests: - ```ruby -test "connects with_cookies" do +test "connects with cookies" do cookies.signed[:user_id] = "42" connect @@ -1778,7 +1777,6 @@ end See the API documentation for [`AcionCable::Connection::TestCase`](http://api.rubyonrails.org/classes/ActionCable/Connection/TestCase.html) for more information. - ### Channel Test Case By default, when you generate a channel, an associated test will be generated as well @@ -1823,7 +1821,7 @@ See the API documentation for [`AcionCable::Channel::TestCase`](http://api.rubyo Action Cable ships with a bunch of custom assertions that can be used to lessen the verbosity of tests. For a full list of available assertions, see the API documentation for [`ActionCable::TestHelper`](http://api.rubyonrails.org/classes/ActionCable/TestHelper.html). -It's a good practice to ensure that the correct message has been broadcasted inside another components (e.g. inside your controllers). This is precisely where +It's a good practice to ensure that the correct message has been broadcasted inside other components (e.g. inside your controllers). This is precisely where the custom assertions provided by Action Cable are pretty useful. For instance, within a model: |