Cant solve error: #<Double (anonymous)> received unexpected message :[]= with (:rule_code, 1)
<p>Im a struggling to solve the above error i get when testing the following:</p>

<pre><code>def add_rule_code new_rule
  count = list[:multiple_item_rules].count + list[:total_price_rules].count + 1
  new_rule[:rule_code] = count
end
</code></pre>

<p>with the following test:</p>

<pre><code>  it "adds a unique rule code" do
    item_rule = double( {rule_type: "item", item_code: 001, number_of_items: 2, new_item_price: 8.50} )
    rules.add_rule_code item_rule
    expect(rules.list[:multiple_item_rules][:rule_code]).to eq 1
  end
</code></pre>

<p>I get the following error message:</p>

<pre><code>1) Promotional_Rules New rules adds a unique rule code
   Failure/Error: new_rule[:rule_code] = count
     #&lt;Double (anonymous)&gt; received unexpected message :[]= with (:rule_code, 1)
   # ./lib/Promotional_Rules.rb:21:in `add_rule_code'
   # ./spec/promotional_rules_spec.rb:27:in `block (3 levels) in &lt;top (required)&gt;'
</code></pre>

<p>I sure its a simple fix but i cant figure it out despite googling etc. Any help would be great.</p>

<p>Thanks</p>