Hi, This is probably straightforward to solve. I'm new to rspec so I hope you'll be patient with me. I've created a model method which works in practice, but which rspec is not passing. I'm obviously not going about things in the right way in rspec so I'd appreciate any advice offered.
Here's the (releveant parts of the) method which sets up a one to many relationship between Company and Projects. def.self create_project(record) parent_company = Company.find_by_basecampid(record.company.id) project = self.find_or_initialize_by_basecampid(record.id) project.company_id = parent_company.id end In rspec I've got this: def parent_company_attributes { :id => 1, :basecampid => 448718, :name => "The Media Collective" } end before do mock_record Company.should_receive(:find_by_basecampid). with(parent_company_attributes[:basecampid]). and_return(parent_company_attributes) @project = Project.create_project(record) end it "should populate company_id" do @project.company_id.should eql(parent_company_attributes[:id]) end The problem is that it looks like rspec is using the object id rather than the id from parent_company_attributes. Here's the failure message: 1) 'Project.create project record should populate company_id' FAILED expected 1, got 8817400 (using .eql?) Thanks for any insights David Currin _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users