Right now I have a model function that is something like this:
Class Address
def first_line
"#{self.building_name} #{self.street_name} #{self.suburb}".squeeze(" ").strip
end
end
My address factory is define like this:
Factory.define :address do |f|
f.building_name "Alpha"
f.street_name "Bravo St"
f.suburb "Charlie"
end
There are basically two ways to write the spec, first one is:
before(:each) do
@address = Factory.build(:address)
end
@address.first_line.should == @address.building_name + " " +
@address.street_name + " " +
@address.suburb
And other way is
@address.first_line.should == "Alpha Bravo St Charlie"
Which way do you think is better? And what is the reason for supporting one against the other?