Class: Makit::Cli::Generators::Templates::Ruby::Test

Inherits:
Object
  • Object
show all
Defined in:
lib/makit/cli/generators/templates/ruby/test.rb

Overview

Template for Ruby gem test file

Instance Method Summary collapse

Constructor Details

#initialize(project_name) ⇒ Test

Returns a new instance of Test.



10
11
12
13
14
# File 'lib/makit/cli/generators/templates/ruby/test.rb', line 10

def initialize(project_name)
  @project_name = project_name
  @module_name = project_name.split(/[-_]/).map(&:capitalize).join
  @test_class_name = "#{@module_name}Test"
end

Instance Method Details

#renderObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/makit/cli/generators/templates/ruby/test.rb', line 16

def render
  <<~RUBY
    # frozen_string_literal: true

    require "test_helper"

    class #{@test_class_name} < Minitest::Test
      def test_that_it_has_a_version_number
        refute_nil ::#{@module_name}::VERSION
      end

      def test_it_does_something_useful
        # TODO: Write your first test
        assert false, "Write a real test"
      end
    end
  RUBY
end