Class: MockGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/mock/mock_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_mock_fileObject



7
8
9
10
11
12
13
14
15
# File 'lib/generators/mock/mock_generator.rb', line 7

def create_mock_file
  path = "app/mocks/#{file_name}_mock.rb"
  if FileTest.exist? path
    raise FileExistError, "This filename ist used by another mock:#{path}"
  end

  copy_file "mock_template.rb", path
  gsub_file path, '-MockName-' , "#{class_name}"
end