Skip to content

Instantly share code, notes, and snippets.

@nicklewis
Created September 14, 2011 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicklewis/1217449 to your computer and use it in GitHub Desktop.
Save nicklewis/1217449 to your computer and use it in GitHub Desktop.
Run specs in random order
#!/usr/bin/env ruby
if size_opt = ARGV.index('-s')
seed = ARGV[size_opt+1]
end
seed ||= Time.now.to_i
if clip_opt = ARGV.index('-c')
begin
require 'rubygems'
require 'clipboard'
Clipboard.copy(seed)
rescue LoadError => e
warn "Could not load 'clipboard' gem which is necessary for '-c'"
end
end
puts "Using seed #{seed}"
srand(seed)
files = Dir['spec/**/*_spec.rb'].sort_by {rand}
system 'rspec', *files
exit $?
@nicklewis
Copy link
Author

Use -s to specify a particular seed value, and -c to automatically copy the seed of the following run to the clipboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment