```ruby
Dir['algorithms/**/*.md'].each do |file_name|
  matcher = File.read(file_name).match(/~~~\n(require 'rspec'\n.+?)\n~~~/m)

  next if matcher.nil?

  puts "Running #{file_name}"
  matcher.captures.each do |capture|
    File.write('_site/spec.rb', capture)
    system('rspec _site/spec.rb')
  end
end```

Support running spec for one file.
user
```ruby
require 'tempfile'

Dir[ARGV[0] || 'algorithms/**/*.md'].each do |filename|
  matcher = File.read(filename).match(/~~~\n(require 'rspec'\n.+?)\n~~~/m)

  next if matcher.nil?

  puts "Running #{filename}"
  matcher.captures.each do |capture|
    tempfile = Tempfile.new('spec')
    tempfile.write(capture)
    tempfile.close

    system("rspec #{tempfile.path}")

    tempfile.unlink
  end
end```
assistant