spec/spec_helper.rb in databound-0.0.3 vs spec/spec_helper.rb in databound-0.1.0

- old
+ new

@@ -17,11 +17,11 @@ obj[key] = JSON.dump(val) end end def rubize(response) - optionize(JSON.parse(response.body)) + convert_scoped_records(optionize(JSON.parse(response.body))) end def optionize(obj) case obj when Array @@ -29,8 +29,24 @@ else obj.to_options end end +def convert_scoped_records(obj) + return obj unless obj.is_a?(Hash) + result = obj + + converted = obj[:scoped_records].map do |record| + record.except('created_at', 'updated_at') + end + + result[:scoped_records] = converted + result +end + def gather(attribute, response) rubize(response).map { |record| record[attribute] } +end + +def all_records + User.select(:id, :name, :city).map(&:attributes) end