Sha256: b3c2d90569a512c467ac11690361d9c4093e1e529cc1038f38f9de7b5ba91d6f
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 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]) object = klass.new(name: 'Jane') expect(object.name).to eql('Jane') expect { object.name = 'Jane' }.to raise_error(NoMethodError) klass = builder.call([:name, :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 context 'when :name option is present' do it 'defines a constant for the model' do builder = ROM::ModelBuilder::PORO.new(name: 'User') builder.call([:name, :email]) expect(Object.const_defined?(:User)).to be(true) end it 'defines a constant within a namespace for the model' do module MyApp; module Entities; end; end builder = ROM::ModelBuilder::PORO.new(name: 'MyApp::Entities::User') builder.call([:name, :email]) expect(MyApp::Entities.const_defined?(:User)).to be(true) expect(Object.const_defined?(:User)).to be(false) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rom-0.5.0 | spec/unit/rom/model_builder_spec.rb |