[RUBY] How to run only specific files with gem's rake test

I can't find it in the existing article (maybe it's just a bad search), and it was difficult to find it in the reference, so I will write it as an article.

If you are developing a gem and want to run tests

rake test

And it is sufficient. Oops, as a prerequisite

bundle gem hoge

Let's use a gem with a typical configuration made as follows.

What if you want to run only a specific test file? You can specify the file as follows.

rake test TEST=path/to/some_test.rb

This is the official Ruby reference class Rake :: TestTask (Ruby 2.7.0 Reference Manual) It was written as "Example of using test target". Hmmm, but it's quite difficult to get to this page. Besides, there is no explanation, only one line is posted as an "example".

In my experiments, it seemed that wildcards could be used to specify TEST. Therefore, if it is troublesome to write directories and extensions

rake test TEST=**/*/some_test*

It can also be done like this.

By the way, in the case of gem made with bundle gem hoge, test is the default task, so test is abbreviated.

rake TEST=**/*/some_test*

You can also write.

Recommended Posts

How to run only specific files with gem's rake test
How to share files with Docker Toolbox
How to test private scope with JUnit
How to run Blazor (C #) with Docker
How to limit IP address only to a specific directory with laravel + nginx
Add class only to specific elements with V-for
[Java] How to test for null with JUnit
How to test interrupts during Thread.sleep with JUnit
How to write test code with Basic authentication
How to get resource files out with spring-boot
How to implement UICollectionView in Swift with code only
How to run javafx with Raspberry Pi Posted on 2020/07/12
How to unit test with JVM with source using RxAndroid
Uppercase only the specified range with substring. (How to use substring)
How to number (number) with html.erb
How to test a private method with RSpec for yourself
How to update with activerecord-import
How to erase test image after running Rspec test with CarrierWave
How to rollback migration files
How to delete only specific data from data created using Form object
How to run a job with docker login in AWS batch
kotlin & Java: How to hide the toolbar only for specific fragments
How to scroll horizontally with ScrollView
How to unit test Spring AOP
How to get started with slim
How to run JUnit in Eclipse
How to disassemble Java class files
How to enclose any character with "~"
How to run JavaFX on Docker
How to use mssql-tools with alpine
How to decompile java class files
How to get along with Rails
[RSpec] How to write test code
How to start Camunda with Docker
How to use args :, environment :, env_file: and .env files with docker-compose command
How to compare only the time with Rails (from what time to what time, something like)
How to crop an image with libGDX
How to adjustTextPosition with iOS Keyboard Extension
How to use binding.pry for view files
How to compile Java with VsCode & Ant
[Java] How to compare with equals method
How to filter JUnit Test in Gradle
Run Embulk on Docker to convert files
How to use BootStrap with Play Framework
[Rails] How to use rails console with docker
How to switch thumbnail images with JavaScript
[Note] How to get started with Rspec
[Java] How to output and write files!
How to do API-based control with cancancan
How to achieve file download with Feign
How to update related models with accepts_nested_attributes_for
How to set JAVA_HOME with Maven appassembler-maven-plugin
How to implement TextInputLayout with validation function
How to handle sign-in errors with devise
How to delete data with foreign key
How to monitor nginx with docker-compose with datadog
How to deal with Precompiling assets failed.
How to write an RSpec controller test
[SpringBoot] How to write a controller test
How to achieve file upload with Feign
How to build Rails 6 environment with Docker