class SpecProducer::Producers::SerializersProducer
Constants
- CLASSES_TO_IGNORE
TODO Rethink this
Public Instance Methods
call(resource)
click to toggle source
# File lib/spec_producer/producers/serializers_producer.rb, line 17 def call(resource) builder.context('should include the expected attribute keys') do builder.subject(builder.initialize_serializer_for_object resource.obj) builder.it("expect(subject.attributes.keys).to contain_exactly(#{resource.obj._attributes.map { |x| ":#{x.to_s}" }.join(', ')})") end builder.context('to_json should have the proper values') do builder.subject(builder.json_parse_for_serialized_object resource.obj) resource.obj._attributes.each do |attribute| builder.it("expect(subject['#{attribute}']).to eq('')") end end end
resources()
click to toggle source
# File lib/spec_producer/producers/serializers_producer.rb, line 11 def resources ActiveModel::Serializer.descendants.reject do |descendant| should_ignore?(descendant) end.map { |desc| Resource.new(desc, desc.name, 'serializer') } end
Private Instance Methods
require_helper_string()
click to toggle source
# File lib/spec_producer/producers/serializers_producer.rb, line 41 def require_helper_string @require_helper_string ||= Utils::FileUtils.collect_helper_strings end
should_ignore?(descendant)
click to toggle source
# File lib/spec_producer/producers/serializers_producer.rb, line 37 def should_ignore?(descendant) CLASSES_TO_IGNORE.include?(descendant.to_s) end