Class: Hanami::Minitest::Generators::Slice Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/minitest/generators/slice.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0

Instance Method Summary collapse

Constructor Details

#initialize(fs:, inflector:) ⇒ Slice

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Slice.

Since:

  • 2.0.0



13
14
15
16
# File 'lib/hanami/minitest/generators/slice.rb', line 13

def initialize(fs:, inflector:)
  @fs = fs
  @inflector = inflector
end

Instance Method Details

#call(slice) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/hanami/minitest/generators/slice.rb', line 20

def call(slice)
  camelized_slice_name = inflector.camelize(slice)

  fs.write(
    "test/slices/#{slice}/action_test.rb",
    Hanami::CLI::RubyFileGenerator.class(
      "ActionTest",
      parent_class_name: "Hanami::Minitest::Test",
      modules: [camelized_slice_name],
      header: ["# frozen_string_literal: true", "", 'require "test_helper"'],
      body: [
        "test \"pending\" do",
        "  skip \"Add tests for #{camelized_slice_name} actions\"",
        "end"
      ]
    )
  )

  fs.write("test/slices/#{slice}/actions/.keep", "")
end