aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/test_unit
Commit message (Collapse)AuthorAgeFilesLines
* Change the empty block style to have space inside of the blockRafael Mendonça França2018-09-251-2/+2
|
* use "minitest" consistentlyXavier Noria2018-09-111-2/+2
| | | | | | | | | The name of the minitest library is spelled that way: regular font, and lowercase. Lowercase is used even at the beginning of sentences, see http://docs.seattlerb.org/minitest/ I double-checked this with @zenspider too (thanks!).
* Enable Start/EndWith and RegexpMatch copsBart de Water2018-07-281-1/+1
| | | | | In cases where the MatchData object is not used, this provides a speed-up: https://github.com/JuanitoFatas/fast-ruby/#stringmatch-vs-stringmatch-vs-stringstart_withstringend_with-code-start-code-end
* Show rails instead of bin/rails on USAGE instructionsAlberto Almagro2018-07-061-1/+1
| | | | | With this commit, rails commands usage instructions display now +rails+ instead of +bin/rails+ within their recommendations.
* Need to use `klass` to get the class name of the test resultyuuji.yaginuma2018-01-031-1/+2
| | | | Ref: http://docs.seattlerb.org/minitest/Minitest/Result.html#attribute-i-klass
* Correctly get source locationyuuji.yaginuma2018-01-031-1/+6
| | | | | `filtered_results` returns an instance of `Minitest::Result` since https://github.com/seattlerb/minitest/commit/00433fc0a4fdd0e6b302aace633384ba13122376 `Minitest::Result` is not test class. So cannot get location directly.
* Set the Rails environment from an environment variableAaron Patterson2017-12-081-4/+1
| | | | | | | | | Option parsing happens too late to have any impact on the Rails environment. Rails accesses the environment name and memoizes it too early in the boot process for a commandline option to have any impact on the database connection, so we'll change this test to set the environment from an environment variable (and ensure it still works when running tests with `ruby`)
* Fix Rails environment when running tests with RubyAaron Patterson2017-12-061-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | I frequently run tests with `ruby`, not with a runner like `rake` or `rails`. When running the test with just `ruby` the `RAILS_ENV` environment variable did not get set to "test", and this would cause the tests to fail (and even mutate the development database!) This commit adds integration tests for running tests with just `ruby` and ensures the environment gets defaulted to "test". I also added a test to ensure that passing an environment to `-e` actually works (and fixed that case too). An interesting / annoying thing is that Minitest picks up it's plugins by asking RubyGems for a list of files: https://github.com/seattlerb/minitest/blob/ca6a71ca901016db09a5ad466b4adea4b52a504a/lib/minitest.rb#L92-L100 This means that RubyGems needs to somehow know about the file before it can return it to Minitest. Since we are not packaging Rails as a Gem before running the integration tests on it (duh, why would you do that?), RubyGems doesn't know about the file, so it can't tell Minitest, so Minitest doesn't automatically require it. This means I had to manually require and insert the plugin in our integration test. I've left comments about that in the test as well. Ugh.
* [Railties] require_relative => requireAkira Matsuda2017-10-212-2/+2
| | | | This basically reverts 618268b4b9382f4bcf004a945fe2d85c0bd03e32
* Remove unused requireyuuji.yaginuma2017-08-191-1/+0
| | | | Since 0d72489, this file does not use `method_source`.
* Merge pull request #29891 from pat/frozen-string-literals-railtiesRafael França2017-08-144-0/+8
|\ | | | | Railties updates for frozen string literals.
| * Adding frozen_string_literal pragma to Railties.Pat Allan2017-08-144-0/+8
| |
* | Show minitest options in test runner helpyuuji.yaginuma2017-07-311-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since #29572, minitest options are available but are no longer showed in help. This fixed to show minitest option in help as with Rails 5.1.2. **before** ``` ./bin/rails t --help You can run a single test by appending a line number to a filename: bin/rails test test/models/user_test.rb:27 You can run multiple files and directories at the same time: bin/rails test test/controllers test/integration/login_test.rb By default test failures and errors are reported inline during a run. Rails options: -w, --warnings Run with Ruby warnings enabled -e, --environment Run tests in the ENV environment -b, --backtrace Show the complete backtrace -d, --defer-output Output test failures and errors after the test run -f, --fail-fast Abort test run on first failure or error -c, --[no-]color Enable color in the output ``` **after** ``` ./bin/rails t --help You can run a single test by appending a line number to a filename: bin/rails test test/models/user_test.rb:27 You can run multiple files and directories at the same time: bin/rails test test/controllers test/integration/login_test.rb By default test failures and errors are reported inline during a run. minitest options: -h, --help Display this help. -s, --seed SEED Sets random seed. Also via env. Eg: SEED=n rake -v, --verbose Verbose. Show progress processing files. -n, --name PATTERN Filter run on /regexp/ or string. --exclude PATTERN Exclude /regexp/ or string from run. Known extensions: rails, pride -w, --warnings Run with Ruby warnings enabled -e, --environment Run tests in the ENV environment -b, --backtrace Show the complete backtrace -d, --defer-output Output test failures and errors after the test run -f, --fail-fast Abort test run on first failure or error -c, --[no-]color Enable color in the output -p, --pride Pride. Show your testing pride! ```
* Merge pull request #29926 from pawandubey:fix-test-with-absolute-pathsKasper Timm Hansen2017-07-251-1/+4
|\
| * Allow bin/rails test task to take absolute paths as argumentsPawan Dubey2017-07-251-3/+3
|/ | | | | | | | | | | | | | | | | | | Solves #29923 This regression was caused due to a wrong regex to filter out paths, introduced in commit 796a1cf0e The regex was /^\w+\// which did not accept paths with a leading slash and hence all absolute paths were filtered out. This change introduces a change in regex which allows for a leading slash and acts on the matched term accordingly. While cascading through the case block, the paths are checked for line number specification, existence of a directory at that path and if none of those match, then it is considered to be a path to the file. The regex matchers specified are filtered out via the call to `Array#compact` since they do not match any of these conditions.
* Fix root not being defined on Travis.Kasper Timm Hansen2017-07-161-1/+6
|
* * Don't eagerly require Rails' minitest plugin.Kasper Timm Hansen2017-07-105-252/+150
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | By making the Rails minitest behave like a standard minitest plugin we're much more likely to not break when people use other minitest plugins. Like minitest-focus and pride. To do this, we need to behave like minitest: require files up front and then perform the plugin behavior via the at_exit hook. This also saves us a fair bit of wrangling with test file loading. Finally, since the environment and warnings options have to be applied as early as possible, and since minitest loads plugins at_exit, they have to be moved to the test command. * Don't expect the root method. It's likely this worked because we eagerly loaded the Rails minitest plugin and that somehow defined a root method on `Rails`. * Assign a backtrace to failed exceptions. Otherwise Minitest pukes when attempting to filter the backtrace (which Rails' backtrace cleaner then removes). Means the exception message test has to be revised too. This is likely caused by the rails minitest plugin now being loaded for these tests and assigning a default backtrace cleaner.
* [Railties] require => require_relativeAkira Matsuda2017-07-013-4/+4
|
* Use mattr_accessor default: option throughout the projectGenadi Samokovarov2017-06-031-1/+1
|
* Add option for class_attribute default (#29270)David Heinemeier Hansson2017-05-291-2/+1
| | | | | | | | | | | | * Allow a default value to be declared for class_attribute * Convert to using class_attribute default rather than explicit setter * Removed instance_accessor option by mistake * False is a valid default value * Documentation
* Update system test runner docseileencodes2017-05-141-0/+1
| | | | | | | | | It wasn't clear that system tests don't run with the rest of the test suite and are part of a separate command. This documents the `test:system` command as well as update the Rails runner help documentation to make it clearer that system tests are run via their own command by default.
* rake -T should load development env by default, not testTimo Kilpilehto2017-05-101-1/+1
|
* Allow to receive arbitrary arguments in `aggregated_results`yuuji.yaginuma2017-05-101-1/+1
| | | | | Argument was added to `aggregated_results` in minitest 5.10.2. Ref: https://github.com/seattlerb/minitest/commit/c6ba2afd90473b76d289562edd24f7d7ca8484f9
* Avoid running system tests by defaultRobin Dupret2017-03-053-10/+19
| | | | | | | | | | These tests may be expansive so let's only allow users to run them through `bin/rails test:system` or by passing a path to the `test` command. The same applies for `bin/rake test`. Refs #28109.
* Fix run_via[]= backwards compatibility.Kasper Timm Hansen2017-02-211-1/+3
| | | | | | | | | ``` Minitest.run_via[:rails] = true ``` 👆 would break because a simple alias won't catch the second true argument there.
* Merge pull request #26703 from eileencodes/rails_system_testsEileen M. Uchitelle2017-02-202-0/+6
|\ | | | | WIP: Capybara Integration with Rails (AKA System Tests)
| * Refactor config settings to use generated fileeileencodes2017-02-201-13/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Originally I had set up system testing to have one configuration option to be set in the test environment. After thinking it over I think a generated class on app creation would be best. The reason for this is Capybara has a ton of configuration options that I'm sure some folks want to use. Thinking about how we handle screenshots, database transactions, and a whole bunch of other settings it would be better for users to be able to turn all of that on and off. When an app or scaffold is generated a `test/system_test_helper.rb` test helper will be generated as well. This will contain the class for tests to inherit from `ActionSystemTestCase` which will inherit from `ActionSystemTest::Base`. Here is where users can change the test driver, remove the screenshot helper, and add their additional Capybara configuration.
| * Don't load ActionSystemTest in productioneileencodes2017-02-201-0/+12
| | | | | | | | | | | | | | | | | | | | By moving to the TestUnit Railtie, and doing the file requirement inside the onload call we can avoid loading ActionSystemTest in production and load it in the test env. This is important for performance reasons - loading up unnecessary files and object is expensive, especially when they should never be used in production.
| * Add generators and ability to run system testseileencodes2017-02-202-0/+6
| | | | | | | | | | | | | | * Generates system test requirements with new Rails app * Includes required default gems in Gemfile for Rails app * Generates a single system test case * Generates a system test case with scaffold
* | Prevent multiple values being set to `run_via`yuuji.yaginuma2017-02-181-5/+29
|/ | | | | When executing the test via rake, since `rake` is set for `run_via`, `ruby` should not be set. Related 2cb6c27310452da11b93d729c3b760ce988106e1
* Collect all file patterns when running multiple rake test tasksDominic Cleal2017-02-041-7/+7
| | | | | | | Replaces the rake_patterns instance variable with simple require, as `autorun` will run tests from all eagerly required test files. Fixes #27801
* add warnings option to test runneryuuji.yaginuma2017-01-241-0/+5
|
* Use `on_load` to trigger commandline processing codeAaron Patterson2016-10-211-0/+8
| | | | We need to use on_load so that plugins will get the same functionality
* Prevent the test framework from being loaded in production modeAaron Patterson2016-10-211-6/+0
| | | | | | | | | | | | The test framework should not be autoloaded in production mode. Before this commit, the testing railtie would extend AS::TestCase. This caused AS::TestCase to be preloaded regardless of the environment in which we were running. This commit just moves the code that adds line filtering support in to the test command where we actually execute the test runner. That allows us to maintain the line runner feature but only load the minimal amount of code we need.
* Use autorun when running via Rake.Kasper Timm Hansen2016-09-251-3/+13
| | | | | | | Makes sure we get support for `Minitest.after_run` hooks and don't accidentally run tests twice. Requires overriding minitest `run` to respect the TESTOPTS variable.
* Revise setting of run_with_rails_extension.Kasper Timm Hansen2016-09-251-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | The Rails test runner supports three ways to run tests: directly, via rake, or ruby. When Running with Ruby ala `ruby -Itest test/models/post_test.rb` our test file would be evaluated first, requiring `test_helper` and then `active_support/testing/autorun` that would then require the test file (which it hadn't been before) thus reevaluating it. This caused exceptions if using Active Support's declarative syntax. Fix this by shifting around when we set the how we're run to closer mimick the require order. If we're running with `bin/rails test` the test command file is run first and we then set `run_with_rails_extension`, later we hit `active_support/testing/autorun` and do nothing — because we've been run elsewhere. If we at this point haven't set `run_with_rails_extension` we've been running with `ruby` this whole time and thus we set that. We should always trigger `Minitest.autorun` as it doesn't hurt to call it twice. Consolidate the two methods into a single one that better brings out the intent of why they're there.
* code gardening: removes redundant selfsXavier Noria2016-08-081-1/+1
| | | | | | | | | A few have been left for aesthetic reasons, but have made a pass and removed most of them. Note that if the method `foo` returns an array, `foo << 1` is a regular push, nothing to do with assignments, so no self required.
* revises most Lint/EndAlignment offensesXavier Noria2016-08-071-3/+3
| | | | Some case expressions remain, need to think about those ones.
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-1/+1
|
* modernizes hash syntax in railtiesXavier Noria2016-08-061-5/+5
|
* applies new string literal convention in railties/libXavier Noria2016-08-066-17/+17
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* remove unnessary option setting from test runneryuuji.yaginuma2016-04-251-5/+2
| | | | | | | If run the test over the `rake` command, because of the test patterns is passed via `rake_run` method, do not need to be obtained from the argv. This probably fixes #24372.
* [ci skip] Improve comment minitest plugin initialization.Kasper Timm Hansen2016-03-221-2/+4
| | | | | Didn't feel we were clear enough about our motivation for placing Rails first and why we needed to call `load_plugins`.
* Don't get ahead of ourselves.Kasper Timm Hansen2016-03-221-3/+3
| | | | The useless explicit self calls were driving me nuts.
* Set Rails as the first minitest initialized plugin.Kasper Timm Hansen2016-03-221-1/+3
| | | | | | | | | | | When calling `load_plugins` minitest would fill out its extensions, then we'd tackle ourselves on as the last plugin. Because minitest loads plugins in order we will ultimately have the last say on what reporters will be used. Invert that strategy by putting ourselves first and give other plugins plenty of leeway to override our default reporter setup. Fixes #24179.
* make sure `rake test` respects TESTOPTSAaron Patterson2016-02-221-1/+2
| | | | | We should be able to pass options to minitest via TESTOPTS environment variable
* [ci skip] Mention testing fore-runners.Kasper Timm Hansen2016-02-211-0/+2
| | | | Get it? ( ͡° ͜ʖ ͡°)
* use method provided by minitestyuuji.yaginuma2016-02-211-7/+1
| | | | | | | The process of converting `Test` to `String` is already defined in minitest. I think it is better to use that for the consistency of output content. ref: https://github.com/seattlerb/minitest/blob/master/lib/minitest/test.rb#L261..L267
* modify to `error` also abort when specify fail fast optionyuuji.yaginuma2016-02-172-2/+2
|
* test runner, relay minitest information about the error location.Yves Senn2016-02-151-1/+1
| | | | | This is a follow-up to ea70c29 to bring back the assertion error location information provided by minitest.