Sha256: 9ab47eba11b346224f14cbbe38c838741406a906c9b02d7e024fbbf6d9256a75
Contents?: true
Size: 1.62 KB
Versions: 6
Compression:
Stored size: 1.62 KB
Contents
require 'generators/rom/relation_generator' RSpec.describe ROM::Generators::RelationGenerator, type: :generator do destination File.expand_path('../../../../tmp', __FILE__) before(:each) do prepare_destination end specify do run_generator ['users'] default_adapter = ROM.adapters.keys.first expect(destination_root).to have_structure { directory 'app' do directory 'relations' do file 'users_relation.rb' do contains <<-CONTENT.strip_heredoc class UsersRelation < ROM::Relation[:#{default_adapter}] gateway :default schema(:users, infer: true) # define your methods here ie: # # def all # select(:id, :name).order(:id) # end end CONTENT end end end } end specify "with given adapter" do run_generator ['users', '--adapter=memory'] relation = File.read(File.join(destination_root, 'app', 'relations', 'users_relation.rb')) expect(relation).to include("class UsersRelation < ROM::Relation[:memory]") end specify "with given gateway" do run_generator ['users', '--gateway=remote'] relation = File.read(File.join(destination_root, 'app', 'relations', 'users_relation.rb')) expect(relation).to include("gateway :remote") end specify "with given registration" do run_generator ['users', '--register=profiles'] relation = File.read(File.join(destination_root, 'app', 'relations', 'users_relation.rb')) expect(relation).to match(/schema.*as: :profiles/) end end
Version data entries
6 entries across 6 versions & 1 rubygems