New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

test-this

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

test-this

  • 0.2.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Test::This

Often I want to run just one test in a class full of other tests. I usually end up just commenting out everything except for the one test I want to run, but that's kind of lame, so I decided to write a Rake test that lets me do this instead:

$ rake test:this["models/the_model","this is the test"]

This works for both Rails and Minitest.

Installation

Add this line to your application's Gemfile:

gem 'test-this'

And then execute:

$ bundle

Or install it yourself as:

$ gem install test-this

After you install the gem, add this to your Rakefile to use it:

require 'test/this'

Test::This.configure do |config|
  config.file_suffix = '_test.rb'
  config.test_method_prefix = 'test_'
  config.test_path = File.expand_path('../test', __FILE__)
end

Usage

To run a single test from a class full of other tests you don't want to run:

$ rake test:this["controllers/this_controller","the name of the test"]

To test all of the tests in a class full of tests you want to run:

$ rake test:this["controllers/this_controller"]

Note that you can leave off the trailing _test.rb in the name of the test and the prefixed test_ in the name of the test methods for Minitest. For example, if your Minitest case looked like this:

# file: test/something_test.rb
class SomethingTest < Minitest::Test
  def test_the_test_to_run
    assert true
  end

  def test_not_the_test_to_run
    fail
  end
end

To run the test_the_test_to_run:

$ rake test:this["something","the test to run"]

Spaces will automatically be converted to underscores.

Contributing

Bug reports and pull requests are welcome on GitHub at hi5dev/test-this.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 16 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc