[rspec-users] Best way to match several attributes of an object?

George george.jquery at SoftwareUnity.com
Tue Mar 30 10:23:59 EDT 2010

When you need to check several properties of an object, what is the
best way to match them all?

I'm using the 'satisfy' matcher at the moment but perhaps there's a
better way than this:
      flight.should satisfy { |f|
        f.booking_code            == @parsed_pnr_data[:pnr_number] &&
        f.depart_airport.code     == @parsed_pnr_data[:flights][0]
[:depart_airport_code] &&
        f.arrive_airport.code     == @parsed_pnr_data[:flights][0]
[:arrive_airport_code] &&
        f.depart_terminal         == @parsed_pnr_data[:flights][0]
[:depart_terminal] &&
        f.arrive_terminal         == @parsed_pnr_data[:flights][0]
[:arrive_terminal] &&
        f.start_date              == @parsed_pnr_data[:flights][0]
[:depart_date] &&
        f.end_date                == @parsed_pnr_data[:flights][0]

Many thanks

More information about the rspec-users mailing list