lib/rspec-virtus/matcher.rb in rspec-virtus-0.0.1 vs lib/rspec-virtus/matcher.rb in rspec-virtus-0.1.0

- old
+ new

@@ -4,12 +4,13 @@ def initialize(attribute_name) @attribute_name = attribute_name @options = {} end - def of_type(type) + def of_type(type, options={}) @options[:type] = type + @options[:member_type] = options.delete(:member_type) self end def matches?(subject) @subject = subject @@ -28,19 +29,25 @@ def attribute @subject.attribute_set[@attribute_name] end + def member_type + attribute.options[:member_type] + end + def attribute_type attribute.options[:primitive] end def attribute_exists? attribute != nil end def type_correct? - if @options[:type] + if @options[:member_type] + member_type == @options[:member_type] && attribute_type == @options[:type] + elsif @options[:type] attribute_type == @options[:type] else true end end