aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/testing.md
Commit message (Collapse)AuthorAgeFilesLines
* Change `ActionDispatch::Response#content_type` returning Content-Type header ↵yuuji.yaginuma2019-06-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | as it is Since #35709, `Response#conten_type` returns only MIME type correctly. It is a documented behavior that this method only returns MIME type, so this change seems appropriate. https://github.com/rails/rails/blob/39de7fac0507070e3c5f8b33fbad6fced84d97ed/actionpack/lib/action_dispatch/http/response.rb#L245-L249 But unfortunately, some users expect this method to return all Content-Type that does not contain charset. This seems to be breaking changes. We can change this behavior with the deprecate cycle. But, in that case, a method needs that include Content-Type with additional parameters. And that method name is probably the `content_type` seems to properly. So I changed the new behavior to more appropriate `media_type` method. And `Response#content_type` changed (as the method name) to return Content-Type header as it is. Fixes #35709. [Rafael Mendonça França & Yuuji Yaginuma ]
* Update testing guide to reflect changes from #36047Richard Macklin2019-05-081-1/+1
| | | | | | | | | | In #36047 we moved `take_failed_screenshot` from an `after_teardown` hook to a `before_teardown` hook. However, I didn't realize the Testing rails guide was explicitly mentioning that it happened inside `after_teardown`. So this updates the docs to be consistent with that change. [ci skip]
* Fix incorrect url in guide [ci skip]Robin Fisher2019-04-291-1/+1
| | | The example functional test lists the 'create' route as article_url rather than articles_url
* Merge pull request #35738 from gmcgibbon/aj_assert_drop_usec_docsGannon McGibbon2019-04-201-0/+19
|\ | | | | ActiveJob time argument assertion documentation
| * Add section on asserting time args for jobsGannon McGibbon2019-03-251-0/+19
| |
* | [ci skip] Fixed testing guides typo `fourty` -> `forty`Shailesh Kalamkar2019-03-281-3/+3
|/
* [ci skip] Minor documentation fixes for consistencyShailesh Kalamkar2019-03-091-1/+1
|
* Guides: Fix parent class of model test example (#35065)Sean Abrahams2019-03-091-1/+3
| | | | | | | * Fix parent class of model test example * include ActiveJob::TestHelper [ci skip]
* Update links and code examples in the guides to use HTTPS where the host ↵Nathaniel Suchy2019-03-061-29/+29
| | | | supports it.
* Fix typo in ActionCable::Connection::TestCase referenceRicardo Diaz2019-01-241-1/+1
|
* Merge pull request #35021 from palkan/refactor/broadcasting-for-testingKasper Timm Hansen2019-01-241-2/+29
|\ | | | | Action Cable: move channel_name to Channel.broadcasting_for
| * fix fixture syntax in cable docs and guidesVladimir Dementyev2019-01-221-3/+3
| |
| * Move `channel_name` to Channel.broadcasting_forVladimir Dementyev2019-01-221-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | That would allow us to test broadcasting made with channel, e.g.: ```ruby class ChatRelayJob < ApplicationJob def perform_later(room, msg) ChatChannel.broadcast_to room, message: msg end end ``` To test this functionality we need to know the underlying stream name (to use `assert_broadcasts`), which relies on `channel_name`. We had to use the following code: ```ruby assert_broadcasts(ChatChannel.broadcasting_for([ChatChannel.channel_name, room]), 1) do ChatRelayJob.perform_now end ``` The problem with this approach is that we use _internal_ API (we shouldn't care about `channel_name` prefix in our code). With this commit we could re-write the test as following: ```ruby assert_broadcasts(ChatChannel.broadcasting_for(room), 1) do ChatRelayJob.perform_now end ```
* | Corrected spelling of ActionCable::Connection::TestCaseAlan Brown2019-01-221-1/+1
|/
* Remove `frozen_string_literal` from Action Cable's template filesbogdanvlviv2019-01-161-6/+4
| | | | | | Related to 837f602fa1b3281113dac965a8ef96de3cac8b02 Fix the testing guide.
* Add Action Cable Testing guidesVladimir Dementyev2019-01-141-3/+111
|
* Add option to set parallel test worker count to the physical core count of ↵Bogdan2018-12-181-4/+4
| | | | | | | | | | | | | | | | | | | | | | the machine (#34735) * Add option to set parallel test worker count to the physical core count of the machine Also, use the physical core count of the machine as the default number of workers, and generate the `test_helper.rb` file with `parallelize(workers: :number_of_processors)` Closes #34734 * Ensure that we always test parallel testing Since #34734 we decided to use the physical core count of the machine as the default number of workers in the parallel testing, we need to ensure that some tests use at least 2 workers because we could run those tests on VM that has only 1 physical core. It also fixes tests failures on the CI since Travis server we are using has only one physical core. See https://travis-ci.org/rails/rails/jobs/469281088#L2352
* Add advanced test helpers docs to guidesSam Bostock2018-12-041-0/+50
| | | | [ci skip]
* Improve parallel testing guide [ci skip]bogdanvlviv2018-12-031-10/+9
| | | | | | | | - Fix formatting - Don't repeat "Active Record automatically handles creating and migrating a new database for each worker to use." - Tell that AR loads the schema to a database for each process(Related to #33479) - Clarify that `parallelize_teardown` is executed for each process
* Updating the Testing Guide to Reflect Emails Enqueued With ActiveJob [ci skip]Tom Rossi2018-11-251-7/+23
|
* Fix typo in testing guideanthonygharvey2018-10-171-1/+1
|
* [ci skip] Recommend testing information displayed over object storedKadu Ribeiro2018-09-271-1/+1
| | | | | | Since `assigns` is not placed by default with Rails, we suggested to test if the right information was displayed instead of suggesting to test if the right object was stored in the template.
* Fix header setting doc in testing guide [ci skip]Darren2018-08-131-3/+2
|
* Testing Guide: unnecessary commentutilum2018-07-251-1/+1
| | | | | | | | | This has been around as far back as I can [see](https://github.com/rails/rails/blob/5137d03cc5b2a5f0820bdcf11b0fffe5bf461470/guides/source/testing.md). No need to specify the obvious. [ci skip]
* Merge pull request #33229 from ↵Matthew Draper2018-07-251-33/+33
|\ | | | | | | | | albertoalmagro/albertoalmagro/prefer-rails-command-over-bin-rails Prefer rails command over bin/rails
| * Recommend use of rails over bin/railsAlberto Almagro2018-07-061-33/+33
| | | | | | | | | | | | | | | | | | As discussed in #33203 rails command already looks for, and runs, bin/rails if it is present. We were mixing recommendations within guides and USAGE guidelines, in some files we recommended using rails, in others bin/rails and in some cases we even had both options mixed together.
* | Rails guides are now served over httpsPaul McMahon2018-07-241-1/+1
|/ | | | | http links will be redirected to the https version, but still better to just directly link to the https version.
* Fix testing guide typoJon Evans2018-06-011-1/+1
|
* Added a lot of Oxford commasAnthony Crumley2018-05-101-2/+2
| | | | | | | [ci skip] A regular expression was used to find a lot of missing Oxford commas and add them. The regular expression was as follows. ", ([a-zA-Z0-9.\`:'\"]+ ){1,6}(or|and) "
* Fix url_helper examples in testing guide [ci skip]Chris Houhoulis2018-04-291-4/+4
|
* [ci skip] Fix typo in testing.mdPradyumna Shembekar2018-04-271-1/+1
|
* Update results of command in Testing guides [ci skip]Yoshiyuki Hirano2018-04-231-13/+14
| | | | | * Results of command in testing guides are different from actual ones. * Updated them.
* Merge pull request #32575 from ybakos/guides/testing/pluralize_class_namesRafael França2018-04-191-3/+3
|\ | | | | guides/testing: Pluralize controller and helper class names.
| * guides/testing: Pluralize controller and helper class names.Yong Bakos2018-04-141-3/+3
| | | | | | | | | | | | The Rails convention for controllers and helpers is plural, except where intentionally singular. Pluralize the controller and helper class names, to match convention.
* | [ci skip] Fix minor system testing documentation typo.Stephen2018-04-181-1/+1
|/
* Merge descriptions related to parallel test into one section [ci skip]yuuji.yaginuma2018-02-171-2/+2
|
* Add test parallelization to Railseileencodes2018-02-151-0/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Provides both a forked process and threaded parallelization options. To use add `parallelize` to your test suite. Takes a `workers` argument that controls how many times the process is forked. For each process a new database will be created suffixed with the worker number; test-database-0 and test-database-1 respectively. If `ENV["PARALLEL_WORKERS"]` is set the workers argument will be ignored and the environment variable will be used instead. This is useful for CI environments, or other environments where you may need more workers than you do for local testing. If the number of workers is set to `1` or fewer, the tests will not be parallelized. The default parallelization method is to fork processes. If you'd like to use threads instead you can pass `with: :threads` to the `parallelize` method. Note the threaded parallelization does not create multiple database and will not work with system tests at this time. parallelize(workers: 2, with: :threads) The threaded parallelization uses Minitest's parallel exector directly. The processes paralleliztion uses a Ruby Drb server. For parallelization via threads a setup hook and cleanup hook are provided. ``` class ActiveSupport::TestCase parallelize_setup do |worker| # setup databases end parallelize_teardown do |worker| # cleanup database end parallelize(workers: 2) end ``` [Eileen M. Uchitelle, Aaron Patterson]
* Merge pull request #31240 from PHedkvist/sys_test_mobile_guideEileen M. Uchitelle2018-02-061-0/+28
|\ | | | | Example of multiple configurations for system test in guide [ci skip]
| * Example of mobile configuration for system test in guide [ci skip]Pierre Hedkvist2017-12-041-0/+28
| |
* | Fix doc typo [ci-skip]Tom Copeland2018-01-121-1/+1
| |
* | Fix "the the " [ci skip]Ryuta Kamizono2018-01-101-1/+1
| |
* | Merge pull request #30474 from yhirano55/make_it_same_title_in_index_and_pageEileen M. Uchitelle2017-12-131-2/+2
|\ \ | | | | | | Make it same title in index and page [ci skip]
| * | Make it same title in index and page [ci skip]Yoshiyuki Hirano2017-08-311-2/+2
| | |
* | | Add headless firefox driver to System Testsbogdanvlviv2017-12-071-1/+2
| | |
* | | Add `assert_in_epsilon` to Testing guide [ci skip]Yoshiyuki Hirano2017-12-061-0/+2
| |/ |/| | | | | | | | | | | | | | | I found `assert_in_epsilon` is not be in "2.4 Available Assertions". So I Added them. MiniTest::Assertions#assert_in_epsilon: https://github.com/seattlerb/minitest/blob/master/lib/minitest/assertions.rb#L204-L210
* | Cosmetic changes [ci skip]Yauheni Dakuka2017-11-301-1/+1
| |
* | [ci skip] Added example for using headless_chrome with ↵Pierre Hedkvist2017-11-181-0/+10
| | | | | | | | ActionDispatch::SystemTestCase
* | [ci skip] Fix typo.Conrad Beach2017-09-281-1/+1
|/
* Merge pull request #30394 from ydakuka/fixing-indentationRyuta Kamizono2017-08-241-1/+1
|\ | | | | Fix indentation [ci skip]
| * Fix indentation [ci skip]Yauheni Dakuka2017-08-241-1/+1
| |