Created
May 3, 2016 06:42
-
-
Save evmorov/6b52582ebd3fab7f6cdbc6c1cd697f23 to your computer and use it in GitHub Desktop.
For the article at medium.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Student | |
include HappyMapper | |
tag 'student' | |
has_one :name, String | |
has_one :school_id, String, tag: 'schoolId' | |
end | |
class School | |
include HappyMapper | |
tag 'school' | |
has_one :id, String | |
has_one :name, String | |
end | |
let(:schools) { School.parse(xml) } | |
let(:students) { Student.parse(xml) } | |
it do | |
school_id = schools.find { |school| school.name == 'Second school' }.id | |
student_names = students.select { |student| student.school_id == school_id }.map(&:name) | |
expect(student_names).to match(%w(Alex Olivia)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment