lib/rspec/rails/api/dsl/example.rb in rspec-rails-api-0.4.0 vs lib/rspec/rails/api/dsl/example.rb in rspec-rails-api-0.5.0
- old
+ new
@@ -42,20 +42,18 @@
#
# @param entity [Symbol] Entity reference
#
# @return [RSpec::Rails::Api::EntityConfig, Hash] Defined entity
def defined(entity)
- return { type: entity.to_s.split('_').last.to_sym } if PRIMITIVES.include? entity
+ return { type: entity } if PRIMITIVES.include? entity
current_resource = rra_metadata.current_resource
raise '@current_resource is unset' unless current_resource
entities = rra_metadata.resources[current_resource][:entities]
+ raise "Unknown entity '#{entity}' in resource '#{current_resource}'" unless entities.key? entity.to_sym
- out = entities[entity]
- raise "Unknown entity '#{entity}' in resource '#{current_resource}'" unless out
-
- out.expand_with(entities)
+ entities[entity.to_sym].expand_with(entities)
end
##
# Performs various tests on the response
#