Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe Letter do
- before(:each) do
- @john = mock("John")
- @john.stub!(:id).and_return(5)
- @john.stub!(:class).and_return(Person) # is this ok?
- @john.stub!(:name).and_return("John F.")
- Person.stub!(:find).and_return(@john)
- end
- it.should "have a valid #to field" do
- letter = Letter.create!(:to=>@john, :content => "Hello John")
- letter.to_type.should == @john.class.name
- letter.to_id.should == @john.id
- end
- [...]
- end
- class Letter < ActiveRecord::Base
- belongs_to :to, :polymorphic => true
- [...]
- end
- before(:each) do
- @john = mock_model(Person, :name => "John F.")
- Person.stub!(:find).and_return(@john)
- end
- describe Letter
- should_belong_to :to, :polymorphic => true
- end
Add Comment
Please, Sign In to add comment