Skip to content

Instantly share code, notes, and snippets.

@suya55
Created July 9, 2018 04:52
Show Gist options
  • Save suya55/9b59885af90f334507c769b710274e6d to your computer and use it in GitHub Desktop.
Save suya55/9b59885af90f334507c769b710274e6d to your computer and use it in GitHub Desktop.
rspec by name
require 'open3'
namespace :test do
rule '' do |t|
# rake test:league
if /test:(.*)(:([^.]+))?$/.match(t.name)
arguments = t.name.split(':')[1..-1]
file_name = arguments.first
path = Dir["spec/**/*#{file_name}*_spec.rb"].join(' ')
unless path.strip.empty?
puts "=========[ #{path} test result ]=======================================================".colorize(:black).colorize(background: :white)
Open3.pipeline_r("rspec --tty --colour #{path}") do |o, _ts|
o.each_line do |line|
puts(line)
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment