Created
April 25, 2011 10:06
-
-
Save takuyan/940331 to your computer and use it in GitHub Desktop.
parent method ch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyClass | |
after_create :check_parent | |
def check_parent | |
self.parent.do_something | |
end | |
end | |
# spec | |
require 'spec_helper' | |
describe MyClass do | |
before(:each) do | |
parent = mock_model("Parent") | |
parent.stub(:do_something) | |
@my_class = MyClass.new | |
@my_class.parent = parent | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment