Sha256: ad237e5e6961df65b44fbc58b2a1890ba218cd0f3d5ce04620db0f7adc82298c

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 KB

Contents

require 'rom-repository'
require 'generators/rom/repository_generator'

RSpec.describe ROM::Generators::RepositoryGenerator, type: :generator do
  destination File.expand_path('../../../../tmp', __FILE__)

  before(:each) do
    prepare_destination
  end

  specify do
    run_generator ['users']

    expect(destination_root).to have_structure {
      directory 'app' do
        directory 'repositories' do
          file 'user_repository.rb' do
            contains <<-CONTENT.strip_heredoc
              class UserRepository < ROM::Repository::Root
                root :users

                commands :create, update: :by_pk, delete: :by_pk

                struct_namespace Dummy
              end
            CONTENT
          end
        end
      end
    }
  end

  specify 'when generator has a compund name' do
    run_generator ['user_profiles']

    expect(destination_root).to have_structure {
      directory 'app' do
        directory 'repositories' do
          file 'user_profile_repository.rb' do
            contains <<-CONTENT.strip_heredoc
              class UserProfileRepository < ROM::Repository::Root
                root :user_profiles

                commands :create, update: :by_pk, delete: :by_pk

                struct_namespace Dummy
              end
            CONTENT
          end
        end
      end
    }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rom-rails-1.1.1 spec/lib/generators/repository_generator_spec.rb
rom-rails-1.1.0 spec/lib/generators/repository_generator_spec.rb