spec/lib/generators/relation_generator_spec.rb in rom-rails-0.3.1 vs spec/lib/generators/relation_generator_spec.rb in rom-rails-0.3.2
- old
+ new
@@ -17,12 +17,16 @@
directory 'app' do
directory 'relations' do
file 'users_relation.rb' do
contains <<-CONTENT.strip_heredoc
class UsersRelation < ROM::Relation[:#{default_adapter}]
+ # repository :default
+
dataset :users
+ register_as :users
+
# define your methods here ie:
#
# def all
# select(:id, :name).order(:id)
# end
@@ -38,6 +42,21 @@
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 repository" do
+ run_generator ['users', '--repository=remote']
+
+ relation = File.read(File.join(destination_root, 'app', 'relations', 'users_relation.rb'))
+ expect(relation).to include("repository :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 include("register_as :profiles")
+ end
+
end