# associated records. <tt>option_tags</tt> is a string containing the option tags for the select box.
#
# ==== Options
# * <tt>:multiple</tt> - If set to true the selection will allow multiple choices.
# * <tt>:multiple</tt> - If set to true, the selection will allow multiple choices.
# * <tt>:disabled</tt> - If set to true, the user will not be able to use this input.
# * <tt>:include_blank</tt> - If set to true, an empty option will be created. If set to a string, the string will be used as the option's content and the value will be empty.
# * <tt>:prompt</tt> - Create a prompt option with blank value and the text asking user to select something.
We see there is an empty response (no data after the `Cache-Control` line), but the request was successful because Rails has set the response to 200 OK. You can set the `:status` option on render to change this response. Rendering nothing can be useful for Ajax requests where all you want to send back to the browser is an acknowledgment that the request was completed.
Rails comes with a number of built-in rake tasks to help with testing. The
table below lists the commands included in the default Rakefile when a Rails
project is created.
| Tasks | Description |
| ----------------------- | ----------- |
| `rake test` | Runs all tests in the `test` directory. You can also run `rake` and Rails will run all tests by default |
| `rake test:controllers` | Runs all the controller tests from `test/controllers` |
| `rake test:functionals` | Runs all the functional tests from `test/controllers`, `test/mailers`, and `test/functional` |
| `rake test:helpers` | Runs all the helper tests from `test/helpers` |
| `rake test:integration` | Runs all the integration tests from `test/integration` |
| `rake test:jobs` | Runs all the job tests from `test/jobs` |
| `rake test:mailers` | Runs all the mailer tests from `test/mailers` |
| `rake test:models` | Runs all the model tests from `test/models` |
| `rake test:units` | Runs all the unit tests from `test/models`, `test/helpers`, and `test/unit` |
| `rake test:db` | Runs all tests in the `test` directory and resets the db |
### Console Tasks for Running your Tests
Rails comes with a CLI command to run tests.
Here are some examples of how to use it:
```bash
$ bin/rails test# run all tests in the `test` directory
$ bin/rails test test/controllers # run all tests from specific directory
$ bin/rails test test/models/post_test.rb # run specific test
$ bin/rails test test/models/post_test.rb:44 # run specific test and line
```
We will cover each of types Rails tests listed above in this guide.
Model Testing
------------------------
In Rails, unit tests are what you write to test your models.
For this guide we will be using the application we built in the [Getting Started with Rails](getting_started.html) guide.
If you remember when you used the `rails generate scaffold` command from earlier. We created our first resource among other things it created a test stub in the `test/models` directory:
...
...
@@ -259,10 +250,10 @@ be rebuilt. This can be done by executing `bin/rake db:test:prepare`.
### Running Tests
Running a test is as simple as invoking the file containing the test cases through `rake test` command.
Running a test is as simple as invoking the file containing the test cases through `rails test` command.
```bash
$ bin/raketest test/models/article_test.rb
$ bin/railstest test/models/article_test.rb
.
Finished tests in 0.009262s, 107.9680 tests/s, 107.9680 assertions/s.
...
...
@@ -275,7 +266,7 @@ This will run all test methods from the test case.
You can also run a particular test method from the test case by running the test and providing the `test method name`.
NOTE: If you try running `test_should_create_article` test from `articles_controller_test.rb` it will fail on account of the newly added model level validation and rightly so.