I agree with apneadiving your object Passage
knows too much about Phrase
. However, since you asked specifically about the given example, you can do it by setting up the object state:
it "blanks any phrases with few enough hitpoints"
low_hp = 3.times.map{ create :phrase, hp: 1 } # Or however you create them
high_hp = 2.times.map{ create :phrase, hp: 1_000_000 }
passage.phrases = low_hp + high_hp # Or however you can set this state
passage.receives_damage
expect(low_hp.map(&:content)).to match_array [".", ".", "."]
end
I would probably suggest writing a better custom matcher for the end. That way you could properly say something better such as:
expect{passage.receive_damage}.to blank_phrases low_hp