# Rspec + Callbacks Classes

**URL:** <https://www.ruby-forum.com/t/rspec-callbacks-classes/192386>\
**Category:** Rails\
**Created:** [July 29, 2010, 2:36pm UTC](https://www.ruby-forum.com/t/rspec-callbacks-classes/192386 "2010-07-29T14:36:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhishek\_shukla](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/7cd45c/32.png) [@Abhishek\_shukla](https://www.ruby-forum.com/u/Abhishek_shukla)\
**Post date:** [July 29, 2010, 2:36pm UTC](https://www.ruby-forum.com/t/rspec-callbacks-classes/192386/1 "2010-07-29T14:36:02Z")

</div>

Hello Friends,  
I am using rspec for testing my model, and I have used callbacks in my  
model  
as things are working as expected on the front end. but when I try to  
test  
the application it throws an error.

My code.

- 
- 

class MyModel \< ActiveRecord::Base  
after\_create CreateProfileCallBacks  
end

* * *

class CreateProfileCallBacks  
def self.after\_create(args)  
my\_code  
end  
end

And when I run the spec getting the following error.  
_Callbacks must be a symbol denoting the method to call, a string to be  
evaluated, a block to be invoked, or an object responding to the  
callback  
method._

And I already Googled it But no success, it will be really helpful if I  
get  
any Clue on the above mentioned error.

–  
Thanks  
Abhis

---

<div class="post-metadata">

**Author:** ![Abhishek\_shukla](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/7cd45c/32.png) [@Abhishek\_shukla](https://www.ruby-forum.com/u/Abhishek_shukla)\
**Post date:** [July 30, 2010, 7:29am UTC](https://www.ruby-forum.com/t/rspec-callbacks-classes/192386/2 "2010-07-30T07:29:20Z")

</div>

Friends any clue still struggling. ☹

---

<div class="post-metadata">

**Author:** ![Abhishek\_shukla](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/7cd45c/32.png) [@Abhishek\_shukla](https://www.ruby-forum.com/u/Abhishek_shukla)\
**Post date:** [July 30, 2010, 7:43am UTC](https://www.ruby-forum.com/t/rspec-callbacks-classes/192386/3 "2010-07-30T07:43:23Z")

</div>

anObjectNotAmethodStringOrBlock=CreateProfileCallBacks.new

---

<div class="post-metadata">

**Author:** ![Abhishek\_shukla](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/7cd45c/32.png) [@Abhishek\_shukla](https://www.ruby-forum.com/u/Abhishek_shukla)\
**Post date:** [July 30, 2010, 10:26am UTC](https://www.ruby-forum.com/t/rspec-callbacks-classes/192386/4 "2010-07-30T10:26:08Z")

</div>

Hey Abhi, I think you try evaluating the code directly as a string,  
eg: before\_destroy ‘self.class.delete\_all “parent\_id = #{id}”’

Hope this helps.

Aashish
