Class: BunBo

Inherits:
Object
  • Object
show all
Defined in:
lib/bun_bo.rb,
lib/bun_bo/version.rb,
lib/bun_bo/file_not_found.rb

Defined Under Namespace

Classes: FileNotFound

Constant Summary collapse

VERSION =
"0.1.3"

Instance Method Summary collapse

Instance Method Details

#run(input_path) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/bun_bo.rb', line 6

def run(input_path)
  input_path = Pathname.new(input_path)

  if input_path.file?
    folder_path, file_name = input_path.split
    extension = file_name.extname
    base_name = file_name.basename(extension)

    test_folder = folder_path.sub(/^(app|lib)/, 'spec')
    test_path = test_folder.join("#{base_name}_spec").sub_ext(".rb")

    FileUtils.mkdir_p(test_folder)
    test_path.write('')
  else
    raise FileNotFound
  end
end