I have a Premise model with lots of validations and somewhat complex
callbacks. I've already written tests for those (and they pass).
I also have a MeteredService model for which premise :has_many
metered_services and (of course) metered_service :belongs_to premise.
Testing MeteredService doesn't require a real Premise -- all it needs is
a premise_id -- so for my MeteredService tests I tried a simple mock
like:
premise = double("premise", :id => 1)
But this fails with:
Failure/Error: MeteredService.create(:premise => @premise)
ActiveRecord::AssociationTypeMismatch:
Premise(#2202729700) expected, got RSpec::Mocks::Mock(#2154067120)
I *really* don't want to create a real Premise object unless there's a
way to inhibit all the validations and callbacks. (FWIW, I use
FactoryGirl for other test, but it evidently triggers validations and
callbacks just like an ordinary .create())
What are my options?
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users