title: Assigning value to only certain object variables in a loop
body: <p>So I have a complicated RPG character model I'm working on as a side project. For this RPG, there are 6 basic 'ability scores' (strength, dexterity, constitution, intelligence, wisdom, charisma) that each character has. I'm specifically focusing on the tests for setting them to 0, which should be invalid (character death, etc). Here is what I have in rspec:</p>
  
  <pre><code>describe "when ability scores are 0" do
    ability_scores = %w(strength dexterity constitution
                        intelligence wisdom charisma)
    ability_scores.each do |ability_score|
      @character.ability_score = 0
      expect(@character).to be_invalid
    end
  end
  </code></pre>
  
  <p>I have a factory at the beginning of the file creating a perfectly valid character and set <code>subject { @character }</code></p>
  
  <p>I would <em>think</em> that it would see the <code>ability_score</code> and think to insert its value before evaluating against the character object, but that doesn't seem to be the case.</p>
  
  <p>Switching out <code>@character.send(:"#{ability_score}=", 0)</code> for <code>@character.ability_score = 0</code> results in a <code>NoMethodError: undefined method 'strength=' for nil:NilClass</code></p>
  
  <p>However, separate <code>describe</code> blocks work fine:</p>
  
  <pre><code>describe "when strength is 0" do
    before { @character.strength = 0 }
    it { should_not be_valid }
  end
  </code></pre>
  
  <p>but having 6 of these is a cluttering mess.</p>
  
  <p>Any ideas?</p>