Hello,<br><br>I&#39;m confused why the spec described below is failing. Other simple comparison specs are passing fine for the same model. The code is working accordingly when I test it through the console, I&#39;m just having difficulty getting this spec to work. Any pointers would be appreciated.
<br><br>Failure message:<br>&#39;Address fetch and geocode should extract department and write to address object&#39; FAILED<br>expected 3, got nil (using .eql?)<br><br>This spec that is failing:<br>@address.department_id.should
 eql(3)<br><br>before:<br>&nbsp; before do <br>&nbsp;&nbsp;&nbsp; @address = Address.new&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; @address.attributes = valid_address_attributes&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; @address.save&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; @department = mock_model(Department)<br>&nbsp;&nbsp;&nbsp; @department.stub!
(:find_by_code).with(&quot;75&quot;).and_return(&quot;3&quot;)<br>&nbsp; end<br><br><br>The line of code I am writing the spec for:<br>self.department = Department.find_by_code(self.postcode[0..1]) <br><br><br><br>Many thanks,
<br>Omar<br>