Sha256: 1bb3c395d75cf47a033e4cd6183a6c2c779aaaefa7827fc444d47a121cc51008

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

# frozen_string_literal: true

require 'test_helper'
require 'rails/generators/test_case'
require 'generators/upgrow/input/input_generator'

module Upgrow
  module Generators
    class InputGeneratorTest < Rails::Generators::TestCase
      tests InputGenerator
      destination File.expand_path('tmp')
      setup :prepare_destination

      test 'generate Input file' do
        run_generator(['article'])

        assert_file 'app/inputs/article_input.rb', <<~RUBY
          # frozen_string_literal: true

          class ArticleInput < ApplicationInput
          end
        RUBY
      end

      test 'generate Input when suffix is specified' do
        run_generator(['ArticleInput'])

        assert_file 'app/inputs/article_input.rb', <<~RUBY
          # frozen_string_literal: true

          class ArticleInput < ApplicationInput
          end
        RUBY
      end

      test 'generate namespaced Input file' do
        run_generator(['articles/article'])

        assert_file 'app/inputs/articles/article_input.rb', <<~RUBY
          # frozen_string_literal: true

          module Articles
            class ArticleInput < ApplicationInput
            end
          end
        RUBY
      end

      test 'generate namespaced Input file with many layers' do
        run_generator(['users/articles/article'])

        assert_file 'app/inputs/users/articles/article_input.rb', <<~RUBY
          # frozen_string_literal: true

          module Users
            module Articles
              class ArticleInput < ApplicationInput
              end
            end
          end
        RUBY
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
upgrow-0.0.5 test/upgrow/generators/input_generator_test.rb