Sha256: 94ef3ffac160380c0bdaef7a4f784c73b79d781e627d673a6b60a0e33f446dd9
Contents?: true
Size: 1.7 KB
Versions: 2
Compression:
Stored size: 1.7 KB
Contents
require 'spec_helper' require_relative './support/bare_object' describe BareObject do let(:obj) { BareObject } context 'including FormalWear' do before { obj.send(:include, FormalWear) } context 'when required_attr is invoked' do before do obj.class_eval do required_attr dynamic_id: { name: "Test", type: :text, source: ->(s) { nil }, } end end it 'sets a class variable called @@required_fields' do obj.class_variable_defined?(:@@required_fields).should be_true end it 'adds the given field to @@required_fields' do obj.class_variable_get(:@@required_fields).keys.should include(:dynamic_id) end it 'adds a reader for the field' do obj.method_defined?(:dynamic_id).should be_true end it 'adds a writer for the field' do obj.method_defined?(:dynamic_id=).should be_true end end context 'when optional_attr is invoked' do before do obj.class_eval do optional_attr optional_id: { name: "Test", type: :text, source: ->(s) { nil }, } end end it 'sets a class variable called @@optional_attr' do obj.class_variable_defined?(:@@optional_fields).should be_true end it 'adds the given field to @@optional_attr' do obj.class_variable_get(:@@optional_fields).keys.should include(:optional_id) end it 'adds a reader for the field' do obj.method_defined?(:optional_id).should be_true end it 'adds a writer for the field' do obj.method_defined?(:optional_id=).should be_true end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
formal_wear-1.0.0 | spec/bare_object_spec.rb |
formal_wear-0.3.0 | spec/bare_object_spec.rb |