[rspec-users] spec for model_id should eql

Sahyoun osahyoun at gmail.com
Mon Dec 3 13:33:56 EST 2007


Hello,

I'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'm just having difficulty
getting this spec to work. Any pointers would be appreciated.

Failure message:
'Address fetch and geocode should extract department and write to address
object' FAILED
expected 3, got nil (using .eql?)

This spec that is failing:
@address.department_id.should eql(3)

before:
  before do
    @address = Address.new
    @address.attributes = valid_address_attributes
    @address.save
    @department = mock_model(Department)
    @department.stub!(:find_by_code).with("75").and_return("3")
  end


The line of code I am writing the spec for:
self.department = Department.find_by_code(self.postcode[0..1])



Many thanks,
Omar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20071203/0b8e5734/attachment.html 


More information about the rspec-users mailing list