class SpecMigration
Public Class Methods
new(basedir)
click to toggle source
# File lib/r2m/spec_migration.rb, line 6 def initialize(basedir) @basedir = Pathname(basedir) end
Public Instance Methods
migrate(spec_file)
click to toggle source
# File lib/r2m/spec_migration.rb, line 10 def migrate(spec_file) # rubocop:todo Metrics/AbcSize move_and_rename_spec_to_test(spec_file) end
move_and_rename_spec_to_test(spec_file)
click to toggle source
# File lib/r2m/spec_migration.rb, line 22 def move_and_rename_spec_to_test(spec_file) relative_path, spec_basename = split_path(spec_file) test_root = @basedir / 'test' test_dirname = test_root + relative_path FileUtils.mkdir_p test_dirname test_basename = spec_basename.sub(/_spec(?=\.rb)/, '_test') test_file = test_dirname + test_basename FileUtils.cp spec_file, test_file unless test_file.exist? test_file end
split_path(file)
click to toggle source
# File lib/r2m/spec_migration.rb, line 14 def split_path(file) spec_root = @basedir / 'spec' dirname, basename = Pathname(file).split relative_path = dirname.relative_path_from(spec_root) [relative_path, basename] end