[rspec-users] specing class methods
Scott Taylor
mailing_lists at railsnewbie.com
Thu Apr 12 18:53:26 EDT 2007
Here is an example from autotest:
class Autotest
def self.run
new.run
end
def new
...
end
def run
...
end
...
end
How would I spec out Autotest.run?
Two complications come to my mind:
1. How do I spec out class methods? (please point me to docs, if
any. I can only find class level specing on "partial mocks" (of
rails class objects)
2. How can I tell that new.run has been called, without saying
should_receive(:new) and should_receive(:run) in separate specs?
Another complication:
How would I spec out the (instance level) run method, which has an
infinite loop?
def run
hook :run
reset
add_sigint_handler
loop do # ^c handler
#...stuff...
end
hook :quit
end
Thanks for all of your help,
Scott Taylor
PS: Sorry for my previous non-sensical emails. I was being stupid.
More information about the rspec-users
mailing list