aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source
diff options
context:
space:
mode:
authorPrem Sichanugrist <s@sikachu.com>2012-09-02 13:08:06 -0400
committerPrem Sichanugrist <s@sikac.hu>2012-09-17 15:54:23 -0400
commit2c38567646791f223b4e48550fba0e0386a05d96 (patch)
treec9a218e052d5c59aebce5c6a29d436953bc57a1c /guides/source
parent9873dd800b77105fe17f583f0d036240ef334826 (diff)
downloadrails-2c38567646791f223b4e48550fba0e0386a05d96.tar.gz
rails-2c38567646791f223b4e48550fba0e0386a05d96.tar.bz2
rails-2c38567646791f223b4e48550fba0e0386a05d96.zip
Convert all tables to Markdown syntax
Diffstat (limited to 'guides/source')
-rw-r--r--guides/source/action_controller_overview.md40
-rw-r--r--guides/source/active_record_basics.md13
-rw-r--r--guides/source/active_support_core_extensions.md3
-rw-r--r--guides/source/active_support_instrumentation.md201
-rw-r--r--guides/source/caching_with_rails.md13
-rw-r--r--guides/source/getting_started.md17
-rw-r--r--guides/source/i18n.md45
-rw-r--r--guides/source/migrations.md14
-rw-r--r--guides/source/performance_testing.md68
-rw-r--r--guides/source/rails_on_rack.md7
-rw-r--r--guides/source/routing.md119
-rw-r--r--guides/source/testing.md128
12 files changed, 359 insertions, 309 deletions
diff --git a/guides/source/action_controller_overview.md b/guides/source/action_controller_overview.md
index 531fcc6e64..2db11a6c31 100644
--- a/guides/source/action_controller_overview.md
+++ b/guides/source/action_controller_overview.md
@@ -582,18 +582,19 @@ In every controller there are two accessor methods pointing to the request and t
The request object contains a lot of useful information about the request coming in from the client. To get a full list of the available methods, refer to the [API documentation](http://api.rubyonrails.org/classes/ActionDispatch/Request.html). Among the properties that you can access on this object are:
-|_.Property of `request`|_.Purpose|
-|host|The hostname used for this request.|
-|domain(n=2)|The hostname's first `n` segments, starting from the right (the TLD).|
-|format|The content type requested by the client.|
-|method|The HTTP method used for the request.|
-|get?, post?, patch?, put?, delete?, head?|Returns true if the HTTP method is GET/POST/PATCH/PUT/DELETE/HEAD.|
-|headers|Returns a hash containing the headers associated with the request.|
-|port|The port number (integer) used for the request.|
-|protocol|Returns a string containing the protocol used plus "://", for example "http://".|
-|query_string|The query string part of the URL, i.e., everything after "?".|
-|remote_ip|The IP address of the client.|
-|url|The entire URL used for the request.|
+| Property of `request` | Purpose |
+| ----------------------------------------- | -------------------------------------------------------------------------------- |
+| host | The hostname used for this request. |
+| domain(n=2) | The hostname's first `n` segments, starting from the right (the TLD). |
+| format | The content type requested by the client. |
+| method | The HTTP method used for the request. |
+| get?, post?, patch?, put?, delete?, head? | Returns true if the HTTP method is GET/POST/PATCH/PUT/DELETE/HEAD. |
+| headers | Returns a hash containing the headers associated with the request. |
+| port | The port number (integer) used for the request. |
+| protocol | Returns a string containing the protocol used plus "://", for example "http://". |
+| query_string | The query string part of the URL, i.e., everything after "?". |
+| remote_ip | The IP address of the client. |
+| url | The entire URL used for the request. |
#### `path_parameters`, `query_parameters`, and `request_parameters`
@@ -603,13 +604,14 @@ Rails collects all of the parameters sent along with the request in the `params`
The response object is not usually used directly, but is built up during the execution of the action and rendering of the data that is being sent back to the user, but sometimes - like in an after filter - it can be useful to access the response directly. Some of these accessor methods also have setters, allowing you to change their values.
-|_.Property of `response`|_.Purpose|
-|body|This is the string of data being sent back to the client. This is most often HTML.|
-|status|The HTTP status code for the response, like 200 for a successful request or 404 for file not found.|
-|location|The URL the client is being redirected to, if any.|
-|content_type|The content type of the response.|
-|charset|The character set being used for the response. Default is "utf-8".|
-|headers|Headers used for the response.|
+| Property of `response` | Purpose |
+| ---------------------- | --------------------------------------------------------------------------------------------------- |
+| body | This is the string of data being sent back to the client. This is most often HTML. |
+| status | The HTTP status code for the response, like 200 for a successful request or 404 for file not found. |
+| location | The URL the client is being redirected to, if any. |
+| content_type | The content type of the response. |
+| charset | The character set being used for the response. Default is "utf-8". |
+| headers | Headers used for the response. |
#### Setting Custom Headers
diff --git a/guides/source/active_record_basics.md b/guides/source/active_record_basics.md
index 3e7a41973a..6a4b03acc6 100644
--- a/guides/source/active_record_basics.md
+++ b/guides/source/active_record_basics.md
@@ -46,12 +46,13 @@ By default, Active Record uses some naming conventions to find out how the mappi
* Database Table - Plural with underscores separating words (e.g., `book_clubs`)
* Model Class - Singular with the first letter of each word capitalized (e.g., `BookClub`)
-|_.Model / Class |_.Table / Schema |
-|`Post` |`posts`|
-|`LineItem` |`line_items`|
-|`Deer` |`deer`|
-|`Mouse` |`mice`|
-|`Person` |`people`|
+| Model / Class | Table / Schema |
+| ------------- | -------------- |
+| `Post` | `posts` |
+| `LineItem` | `line_items` |
+| `Deer` | `deer` |
+| `Mouse` | `mice` |
+| `Person` | `people` |
### Schema Conventions
diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md
index 4a0e172115..336f93bc0f 100644
--- a/guides/source/active_support_core_extensions.md
+++ b/guides/source/active_support_core_extensions.md
@@ -2221,7 +2221,8 @@ This method accepts three options:
The defaults for these options can be localised, their keys are:
-|_. Option |_. I18n key |
+| Option | I18n key |
+| ---------------------- | ----------------------------------- |
| `:two_words_connector` | `support.array.two_words_connector` |
| `:words_connector` | `support.array.words_connector` |
| `:last_word_connector` | `support.array.last_word_connector` |
diff --git a/guides/source/active_support_instrumentation.md b/guides/source/active_support_instrumentation.md
index e5abbe15c0..76ce98514f 100644
--- a/guides/source/active_support_instrumentation.md
+++ b/guides/source/active_support_instrumentation.md
@@ -31,8 +31,9 @@ ActionController
### write_fragment.action_controller
-|_.Key |_.Value|
-|`:key` |The complete key|
+| Key | Value |
+| ------ | ---------------- |
+| `:key` | The complete key |
```ruby
{
@@ -42,8 +43,9 @@ ActionController
### read_fragment.action_controller
-|_.Key |_.Value|
-|`:key` |The complete key|
+| Key | Value |
+| ------ | ---------------- |
+| `:key` | The complete key |
```ruby
{
@@ -53,8 +55,9 @@ ActionController
### expire_fragment.action_controller
-|_.Key |_.Value|
-|`:key` |The complete key|
+| Key | Value |
+| ------ | ---------------- |
+| `:key` | The complete key |
```ruby
{
@@ -64,8 +67,9 @@ ActionController
### exist_fragment?.action_controller
-|_.Key |_.Value|
-|`:key` |The complete key|
+| Key | Value |
+| ------ | ---------------- |
+| `:key` | The complete key |
```ruby
{
@@ -75,8 +79,9 @@ ActionController
### write_page.action_controller
-|_.Key |_.Value|
-|`:path` |The complete path|
+| Key | Value |
+| ------- | ----------------- |
+| `:path` | The complete path |
```ruby
{
@@ -86,8 +91,9 @@ ActionController
### expire_page.action_controller
-|_.Key |_.Value|
-|`:path` |The complete path|
+| Key | Value |
+| ------- | ----------------- |
+| `:path` | The complete path |
```ruby
{
@@ -97,13 +103,14 @@ ActionController
### start_processing.action_controller
-|_.Key |_.Value |
-|`:controller` |The controller name|
-|`:action` |The action|
-|`:params` |Hash of request parameters without any filtered parameter|
-|`:format` |html/js/json/xml etc|
-|`:method` |HTTP request verb|
-|`:path` |Request path|
+| Key | Value |
+| ------------- | --------------------------------------------------------- |
+| `:controller` | The controller name |
+| `:action` | The action |
+| `:params` | Hash of request parameters without any filtered parameter |
+| `:format` | html/js/json/xml etc |
+| `:method` | HTTP request verb |
+| `:path` | Request path |
```ruby
{
@@ -118,14 +125,15 @@ ActionController
### process_action.action_controller
-|_.Key |_.Value |
-|`:controller` |The controller name|
-|`:action` |The action|
-|`:params` |Hash of request parameters without any filtered parameter|
-|`:format` |html/js/json/xml etc|
-|`:method` |HTTP request verb|
-|`:path` |Request path|
-|`:view_runtime` |Amount spent in view in ms|
+| Key | Value |
+| --------------- | --------------------------------------------------------- |
+| `:controller` | The controller name |
+| `:action` | The action |
+| `:params` | Hash of request parameters without any filtered parameter |
+| `:format` | html/js/json/xml etc |
+| `:method` | HTTP request verb |
+| `:path` | Request path |
+| `:view_runtime` | Amount spent in view in ms |
```ruby
{
@@ -143,8 +151,9 @@ ActionController
### send_file.action_controller
-|_.Key |_.Value |
-|`:path` |Complete path to the file|
+| Key | Value |
+| ------- | ------------------------- |
+| `:path` | Complete path to the file |
INFO. Additional keys may be added by the caller.
@@ -154,9 +163,10 @@ INFO. Additional keys may be added by the caller.
### redirect_to.action_controller
-|_.Key |_.Value |
-|`:status` |HTTP response code|
-|`:location` |URL to redirect to|
+| Key | Value |
+| ----------- | ------------------ |
+| `:status` | HTTP response code |
+| `:location` | URL to redirect to |
```ruby
{
@@ -167,8 +177,9 @@ INFO. Additional keys may be added by the caller.
### halted_callback.action_controller
-|_.Key |_.Value |
-|`:filter` |Filter that halted the action|
+| Key | Value |
+| --------- | ----------------------------- |
+| `:filter` | Filter that halted the action |
```ruby
{
@@ -181,9 +192,10 @@ ActionView
### render_template.action_view
-|_.Key |_.Value |
-|`:identifier` |Full path to template|
-|`:layout` |Applicable layout|
+| Key | Value |
+| ------------- | --------------------- |
+| `:identifier` | Full path to template |
+| `:layout` | Applicable layout |
```ruby
{
@@ -194,8 +206,9 @@ ActionView
### render_partial.action_view
-|_.Key |_.Value |
-|`:identifier` |Full path to template|
+| Key | Value |
+| ------------- | --------------------- |
+| `:identifier` | Full path to template |
```ruby
{
@@ -208,10 +221,11 @@ ActiveRecord
### sql.active_record
-|_.Key |_.Value |
-|`:sql` |SQL statement|
-|`:name` |Name of the operation|
-|`:object_id` |`self.object_id`|
+| Key | Value |
+| ------------ | --------------------- |
+| `:sql` | SQL statement |
+| `:name` | Name of the operation |
+| `:object_id` | `self.object_id` |
INFO. The adapters will add their own data as well.
@@ -226,26 +240,28 @@ INFO. The adapters will add their own data as well.
### identity.active_record
-|_.Key |_.Value |
-|`:line` |Primary Key of object in the identity map|
-|`:name` |Record's class|
-|`:connection_id` |`self.object_id`|
+| Key | Value |
+| ---------------- | ----------------------------------------- |
+| `:line` | Primary Key of object in the identity map |
+| `:name` | Record's class |
+| `:connection_id` | `self.object_id` |
ActionMailer
------------
### receive.action_mailer
-|_.Key |_.Value|
-|`:mailer` |Name of the mailer class|
-|`:message_id` |ID of the message, generated by the Mail gem|
-|`:subject` |Subject of the mail|
-|`:to` |To address(es) of the mail|
-|`:from` |From address of the mail|
-|`:bcc` |BCC addresses of the mail|
-|`:cc` |CC addresses of the mail|
-|`:date` |Date of the mail|
-|`:mail` |The encoded form of the mail|
+| Key | Value |
+| ------------- | -------------------------------------------- |
+| `:mailer` | Name of the mailer class |
+| `:message_id` | ID of the message, generated by the Mail gem |
+| `:subject` | Subject of the mail |
+| `:to` | To address(es) of the mail |
+| `:from` | From address of the mail |
+| `:bcc` | BCC addresses of the mail |
+| `:cc` | CC addresses of the mail |
+| `:date` | Date of the mail |
+| `:mail` | The encoded form of the mail |
```ruby
{
@@ -261,16 +277,17 @@ ActionMailer
### deliver.action_mailer
-|_.Key |_.Value|
-|`:mailer` |Name of the mailer class|
-|`:message_id` |ID of the message, generated by the Mail gem|
-|`:subject` |Subject of the mail|
-|`:to` |To address(es) of the mail|
-|`:from` |From address of the mail|
-|`:bcc` |BCC addresses of the mail|
-|`:cc` |CC addresses of the mail|
-|`:date` |Date of the mail|
-|`:mail` |The encoded form of the mail|
+| Key | Value |
+| ------------- | -------------------------------------------- |
+| `:mailer` | Name of the mailer class |
+| `:message_id` | ID of the message, generated by the Mail gem |
+| `:subject` | Subject of the mail |
+| `:to` | To address(es) of the mail |
+| `:from` | From address of the mail |
+| `:bcc` | BCC addresses of the mail |
+| `:cc` | CC addresses of the mail |
+| `:date` | Date of the mail |
+| `:mail` | The encoded form of the mail |
```ruby
{
@@ -289,27 +306,30 @@ ActiveResource
### request.active_resource
-|_.Key |_.Value|
-|`:method` |HTTP method|
-|`:request_uri` |Complete URI|
-|`:result` |HTTP response object|
+| Key | Value |
+| -------------- | -------------------- |
+| `:method` | HTTP method |
+| `:request_uri` | Complete URI |
+| `:result` | HTTP response object |
ActiveSupport
-------------
### cache_read.active_support
-|_.Key |_.Value|
-|`:key` |Key used in the store|
-|`:hit` |If this read is a hit|
-|`:super_operation` |:fetch is added when a read is used with `#fetch`|
+| Key | Value |
+| ------------------ | ------------------------------------------------- |
+| `:key` | Key used in the store |
+| `:hit` | If this read is a hit |
+| `:super_operation` | :fetch is added when a read is used with `#fetch` |
### cache_generate.active_support
This event is only used when `#fetch` is called with a block.
-|_.Key |_.Value|
-|`:key` |Key used in the store|
+| Key | Value |
+| ------ | --------------------- |
+| `:key` | Key used in the store |
INFO. Options passed to fetch will be merged with the payload when writing to the store
@@ -324,8 +344,9 @@ INFO. Options passed to fetch will be merged with the payload when writing to th
This event is only used when `#fetch` is called with a block.
-|_.Key |_.Value|
-|`:key` |Key used in the store|
+| Key | Value |
+| ------ | --------------------- |
+| `:key` | Key used in the store |
INFO. Options passed to fetch will be merged with the payload.
@@ -337,8 +358,9 @@ INFO. Options passed to fetch will be merged with the payload.
### cache_write.active_support
-|_.Key |_.Value|
-|`:key` |Key used in the store|
+| Key | Value |
+| ------ | --------------------- |
+| `:key` | Key used in the store |
INFO. Cache stores my add their own keys
@@ -350,8 +372,9 @@ INFO. Cache stores my add their own keys
### cache_delete.active_support
-|_.Key |_.Value|
-|`:key` |Key used in the store|
+| Key | Value |
+| ------ | --------------------- |
+| `:key` | Key used in the store |
```ruby
{
@@ -361,8 +384,9 @@ INFO. Cache stores my add their own keys
### cache_exist?.active_support
-|_.Key |_.Value|
-|`:key` |Key used in the store|
+| Key | Value |
+| ------ | --------------------- |
+| `:key` | Key used in the store |
```ruby
{
@@ -375,9 +399,10 @@ Rails
### deprecation.rails
-|_.Key |_.Value|
-|`:message` |The deprecation warning|
-|`:callstack` |Where the deprecation came from|
+| Key | Value |
+| ------------ | ------------------------------- |
+| `:message` | The deprecation warning |
+| `:callstack` | Where the deprecation came from |
Subscribing to an event
-----------------------
diff --git a/guides/source/caching_with_rails.md b/guides/source/caching_with_rails.md
index 4d385a12ab..759562bc10 100644
--- a/guides/source/caching_with_rails.md
+++ b/guides/source/caching_with_rails.md
@@ -380,12 +380,13 @@ When initializing the cache, you may use the `:ehcache_config` option to specify
In addition to the standard `:expires_in` option, the `write` method on this cache can also accept the additional `:unless_exist` option, which will cause the cache store to use Ehcache's `putIfAbsent` method instead of `put`, and therefore will not overwrite an existing entry. Additionally, the `write` method supports all of the properties exposed by the [Ehcache Element class](http://ehcache.org/apidocs/net/sf/ehcache/Element.html) , including:
-|_. Property |_. Argument Type |_. Description |
-| elementEvictionData | ElementEvictionData | Sets this element's eviction data instance. |
-| eternal | boolean | Sets whether the element is eternal. |
-| timeToIdle, tti | int | Sets time to idle |
-| timeToLive, ttl, expires_in | int | Sets time to Live |
-| version | long | Sets the version attribute of the ElementAttributes object. |
+| Property | Argument Type | Description |
+| --------------------------- | ------------------- | ----------------------------------------------------------- |
+| elementEvictionData | ElementEvictionData | Sets this element's eviction data instance. |
+| eternal | boolean | Sets whether the element is eternal. |
+| timeToIdle, tti | int | Sets time to idle |
+| timeToLive, ttl, expires_in | int | Sets time to Live |
+| version | long | Sets the version attribute of the ElementAttributes object. |
These options are passed to the `write` method as Hash options using either camelCase or underscore notation, as in the following examples:
diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md
index d5fd50412d..52fd2b8ca0 100644
--- a/guides/source/getting_started.md
+++ b/guides/source/getting_started.md
@@ -122,7 +122,8 @@ working directory called `blog`. The `blog` directory has a number of
auto-generated files and folders that make up the structure of a Rails
application. Most of the work in this tutorial will happen in the `app/` folder, but here's a basic rundown on the function of each of the files and folders that Rails created by default:
-|_.File/Folder|_.Purpose|
+| File/Folder | Purpose |
+| ----------- | ------- |
|app/|Contains the controllers, models, views, helpers, mailers and assets for your application. You'll focus on this folder for the remainder of this guide.|
|config/|Configure your application's runtime rules, routes, database, and more. This is covered in more detail in [Configuring Rails Applications](configuring.html|)
|config.ru|Rack configuration for Rack based servers used to start the application.|
@@ -1243,11 +1244,12 @@ $ rails generate model Comment commenter:string body:text post:references
This command will generate four files:
-|_.File |_.Purpose|
-|db/migrate/20100207235629_create_comments.rb | Migration to create the comments table in your database (your name will include a different timestamp) |
-| app/models/comment.rb | The Comment model |
-| test/unit/comment_test.rb | Unit testing harness for the comments model |
-| test/fixtures/comments.yml | Sample comments for use in testing |
+| File | Purpose |
+| -------------------------------------------- | ------------------------------------------------------------------------------------------------------ |
+| db/migrate/20100207235629_create_comments.rb | Migration to create the comments table in your database (your name will include a different timestamp) |
+| app/models/comment.rb | The Comment model |
+| test/unit/comment_test.rb | Unit testing harness for the comments model |
+| test/fixtures/comments.yml | Sample comments for use in testing |
First, take a look at `comment.rb`:
@@ -1368,7 +1370,8 @@ $ rails generate controller Comments
This creates six files and one empty directory:
-|_.File/Directory |_.Purpose |
+| File/Directory | Purpose |
+| ------------------------------------------- | ---------------------------------------- |
| app/controllers/comments_controller.rb | The Comments controller |
| app/views/comments/ | Views of the controller are stored here |
| test/functional/comments_controller_test.rb | The functional tests for the controller |
diff --git a/guides/source/i18n.md b/guides/source/i18n.md
index 4857973b7a..91d12fdc85 100644
--- a/guides/source/i18n.md
+++ b/guides/source/i18n.md
@@ -780,28 +780,29 @@ So, for example, instead of the default error message `"can not be blank"` you c
* `count`, where available, can be used for pluralization if present:
-|_. validation |_.with option |_.message |_.interpolation|
-| confirmation | - | :confirmation | -|
-| acceptance | - | :accepted | -|
-| presence | - | :blank | -|
-| length | :within, :in | :too_short | count|
-| length | :within, :in | :too_long | count|
-| length | :is | :wrong_length | count|
-| length | :minimum | :too_short | count|
-| length | :maximum | :too_long | count|
-| uniqueness | - | :taken | -|
-| format | - | :invalid | -|
-| inclusion | - | :inclusion | -|
-| exclusion | - | :exclusion | -|
-| associated | - | :invalid | -|
-| numericality | - | :not_a_number | -|
-| numericality | :greater_than | :greater_than | count|
-| numericality | :greater_than_or_equal_to | :greater_than_or_equal_to | count|
-| numericality | :equal_to | :equal_to | count|
-| numericality | :less_than | :less_than | count|
-| numericality | :less_than_or_equal_to | :less_than_or_equal_to | count|
-| numericality | :odd | :odd | -|
-| numericality | :even | :even | -|
+| validation | with option | message | interpolation |
+| ------------ | ------------------------- | ------------------------- | ------------- |
+| confirmation | - | :confirmation | - |
+| acceptance | - | :accepted | - |
+| presence | - | :blank | - |
+| length | :within, :in | :too_short | count |
+| length | :within, :in | :too_long | count |
+| length | :is | :wrong_length | count |
+| length | :minimum | :too_short | count |
+| length | :maximum | :too_long | count |
+| uniqueness | - | :taken | - |
+| format | - | :invalid | - |
+| inclusion | - | :inclusion | - |
+| exclusion | - | :exclusion | - |
+| associated | - | :invalid | - |
+| numericality | - | :not_a_number | - |
+| numericality | :greater_than | :greater_than | count |
+| numericality | :greater_than_or_equal_to | :greater_than_or_equal_to | count |
+| numericality | :equal_to | :equal_to | count |
+| numericality | :less_than | :less_than | count |
+| numericality | :less_than_or_equal_to | :less_than_or_equal_to | count |
+| numericality | :odd | :odd | - |
+| numericality | :even | :even | - |
#### Translations for the Active Record `error_messages_for` Helper
diff --git a/guides/source/migrations.md b/guides/source/migrations.md
index fa8a064e86..4f122945ba 100644
--- a/guides/source/migrations.md
+++ b/guides/source/migrations.md
@@ -714,15 +714,11 @@ A migration creating a table and adding an index might produce output like this
Several methods are provided in migrations that allow you to control all this:
-|_.Method |_.Purpose|
-|suppress_messages |Takes a block as an argument and suppresses any output
- generated by the block.|
-|say |Takes a message argument and outputs it as is. A second
- boolean argument can be passed to specify whether to
- indent or not.|
-|say_with_time |Outputs text along with how long it took to run its
- block. If the block returns an integer it assumes it
- is the number of rows affected.|
+| Method | Purpose
+| -------------------- | -------
+| suppress_messages | Takes a block as an argument and suppresses any output generated by the block.
+| say | Takes a message argument and outputs it as is. A second boolean argument can be passed to specify whether to indent or not.
+| say_with_time | Outputs text along with how long it took to run its block. If the block returns an integer it assumes it is the number of rows affected.
For example, this migration
diff --git a/guides/source/performance_testing.md b/guides/source/performance_testing.md
index 28e05b7d28..a5f5661b6a 100644
--- a/guides/source/performance_testing.md
+++ b/guides/source/performance_testing.md
@@ -248,19 +248,21 @@ GC Time measures the amount of time spent in GC for the performance test case.
##### Benchmarking
-|_.Interpreter|_.Wall Time|_.Process Time|_.CPU Time|_.User Time|_.Memory|_.Objects|_.GC Runs|_.GC Time|
-|_.MRI | yes | yes | yes | no | yes | yes | yes | yes |
-|_.REE | yes | yes | yes | no | yes | yes | yes | yes |
-|_.Rubinius | yes | no | no | no | yes | yes | yes | yes |
-|_.JRuby | yes | no | no | yes | yes | yes | yes | yes |
+| Interpreter | Wall Time | Process Time | CPU Time | User Time | Memory | Objects | GC Runs | GC Time |
+| ------------ | --------- | ------------ | -------- | --------- | ------ | ------- | ------- | ------- |
+| **MRI** | yes | yes | yes | no | yes | yes | yes | yes |
+| **REE** | yes | yes | yes | no | yes | yes | yes | yes |
+| **Rubinius** | yes | no | no | no | yes | yes | yes | yes |
+| **JRuby** | yes | no | no | yes | yes | yes | yes | yes |
##### Profiling
-|_.Interpreter|_.Wall Time|_.Process Time|_.CPU Time|_.User Time|_.Memory|_.Objects|_.GC Runs|_.GC Time|
-|_.MRI | yes | yes | no | no | yes | yes | yes | yes |
-|_.REE | yes | yes | no | no | yes | yes | yes | yes |
-|_.Rubinius | yes | no | no | no | no | no | no | no |
-|_.JRuby | yes | no | no | no | no | no | no | no |
+| Interpreter | Wall Time | Process Time | CPU Time | User Time | Memory | Objects | GC Runs | GC Time |
+| ------------ | --------- | ------------ | -------- | --------- | ------ | ------- | ------- | ------- |
+| **MRI** | yes | yes | no | no | yes | yes | yes | yes |
+| **REE** | yes | yes | no | no | yes | yes | yes | yes |
+| **Rubinius** | yes | no | no | no | no | no | no | no |
+| **JRuby** | yes | no | no | no | no | no | no | no |
NOTE: To profile under JRuby you'll need to run `export JRUBY_OPTS="-Xlaunch.inproc=false --profile.api"`
*before* the performance tests.
@@ -354,11 +356,12 @@ and similar tools.
##### Output Availability
-|_. |_.Flat|_.Graph|_.Tree|
-|_.MRI | yes | yes | yes |
-|_.REE | yes | yes | yes |
-|_.Rubinius | yes | yes | no |
-|_.JRuby | yes | yes | no |
+| | Flat | Graph | Tree |
+| ------------ | ---- | ----- | ---- |
+| **MRI** | yes | yes | yes |
+| **REE** | yes | yes | yes |
+| **Rubinius** | yes | yes | no |
+| **JRuby** | yes | yes | no |
### Tuning Test Runs
@@ -381,21 +384,23 @@ end
In this example, the test would run 5 times and measure wall time and memory.
There are a few configurable options:
-|_.Option |_.Description|_.Default|_.Mode|
-|`:runs` |Number of runs.|Benchmarking: 4, Profiling: 1|Both|
-|`:output` |Directory to use when writing the results.|`tmp/performance`|Both|
-|`:metrics` |Metrics to use.|See below.|Both|
-|`:formats` |Formats to output to.|See below.|Profiling|
+| Option | Description | Default | Mode |
+| ---------- | ------------------------------------------ | ----------------------------- | --------- |
+| `:runs` | Number of runs. | Benchmarking: 4, Profiling: 1 | Both |
+| `:output` | Directory to use when writing the results. | `tmp/performance` | Both |
+| `:metrics` | Metrics to use. | See below. | Both |
+| `:formats` | Formats to output to. | See below. | Profiling |
Metrics and formats have different defaults depending on the interpreter in use.
-|_.Interpreter|_.Mode|_.Default metrics|_.Default formats|
-|/2.MRI/REE |Benchmarking|`[:wall_time, :memory, :objects, :gc_runs, :gc_time]`|N/A|
-|Profiling |`[:process_time, :memory, :objects]`|`[:flat, :graph_html, :call_tree, :call_stack]`|
-|/2.Rubinius|Benchmarking|`[:wall_time, :memory, :objects, :gc_runs, :gc_time]`|N/A|
-|Profiling |`[:wall_time]`|`[:flat, :graph]`|
-|/2.JRuby |Benchmarking|`[:wall_time, :user_time, :memory, :gc_runs, :gc_time]`|N/A|
-|Profiling |`[:wall_time]`|`[:flat, :graph]`|
+| Interpreter | Mode | Default metrics | Default formats |
+| -------------- | ------------ | ------------------------------------------------------- | ----------------------------------------------- |
+| **MRI/REE** | Benchmarking | `[:wall_time, :memory, :objects, :gc_runs, :gc_time]` | N/A |
+| | Profiling | `[:process_time, :memory, :objects]` | `[:flat, :graph_html, :call_tree, :call_stack]` |
+| **Rubinius** | Benchmarking | `[:wall_time, :memory, :objects, :gc_runs, :gc_time]` | N/A |
+| | Profiling | `[:wall_time]` | `[:flat, :graph]` |
+| **JRuby** | Benchmarking | `[:wall_time, :user_time, :memory, :gc_runs, :gc_time]` | N/A |
+| | Profiling | `[:wall_time]` | `[:flat, :graph]` |
As you've probably noticed by now, metrics and formats are specified using a
symbol array with each name [underscored.](http://api.rubyonrails.org/classes/String.html#method-i-underscore)
@@ -421,10 +426,11 @@ a special Ruby binary with some super powers.
The recommended patches for each MRI version are:
-|_.Version|_.Patch|
-|1.8.6|ruby186gc|
-|1.8.7|ruby187gc|
-|1.9.2 and above|gcdata|
+| Version | Patch |
+| --------------- | --------- |
+| 1.8.6 | ruby186gc |
+| 1.8.7 | ruby187gc |
+| 1.9.2 and above | gcdata |
All of these can be found on [RVM's _patches_ directory](https://github.com/wayneeseguin/rvm/tree/master/patches/ruby)
under each specific interpreter version.
diff --git a/guides/source/rails_on_rack.md b/guides/source/rails_on_rack.md
index d5da31ca36..98e96f2643 100644
--- a/guides/source/rails_on_rack.md
+++ b/guides/source/rails_on_rack.md
@@ -66,9 +66,10 @@ end
`Rails::Rack::Debugger` is primarily useful only in the development environment. The following table explains the usage of the loaded middlewares:
-|_.Middleware|_.Purpose|
-|`Rails::Rack::Debugger`|Starts Debugger|
-|`Rack::ContentLength`|Counts the number of bytes in the response and set the HTTP Content-Length header|
+| Middleware | Purpose |
+| ----------------------- | --------------------------------------------------------------------------------- |
+| `Rails::Rack::Debugger` | Starts Debugger |
+| `Rack::ContentLength` | Counts the number of bytes in the response and set the HTTP Content-Length header |
### `rackup`
diff --git a/guides/source/routing.md b/guides/source/routing.md
index 8634f314ad..bc47e6c71a 100644
--- a/guides/source/routing.md
+++ b/guides/source/routing.md
@@ -85,14 +85,15 @@ resources :photos
creates seven different routes in your application, all mapping to the `Photos` controller:
-|_. HTTP Verb |_.Path |_.action |_.used for |
-|GET |/photos |index |display a list of all photos |
-|GET |/photos/new |new |return an HTML form for creating a new photo |
-|POST |/photos |create |create a new photo |
-|GET |/photos/:id |show |display a specific photo |
-|GET |/photos/:id/edit |edit |return an HTML form for editing a photo |
-|PATCH/PUT |/photos/:id |update |update a specific photo |
-|DELETE |/photos/:id |destroy |delete a specific photo |
+| HTTP Verb | Path | action | used for |
+| --------- | ---------------- | ------- | -------------------------------------------- |
+| GET | /photos | index | display a list of all photos |
+| GET | /photos/new | new | return an HTML form for creating a new photo |
+| POST | /photos | create | create a new photo |
+| GET | /photos/:id | show | display a specific photo |
+| GET | /photos/:id/edit | edit | return an HTML form for editing a photo |
+| PATCH/PUT | /photos/:id | update | update a specific photo |
+| DELETE | /photos/:id | destroy | delete a specific photo |
NOTE: Rails routes are matched in the order they are specified, so if you have a `resources :photos` above a `get 'photos/poll'` the `show` action's route for the `resources` line will be matched before the `get` line. To fix this, move the `get` line *above* the `resources` line so that it is matched first.
@@ -171,14 +172,15 @@ end
This will create a number of routes for each of the `posts` and `comments` controller. For `Admin::PostsController`, Rails will create:
-|_.HTTP Verb |_.Path |_.action |_.named helper |
-|GET |/admin/posts |index | admin_posts_path |
-|GET |/admin/posts/new |new | new_admin_post_path |
-|POST |/admin/posts |create | admin_posts_path |
-|GET |/admin/posts/:id |show | admin_post_path(:id) |
-|GET |/admin/posts/:id/edit |edit | edit_admin_post_path(:id) |
-|PATCH/PUT |/admin/posts/:id |update | admin_post_path(:id) |
-|DELETE |/admin/posts/:id |destroy | admin_post_path(:id) |
+| HTTP Verb | Path | action | used for |
+| --------- | --------------------- | ------- | ------------------------- |
+| GET | /admin/posts | index | admin_posts_path |
+| GET | /admin/posts/new | new | new_admin_post_path |
+| POST | /admin/posts | create | admin_posts_path |
+| GET | /admin/posts/:id | show | admin_post_path(:id) |
+| GET | /admin/posts/:id/edit | edit | edit_admin_post_path(:id) |
+| PATCH/PUT | /admin/posts/:id | update | admin_post_path(:id) |
+| DELETE | /admin/posts/:id | destroy | admin_post_path(:id) |
If you want to route `/posts` (without the prefix `/admin`) to `Admin::PostsController`, you could use
@@ -210,14 +212,15 @@ resources :posts, :path => "/admin/posts"
In each of these cases, the named routes remain the same as if you did not use `scope`. In the last case, the following paths map to `PostsController`:
-|_.HTTP Verb |_.Path |_.action |_.named helper |
-|GET |/admin/posts |index | posts_path |
-|GET |/admin/posts/new |new | new_post_path |
-|POST |/admin/posts |create | posts_path |
-|GET |/admin/posts/:id |show | post_path(:id) |
-|GET |/admin/posts/:id/edit|edit | edit_post_path(:id)|
-|PATCH/PUT |/admin/posts/:id |update | post_path(:id) |
-|DELETE |/admin/posts/:id |destroy | post_path(:id) |
+| HTTP Verb | Path | action | named helper |
+| --------- | --------------------- | ------- | ------------------- |
+| GET | /admin/posts | index | posts_path |
+| GET | /admin/posts/new | new | new_post_path |
+| POST | /admin/posts | create | posts_path |
+| GET | /admin/posts/:id | show | post_path(:id) |
+| GET | /admin/posts/:id/edit | edit | edit_post_path(:id) |
+| PATCH/PUT | /admin/posts/:id | update | post_path(:id) |
+| DELETE | /admin/posts/:id | destroy | post_path(:id) |
### Nested Resources
@@ -243,14 +246,15 @@ end
In addition to the routes for magazines, this declaration will also route ads to an `AdsController`. The ad URLs require a magazine:
-|_.HTTP Verb |_.Path |_.action |_.used for |
-|GET |/magazines/:magazine_id/ads |index |display a list of all ads for a specific magazine |
-|GET |/magazines/:magazine_id/ads/new |new |return an HTML form for creating a new ad belonging to a specific magazine |
-|POST |/magazines/:magazine_id/ads |create |create a new ad belonging to a specific magazine |
-|GET |/magazines/:magazine_id/ads/:id |show |display a specific ad belonging to a specific magazine |
-|GET |/magazines/:magazine_id/ads/:id/edit |edit |return an HTML form for editing an ad belonging to a specific magazine |
-|PATCH/PUT |/magazines/:magazine_id/ads/:id |update |update a specific ad belonging to a specific magazine |
-|DELETE |/magazines/:magazine_id/ads/:id |destroy |delete a specific ad belonging to a specific magazine |
+| HTTP Verb | Path | action | used for |
+| --------- | ------------------------------------ | ------- | -------------------------------------------------------------------------- |
+| GET | /magazines/:magazine_id/ads | index | display a list of all ads for a specific magazine |
+| GET | /magazines/:magazine_id/ads/new | new | return an HTML form for creating a new ad belonging to a specific magazine |
+| POST | /magazines/:magazine_id/ads | create | create a new ad belonging to a specific magazine |
+| GET | /magazines/:magazine_id/ads/:id | show | display a specific ad belonging to a specific magazine |
+| GET | /magazines/:magazine_id/ads/:id/edit | edit | return an HTML form for editing an ad belonging to a specific magazine |
+| PATCH/PUT | /magazines/:magazine_id/ads/:id | update | update a specific ad belonging to a specific magazine |
+| DELETE | /magazines/:magazine_id/ads/:id | destroy | delete a specific ad belonging to a specific magazine |
This will also create routing helpers such as `magazine_ads_url` and `edit_magazine_ad_path`. These helpers take an instance of Magazine as the first parameter (`magazine_ads_url(@magazine)`).
@@ -707,14 +711,15 @@ resources :photos, :controller => "images"
will recognize incoming paths beginning with `/photos` but route to the `Images` controller:
-|_.HTTP Verb |_.Path |_.action |_.named helper |
-|GET |/photos |index | photos_path |
-|GET |/photos/new |new | new_photo_path |
-|POST |/photos |create | photos_path |
-|GET |/photos/:id |show | photo_path(:id) |
-|GET |/photos/:id/edit |edit | edit_photo_path(:id) |
-|PATCH/PUT |/photos/:id |update | photo_path(:id) |
-|DELETE |/photos/:id |destroy | photo_path(:id) |
+| HTTP Verb | Path | action | named helper |
+| --------- | ---------------- | ------- | -------------------- |
+| GET | /photos | index | photos_path |
+| GET | /photos/new | new | new_photo_path |
+| POST | /photos | create | photos_path |
+| GET | /photos/:id | show | photo_path(:id) |
+| GET | /photos/:id/edit | edit | edit_photo_path(:id) |
+| PATCH/PUT | /photos/:id | update | photo_path(:id) |
+| DELETE | /photos/:id | destroy | photo_path(:id) |
NOTE: Use `photos_path`, `new_photo_path`, etc. to generate paths for this resource.
@@ -751,14 +756,15 @@ resources :photos, :as => "images"
will recognize incoming paths beginning with `/photos` and route the requests to `PhotosController`, but use the value of the :as option to name the helpers.
-|_.HTTP verb|_.Path |_.action |_.named helper |
-|GET |/photos |index | images_path |
-|GET |/photos/new |new | new_image_path |
-|POST |/photos |create | images_path |
-|GET |/photos/:id |show | image_path(:id) |
-|GET |/photos/:id/edit |edit | edit_image_path(:id) |
-|PATCH/PUT |/photos/:id |update | image_path(:id) |
-|DELETE |/photos/:id |destroy | image_path(:id) |
+| HTTP Verb | Path | action | named helper |
+| --------- | ---------------- | ------- | -------------------- |
+| GET | /photos | index | images_path |
+| GET | /photos/new | new | new_image_path |
+| POST | /photos | create | images_path |
+| GET | /photos/:id | show | image_path(:id) |
+| GET | /photos/:id/edit | edit | edit_image_path(:id) |
+| PATCH/PUT | /photos/:id | update | image_path(:id) |
+| DELETE | /photos/:id | destroy | image_path(:id) |
### Overriding the `new` and `edit` Segments
@@ -855,14 +861,15 @@ end
Rails now creates routes to the `CategoriesController`.
-|_.HTTP verb|_.Path |_.action |_.named helper |
-|GET |/kategorien |index | categories_path |
-|GET |/kategorien/neu |new | new_category_path |
-|POST |/kategorien |create | categories_path |
-|GET |/kategorien/:id |show | category_path(:id) |
-|GET |/kategorien/:id/bearbeiten |edit | edit_category_path(:id) |
-|PATCH/PUT |/kategorien/:id |update | category_path(:id) |
-|DELETE |/kategorien/:id |destroy | category_path(:id) |
+| HTTP Verb | Path | action | used for |
+| --------- | -------------------------- | ------- | ----------------------- |
+| GET | /kategorien | index | categories_path |
+| GET | /kategorien/neu | new | new_category_path |
+| POST | /kategorien | create | categories_path |
+| GET | /kategorien/:id | show | category_path(:id) |
+| GET | /kategorien/:id/bearbeiten | edit | edit_category_path(:id) |
+| PATCH/PUT | /kategorien/:id | update | category_path(:id) |
+| DELETE | /kategorien/:id | destroy | category_path(:id) |
### Overriding the Singular Form
diff --git a/guides/source/testing.md b/guides/source/testing.md
index 15107bfe5f..2db6d71a97 100644
--- a/guides/source/testing.md
+++ b/guides/source/testing.md
@@ -210,12 +210,13 @@ NOTE: `db:test:prepare` will fail with an error if `db/schema.rb` doesn't exist.
#### Rake Tasks for Preparing your Application for Testing
-|_.Tasks |_.Description|
-|`rake db:test:clone` |Recreate the test database from the current environment's database schema|
-|`rake db:test:clone_structure` |Recreate the test database from the development structure|
-|`rake db:test:load` |Recreate the test database from the current `schema.rb`|
-|`rake db:test:prepare` |Check for pending migrations and load the test schema|
-|`rake db:test:purge` |Empty the test database.|
+| Tasks | Description |
+| ------------------------------ | ------------------------------------------------------------------------- |
+| `rake db:test:clone` | Recreate the test database from the current environment's database schema |
+| `rake db:test:clone_structure` | Recreate the test database from the development structure |
+| `rake db:test:load` | Recreate the test database from the current `schema.rb` |
+| `rake db:test:prepare` | Check for pending migrations and load the test schema |
+| `rake db:test:purge` | Empty the test database. |
TIP: You can see all these rake tasks and their descriptions by running `rake --tasks --describe`
@@ -359,26 +360,27 @@ By now you've caught a glimpse of some of the assertions that are available. Ass
There are a bunch of different types of assertions you can use. Here's the complete list of assertions that ship with `test/unit`, the default testing library used by Rails. The `[msg]` parameter is an optional string message you can specify to make your test failure messages clearer. It's not required.
-|_.Assertion |_.Purpose|
-|`assert( boolean, [msg] )` |Ensures that the object/expression is true.|
-|`assert_equal( expected, actual, [msg] )` |Ensures that `expected == actual` is true.|
-|`assert_not_equal( expected, actual, [msg] )` |Ensures that `expected != actual` is true.|
-|`assert_same( expected, actual, [msg] )` |Ensures that `expected.equal?(actual)` is true.|
-|`assert_not_same( expected, actual, [msg] )` |Ensures that `!expected.equal?(actual)` is true.|
-|`assert_nil( obj, [msg] )` |Ensures that `obj.nil?` is true.|
-|`assert_not_nil( obj, [msg] )` |Ensures that `!obj.nil?` is true.|
-|`assert_match( regexp, string, [msg] )` |Ensures that a string matches the regular expression.|
-|`assert_no_match( regexp, string, [msg] )` |Ensures that a string doesn't match the regular expression.|
-|`assert_in_delta( expecting, actual, delta, [msg] )` |Ensures that the numbers `expecting` and `actual` are within `delta` of each other.|
-|`assert_throws( symbol, [msg] ) { block }` |Ensures that the given block throws the symbol.|
-|`assert_raise( exception1, exception2, ... ) { block }` |Ensures that the given block raises one of the given exceptions.|
-|`assert_nothing_raised( exception1, exception2, ... ) { block }` |Ensures that the given block doesn't raise one of the given exceptions.|
-|`assert_instance_of( class, obj, [msg] )` |Ensures that `obj` is of the `class` type.|
-|`assert_kind_of( class, obj, [msg] )` |Ensures that `obj` is or descends from `class`.|
-|`assert_respond_to( obj, symbol, [msg] )` |Ensures that `obj` has a method called `symbol`.|
-|`assert_operator( obj1, operator, obj2, [msg] )` |Ensures that `obj1.operator(obj2)` is true.|
-|`assert_send( array, [msg] )` |Ensures that executing the method listed in `array[1]` on the object in `array[0]` with the parameters of `array[2 and up]` is true. This one is weird eh?|
-|`flunk( [msg] )` |Ensures failure. This is useful to explicitly mark a test that isn't finished yet.|
+| Assertion | Purpose |
+| ---------------------------------------------------------------- | ------- |
+| `assert( boolean, [msg] )` | Ensures that the object/expression is true.|
+| `assert_equal( expected, actual, [msg] )` | Ensures that `expected == actual` is true.|
+| `assert_not_equal( expected, actual, [msg] )` | Ensures that `expected != actual` is true.|
+| `assert_same( expected, actual, [msg] )` | Ensures that `expected.equal?(actual)` is true.|
+| `assert_not_same( expected, actual, [msg] )` | Ensures that `!expected.equal?(actual)` is true.|
+| `assert_nil( obj, [msg] )` | Ensures that `obj.nil?` is true.|
+| `assert_not_nil( obj, [msg] )` | Ensures that `!obj.nil?` is true.|
+| `assert_match( regexp, string, [msg] )` | Ensures that a string matches the regular expression.|
+| `assert_no_match( regexp, string, [msg] )` | Ensures that a string doesn't match the regular expression.|
+| `assert_in_delta( expecting, actual, delta, [msg] )` | Ensures that the numbers `expecting` and `actual` are within `delta` of each other.|
+| `assert_throws( symbol, [msg] ) { block }` | Ensures that the given block throws the symbol.|
+| `assert_raise( exception1, exception2, ... ) { block }` | Ensures that the given block raises one of the given exceptions.|
+| `assert_nothing_raised( exception1, exception2, ... ) { block }` | Ensures that the given block doesn't raise one of the given exceptions.|
+| `assert_instance_of( class, obj, [msg] )` | Ensures that `obj` is of the `class` type.|
+| `assert_kind_of( class, obj, [msg] )` | Ensures that `obj` is or descends from `class`.|
+| `assert_respond_to( obj, symbol, [msg] )` | Ensures that `obj` has a method called `symbol`.|
+| `assert_operator( obj1, operator, obj2, [msg] )` | Ensures that `obj1.operator(obj2)` is true.|
+| `assert_send( array, [msg] )` | Ensures that executing the method listed in `array[1]` on the object in `array[0]` with the parameters of `array[2 and up]` is true. This one is weird eh?|
+| `flunk( [msg] )` | Ensures failure. This is useful to explicitly mark a test that isn't finished yet.|
Because of the modular nature of the testing framework, it is possible to create your own assertions. In fact, that's exactly what Rails does. It includes some specialized assertions to make your life easier.
@@ -390,15 +392,16 @@ Rails adds some custom assertions of its own to the `test/unit` framework:
NOTE: `assert_valid(record)` has been deprecated. Please use `assert(record.valid?)` instead.
-|_.Assertion |_.Purpose|
-|`assert_valid(record)` |Ensures that the passed record is valid by Active Record standards and returns any error messages if it is not.|
-|`assert_difference(expressions, difference = 1, message = nil) {...}` |Test numeric difference between the return value of an expression as a result of what is evaluated in the yielded block.|
-|`assert_no_difference(expressions, message = nil, &amp;block)` |Asserts that the numeric result of evaluating an expression is not changed before and after invoking the passed in block.|
-|`assert_recognizes(expected_options, path, extras={}, message=nil)` |Asserts that the routing of the given path was handled correctly and that the parsed options (given in the expected_options hash) match path. Basically, it asserts that Rails recognizes the route given by expected_options.|
-|`assert_generates(expected_path, options, defaults={}, extras = {}, message=nil)` |Asserts that the provided options can be used to generate the provided path. This is the inverse of assert_recognizes. The extras parameter is used to tell the request the names and values of additional request parameters that would be in a query string. The message parameter allows you to specify a custom error message for assertion failures.|
-|`assert_response(type, message = nil)` |Asserts that the response comes with a specific status code. You can specify `:success` to indicate 200-299, `:redirect` to indicate 300-399, `:missing` to indicate 404, or `:error` to match the 500-599 range|
-|`assert_redirected_to(options = {}, message=nil)` |Assert that the redirection options passed in match those of the redirect called in the latest action. This match can be partial, such that `assert_redirected_to(:controller => "weblog")` will also match the redirection of `redirect_to(:controller => "weblog", :action => "show")` and so on.|
-|`assert_template(expected = nil, message=nil)` |Asserts that the request was rendered with the appropriate template file.|
+| Assertion | Purpose |
+| --------------------------------------------------------------------------------- | ------- |
+| `assert_valid(record)` | Ensures that the passed record is valid by Active Record standards and returns any error messages if it is not.|
+| `assert_difference(expressions, difference = 1, message = nil) {...}` | Test numeric difference between the return value of an expression as a result of what is evaluated in the yielded block.|
+| `assert_no_difference(expressions, message = nil, &amp;block)` | Asserts that the numeric result of evaluating an expression is not changed before and after invoking the passed in block.|
+| `assert_recognizes(expected_options, path, extras={}, message=nil)` | Asserts that the routing of the given path was handled correctly and that the parsed options (given in the expected_options hash) match path. Basically, it asserts that Rails recognizes the route given by expected_options.|
+| `assert_generates(expected_path, options, defaults={}, extras = {}, message=nil)` | Asserts that the provided options can be used to generate the provided path. This is the inverse of assert_recognizes. The extras parameter is used to tell the request the names and values of additional request parameters that would be in a query string. The message parameter allows you to specify a custom error message for assertion failures.|
+| `assert_response(type, message = nil)` | Asserts that the response comes with a specific status code. You can specify `:success` to indicate 200-299, `:redirect` to indicate 300-399, `:missing` to indicate 404, or `:error` to match the 500-599 range|
+| `assert_redirected_to(options = {}, message=nil)` | Assert that the redirection options passed in match those of the redirect called in the latest action. This match can be partial, such that `assert_redirected_to(:controller => "weblog")` will also match the redirection of `redirect_to(:controller => "weblog", :action => "show")` and so on.|
+| `assert_template(expected = nil, message=nil)` | Asserts that the request was rendered with the appropriate template file.|
You'll see the usage of some of these assertions in the next chapter.
@@ -607,10 +610,11 @@ The `assert_select` assertion is quite powerful. For more advanced usage, refer
There are more assertions that are primarily used in testing views:
-|_.Assertion |_.Purpose|
-|`assert_select_email` |Allows you to make assertions on the body of an e-mail. |
-|`assert_select_encoded` |Allows you to make assertions on encoded HTML. It does this by un-encoding the contents of each element and then calling the block with all the un-encoded elements.|
-|`css_select(selector)` or `css_select(element, selector)` |Returns an array of all the elements selected by the _selector_. In the second variant it first matches the base _element_ and tries to match the _selector_ expression on any of its children. If there are no matches both variants return an empty array.|
+| Assertion | Purpose |
+| ---------------------------------------------------------- | ------- |
+| `assert_select_email` | Allows you to make assertions on the body of an e-mail. |
+| `assert_select_encoded` | Allows you to make assertions on encoded HTML. It does this by un-encoding the contents of each element and then calling the block with all the un-encoded elements.|
+| `css_select(selector)` or `css_select(element, selector)` | Returns an array of all the elements selected by the _selector_. In the second variant it first matches the base _element_ and tries to match the _selector_ expression on any of its children. If there are no matches both variants return an empty array.|
Here's an example of using `assert_select_email`:
@@ -654,19 +658,20 @@ Integration tests inherit from `ActionDispatch::IntegrationTest`. This makes ava
In addition to the standard testing helpers, there are some additional helpers available to integration tests:
-|_.Helper |_.Purpose|
-|`https?` |Returns `true` if the session is mimicking a secure HTTPS request.|
-|`https!` |Allows you to mimic a secure HTTPS request.|
-|`host!` |Allows you to set the host name to use in the next request.|
-|`redirect?` |Returns `true` if the last request was a redirect.|
-|`follow_redirect!` |Follows a single redirect response.|
-|`request_via_redirect(http_method, path, [parameters], [headers])` |Allows you to make an HTTP request and follow any subsequent redirects.|
-|`post_via_redirect(path, [parameters], [headers])` |Allows you to make an HTTP POST request and follow any subsequent redirects.|
-|`get_via_redirect(path, [parameters], [headers])` |Allows you to make an HTTP GET request and follow any subsequent redirects.|
-|`patch_via_redirect(path, [parameters], [headers])` |Allows you to make an HTTP PATCH request and follow any subsequent redirects.|
-|`put_via_redirect(path, [parameters], [headers])` |Allows you to make an HTTP PUT request and follow any subsequent redirects.|
-|`delete_via_redirect(path, [parameters], [headers])` |Allows you to make an HTTP DELETE request and follow any subsequent redirects.|
-|`open_session` |Opens a new session instance.|
+| Helper | Purpose |
+| ------------------------------------------------------------------ | ------- |
+| `https?` | Returns `true` if the session is mimicking a secure HTTPS request.|
+| `https!` | Allows you to mimic a secure HTTPS request.|
+| `host!` | Allows you to set the host name to use in the next request.|
+| `redirect?` | Returns `true` if the last request was a redirect.|
+| `follow_redirect!` | Follows a single redirect response.|
+| `request_via_redirect(http_method, path, [parameters], [headers])` | Allows you to make an HTTP request and follow any subsequent redirects.|
+| `post_via_redirect(path, [parameters], [headers])` | Allows you to make an HTTP POST request and follow any subsequent redirects.|
+| `get_via_redirect(path, [parameters], [headers])` | Allows you to make an HTTP GET request and follow any subsequent redirects.|
+| `patch_via_redirect(path, [parameters], [headers])` | Allows you to make an HTTP PATCH request and follow any subsequent redirects.|
+| `put_via_redirect(path, [parameters], [headers])` | Allows you to make an HTTP PUT request and follow any subsequent redirects.|
+| `delete_via_redirect(path, [parameters], [headers])` | Allows you to make an HTTP DELETE request and follow any subsequent redirects.|
+| `open_session` | Opens a new session instance.|
### Integration Testing Examples
@@ -753,15 +758,16 @@ Rake Tasks for Running your Tests
You don't need to set up and run your tests by hand on a test-by-test basis. Rails comes with a number of rake tasks to help in testing. The table below lists all rake tasks that come along in the default Rakefile when you initiate a Rails project.
-|_.Tasks |_.Description|
-|`rake test` |Runs all unit, functional and integration tests. You can also simply run `rake` as the _test_ target is the default.|
-|`rake test:benchmark` |Benchmark the performance tests|
-|`rake test:functionals` |Runs all the functional tests from `test/functional`|
-|`rake test:integration` |Runs all the integration tests from `test/integration`|
-|`rake test:profile` |Profile the performance tests|
-|`rake test:recent` |Tests recent changes|
-|`rake test:uncommitted` |Runs all the tests which are uncommitted. Supports Subversion and Git|
-|`rake test:units` |Runs all the unit tests from `test/unit`|
+| Tasks | Description |
+| ------------------------------- | ----------- |
+| `rake test` | Runs all unit, functional and integration tests. You can also simply run `rake` as the _test_ target is the default.|
+| `rake test:benchmark` | Benchmark the performance tests|
+| `rake test:functionals` | Runs all the functional tests from `test/functional`|
+| `rake test:integration` | Runs all the integration tests from `test/integration`|
+| `rake test:profile` | Profile the performance tests|
+| `rake test:recent` | Tests recent changes|
+| `rake test:uncommitted` | Runs all the tests which are uncommitted. Supports Subversion and Git|
+| `rake test:units` | Runs all the unit tests from `test/unit`|
Brief Note About `Test::Unit`