Sha256: a3b305e193021c74dd4e0a6b0b9f726dc7d49e80299bb0a12ab2f54127833c9a

Contents?: true

Size: 1.44 KB

Versions: 43

Compression:

Stored size: 1.44 KB

Contents

require 'rails_helper'

require 'generators/pg_rspec/scaffold/scaffold_generator'
require 'generators/pg_decorator/pg_decorator_generator'
require 'generators/pg_active_record/model/model_generator'

DESTINATION_PATH = File.expand_path('./../../tmp/generator_testing', __dir__)

describe 'Generators', type: :generator do
  describe 'PgDecoratorGenerator' do
    destination DESTINATION_PATH
    tests PgDecoratorGenerator

    before { prepare_destination }

    it do
      run_generator(['Frontend/Modelo', 'bla:integer'])

      my_assert_file 'app/decorators/modelo_decorator.rb' do |content|
        assert_match(/delegate_all/, content)
      end
    end
  end

  describe 'ScaffoldGenerator' do
    destination DESTINATION_PATH
    tests PgRspec::Generators::ScaffoldGenerator

    before { prepare_destination }

    it do
      run_generator(['Frontend/Modelo', 'bla:integer'])

      my_assert_file 'spec/controllers/frontend/modelos_controller_spec.rb' do |content|
        assert_match(/routing/, content)
        assert_match(/sign_in/, content)
      end
    end
  end

  describe PgActiveRecord::ModelGenerator do
    destination DESTINATION_PATH
    tests described_class

    before { prepare_destination }

    it do
      run_generator(['Frontend/Modelo', 'bla:integer', 'cosa:references', '--activeadmin'])

      my_assert_file 'app/admin/modelos.rb' do |content|
        assert_match(/permit_params.*cosa_id/, content)
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
pg_rails-7.0.8.pre.alpha.56 pg_scaffold/spec/generators_spec.rb
pg_rails-7.0.8.pre.alpha.55 pg_scaffold/spec/generators_spec.rb
pg_rails-7.0.8.pre.alpha.54 pg_scaffold/spec/generators_spec.rb
pg_rails-7.0.8.pre.alpha.53 pg_scaffold/spec/generators_spec.rb
pg_rails-7.0.8.pre.alpha.52 pg_scaffold/spec/generators_spec.rb
pg_rails-7.0.8.pre.alpha.51 pg_scaffold/spec/generators_spec.rb
pg_rails-7.0.8.pre.alpha.50 pg_scaffold/spec/generators_spec.rb
pg_rails-7.0.8.pre.alpha.49 pg_scaffold/spec/generators_spec.rb
pg_rails-7.0.8.pre.alpha.48 pg_scaffold/spec/generators_spec.rb
pg_rails-7.0.8.pre.alpha.47 pg_scaffold/spec/generators_spec.rb
pg_rails-7.0.8.pre.alpha.46 pg_scaffold/spec/generators_spec.rb
pg_rails-7.0.8.pre.alpha.45 pg_scaffold/spec/generators_spec.rb
pg_rails-7.0.8.pre.alpha.44 pg_scaffold/spec/generators_spec.rb
pg_rails-7.0.8.pre.alpha.43 pg_scaffold/spec/generators_spec.rb
pg_rails-7.0.8.pre.alpha.42 pg_scaffold/spec/generators_spec.rb
pg_rails-7.0.8.pre.alpha.41 pg_scaffold/spec/generators_spec.rb
pg_rails-7.0.8.pre.alpha.40 pg_scaffold/spec/generators_spec.rb
pg_rails-7.0.8.pre.alpha.39 pg_scaffold/spec/generators_spec.rb
pg_rails-7.0.8.pre.alpha.38 pg_scaffold/spec/generators_spec.rb
pg_rails-7.0.8.pre.alpha.37 pg_scaffold/spec/generators_spec.rb