Yep, that's a fair point and may improve readability if I set up the compare object in a before method. Good idea, thanks David. George
On Mar 30, 5:43 pm, David Chelimsky <dchelim...@gmail.com> wrote: > On Mar 30, 2010, at 9:23 AM, George wrote: > > > > > 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] > > [:arrive_date] > > } > > I don't know if this is workable in your case or not, but I like to design > objects so you can compare them. Something like: > > flight.should == Flight.new :booking_code => @parsed_pnr_data[:pnr_number], > ..... > > HTH, > David > _______________________________________________ > rspec-users mailing list > rspec-us...@rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users