Sha256: fc308bdc87da9d4e14e9dd7452717baec27845c5c5704a5d14d504cdd49018b1

Contents?: true

Size: 1.26 KB

Versions: 6

Compression:

Stored size: 1.26 KB

Contents

require 'generators/rom/mapper_generator'

RSpec.describe ROM::Generators::MapperGenerator do
  destination File.expand_path('../../../tmp', __dir__)

  before(:all) do
    prepare_destination
    run_generator ['users']
    run_generator ['app_user']
  end

  specify do
    expect(destination_root).to have_structure {
      directory 'app' do
        directory 'mappers' do
          file 'user_mapper.rb' do
            contains <<-CONTENT.strip_heredoc
              class UserMapper < ROM::Mapper
                relation :users

                register_as :user

                # specify model and attributes ie
                #
                # model User
                #
                # attribute :name
                # attribute :email
              end
            CONTENT
          end

          file 'app_user_mapper.rb' do
            contains <<-CONTENT.strip_heredoc
              class AppUserMapper < ROM::Mapper
                relation :app_users

                register_as :app_user

                # specify model and attributes ie
                #
                # model AppUser
                #
                # attribute :name
                # attribute :email
              end
            CONTENT
          end
        end
      end
    }
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rom-rails-2.4.0 spec/lib/generators/mapper_generator_spec.rb
rom-rails-2.3.1 spec/lib/generators/mapper_generator_spec.rb
rom-rails-2.3.0 spec/lib/generators/mapper_generator_spec.rb
rom-rails-2.2.0 spec/lib/generators/mapper_generator_spec.rb
rom-rails-2.0.0 spec/lib/generators/mapper_generator_spec.rb
rom-rails-1.2.0 spec/lib/generators/mapper_generator_spec.rb