Sha256: 6f5fe6c1e2370718de6798bb438080f47518fe886aa4e68828d80266c1ac5a39

Contents?: true

Size: 1.32 KB

Versions: 250

Compression:

Stored size: 1.32 KB

Contents

#!/usr/bin/env ruby
require 'fileutils'
require 'tmpdir'

TMP = Dir::tmpdir

def usage(msg = nil)
  puts "Error: #{msg}" if msg
  puts if msg
  puts "Usage: #{File.basename(__FILE__)} normal_test_file.rb"
  puts
  puts "Will convert an existing test file with names like "
  puts
  puts "  def test_should_do_stuff"
  puts "    ..."
  puts "  end"
  puts
  puts "to one using the new syntax: "
  puts
  puts "  should \"be super cool\" do"
  puts "    ..."
  puts "  end"
  puts
  puts "A copy of the old file will be left under #{TMP} in case\nthis script just seriously screws up"
  puts
  exit (msg ? 2 : 0)
end

usage("Wrong number of arguments.") unless ARGV.size == 1
usage("Temp directory '#{TMP}' is not valid. Set TMPDIR environment variable to a writeable directory.") unless File.directory?(TMP) && File.writable?(TMP)

file = ARGV.shift
tmpfile = File.join(TMP, File.basename(file))
usage("File '#{file}' doesn't exist") unless File.exists?(file)

FileUtils.cp(file, tmpfile)
contents = File.read(tmpfile)
contents.gsub!(/def test_should_(\S+)/) {|line| "should \"#{$1.tr('_', ' ')}\" do"}
contents.gsub!(/def test_(\S+)/) {|line| "should \"RENAME ME: test #{$1.tr('_', ' ')}\" do"}
File.open(file, 'w') { |f| f.write(contents) }

puts "File '#{file}' has been converted to 'should' syntax.  Old version has been stored in '#{tmpfile}'"

Version data entries

250 entries across 206 versions & 33 rubygems

Version Path
dirty_history-0.5.0 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/bin/convert_to_should_syntax
dirty_history-0.5.0 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/bin/convert_to_should_syntax
dirty_history-0.5.0 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/bin/convert_to_should_syntax
challah-0.4.1 vendor/bundle/gems/shoulda-2.11.3/bin/convert_to_should_syntax
challah-0.4.0 vendor/bundle/gems/shoulda-2.11.3/bin/convert_to_should_syntax
challah-0.3.5 vendor/bundle/gems/shoulda-2.11.3/bin/convert_to_should_syntax
faster_shoulda-2.11.4 bin/convert_to_should_syntax
challah-0.3.4 vendor/bundle/gems/shoulda-2.11.3/bin/convert_to_should_syntax
challah-0.3.3 vendor/bundle/gems/shoulda-2.11.3/bin/convert_to_should_syntax
challah-0.3.2 vendor/bundle/gems/shoulda-2.11.3/bin/convert_to_should_syntax
challah-0.3.1 vendor/bundle/gems/shoulda-2.11.3/bin/convert_to_should_syntax
challah-0.3.0 vendor/bundle/gems/shoulda-2.11.3/bin/convert_to_should_syntax
challah-0.2.1 vendor/bundle/gems/shoulda-2.11.3/bin/convert_to_should_syntax
challah-0.2.0 vendor/bundle/gems/shoulda-2.11.3/bin/convert_to_should_syntax
chida_fib-0.1.0 shoulda/ruby/1.8/gems/shoulda-2.11.3/bin/convert_to_should_syntax
dirty_history-0.4.10 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/bin/convert_to_should_syntax
dirty_history-0.4.10 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/bin/convert_to_should_syntax
dirty_history-0.4.10 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/bin/convert_to_should_syntax
dirty_history-0.4.9 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/bin/convert_to_should_syntax
dirty_history-0.4.9 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/bin/convert_to_should_syntax