Sha256: 1e295e1fa900f01ad0f29193c46745cd00fae044ecd2dd01bb9825890052a479
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
require 'spec_helper' describe ROM::ModelBuilder do describe '#call' do it 'builds a class with a constructor accepting attributes' do builder = ROM::ModelBuilder::PORO.new klass = builder.call(name: :user_name) object = klass.new(name: 'Jane') expect(object.name).to eql('Jane') expect { object.name = 'Jane' }.to raise_error(NoMethodError) klass = builder.call(name: :user_name, email: :user_email) object = klass.new(name: 'Jane', email: 'jane@doe.org') expect(object.name).to eql('Jane') expect(object.email).to eql('jane@doe.org') end it 'defines a constant for the model when :name option is present' do builder = ROM::ModelBuilder::PORO.new(name: 'User') builder.call(name: :user_name, email: :user_email) expect(Object.const_defined?(:User)).to be(true) end it 'defines a constant within a namespace for the model when :name option is present' do module MyApp; module Entities; end; end builder = ROM::ModelBuilder::PORO.new(name: 'MyApp::Entities::User') builder.call(name: :user_name, email: :user_email) expect(MyApp::Entities.const_defined?(:User)).to be(true) expect(Object.const_defined?(:User)).to be(false) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rom-0.4.2 | spec/unit/rom/model_builder_spec.rb |