Class: MiniTest::Generators::Base

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

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.default_source_rootObject



13
14
15
# File 'lib/generators/mini_test.rb', line 13

def self.default_source_root
  File.expand_path(File.join(File.dirname(__FILE__), 'mini_test', generator_name, 'templates'))
end

Instance Method Details

#attributes_namesObject



33
34
35
36
37
38
# File 'lib/generators/mini_test.rb', line 33

def attributes_names
  @attributes_names ||= attributes.each_with_object([]) do |a, names|
    names << a.column_name
    names << "#{a.name}_type" if a.polymorphic?
  end
end

#key_value(key, value) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/generators/mini_test.rb', line 25

def key_value(key, value)
  if options[:old_style_hash] || RUBY_VERSION < '1.9'
    ":#{key} => #{value}"
  else
    "#{key}: #{value}"
  end
end

#module_namespacing(&block) ⇒ Object

Fill in methods that might be missing depending on the version of Rails



21
22
23
# File 'lib/generators/mini_test.rb', line 21

def module_namespacing(&block)
  yield if block_given?
end