Sha256: f4554e882a1f6634dde3c0d5367f5914c06ef9851bfc29b1502ccfb48fd4a786

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

require 'test_helper'
require 'rails/generators/test_case'
require 'generators/upgrow/action/action_generator'

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

      test 'generate Action file' do
        run_generator(['index'])

        assert_file 'app/actions/index_action.rb', <<~RUBY
          # frozen_string_literal: true

          class IndexAction < ApplicationAction
            def perform(*args)
              # Do something here.
            end
          end
        RUBY
      end

      test 'generate Action when suffix is specified' do
        run_generator(['IndexAction'])

        assert_file 'app/actions/index_action.rb', <<~RUBY
          # frozen_string_literal: true

          class IndexAction < ApplicationAction
            def perform(*args)
              # Do something here.
            end
          end
        RUBY
      end

      test 'generate namespaced Action file' do
        run_generator(['articles/index'])

        assert_file 'app/actions/articles/index_action.rb', <<~RUBY
          # frozen_string_literal: true

          module Articles
            class IndexAction < ApplicationAction
              def perform(*args)
                # Do something here.
              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/action_generator_test.rb