aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source
diff options
context:
space:
mode:
authorKir Shatrov <shatrov@me.com>2014-12-30 23:55:22 +0100
committerKir Shatrov <shatrov@me.com>2015-01-03 20:16:06 +0100
commit1ffd1a305c51856da09dcac43781e7f2d1b6e633 (patch)
tree92d563c4b865b81e41d1a14de86e89700620ff59 /guides/source
parent4b9dba99d65b1bd27576b16a68d7d18522bae9ea (diff)
downloadrails-1ffd1a305c51856da09dcac43781e7f2d1b6e633.tar.gz
rails-1ffd1a305c51856da09dcac43781e7f2d1b6e633.tar.bz2
rails-1ffd1a305c51856da09dcac43781e7f2d1b6e633.zip
Section about testing xhr requests
rails/rails#18305
Diffstat (limited to 'guides/source')
-rw-r--r--guides/source/testing.md13
1 files changed, 13 insertions, 0 deletions
diff --git a/guides/source/testing.md b/guides/source/testing.md
index 21b0b37efa..308d744d71 100644
--- a/guides/source/testing.md
+++ b/guides/source/testing.md
@@ -528,6 +528,19 @@ All of request types have equivalent methods that you can use. In a typical C.R.
NOTE: Functional tests do not verify whether the specified request type is accepted by the action, we're more concerned with the result. Request tests exist for this use case to make your tests more purposeful.
+### Testing XHR (AJAX) requests
+
+`xhr` accepts method (listed in the section above), action name and parameters:
+
+```ruby
+test "ajax request responds with no layout" do
+ xhr :get, :show, id: articles(:first).id
+
+ assert_template :index
+ assert_template layout: nil
+end
+```
+
### The Four Hashes of the Apocalypse
After a request has been made and processed, you will have 4 Hash objects ready for use: