Sha256: e1f14e1f029b5bbc2087cb452c4d1c6b6fcc3ad48a340240e55cf6b9cf344f7f

Contents?: true

Size: 827 Bytes

Versions: 9

Compression:

Stored size: 827 Bytes

Contents

class Spud::ControllerSpecGenerator < ::Rails::Generators::Base
  source_root File.expand_path('../templates', __FILE__)

  argument :name, type: :string
  argument :string_attribute, type: :string
  argument :editable, type: :numeric, default: 0

  def controller
    template 'controller_spec.rb.erb', "spec/controllers/#{name.downcase}_controller_spec.rb"
  end

private

  def controller_class_name
    return name.camelize + 'Controller'
  end

  def model_variable_name
    return name.split('/').last.downcase.singularize
  end

  def model_class_name
    return name.split('/').last.camelize.singularize
  end

  def model_string_attribute_name
    return string_attribute.downcase
  end

  def include_edit_actions?
    return editable == 1
  end

  def include_user_session?
    return name.match('Admin/')
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
tb_core-1.4.3.1 lib/generators/spud/controller_spec_generator.rb
tb_core-1.4.5 lib/generators/spud/controller_spec_generator.rb
tb_core-1.4.4 lib/generators/spud/controller_spec_generator.rb
tb_core-1.4.3 lib/generators/spud/controller_spec_generator.rb
tb_core-1.4.2 lib/generators/spud/controller_spec_generator.rb
tb_core-1.4.1 lib/generators/spud/controller_spec_generator.rb
tb_core-1.4.0.1 lib/generators/spud/controller_spec_generator.rb
tb_core-1.4.beta2 lib/generators/spud/controller_spec_generator.rb
tb_core-1.4.beta1 lib/generators/spud/controller_spec_generator.rb