« Return to Thread: spec'ing calls to super (or other Ruby keywords)

spec'ing calls to super (or other Ruby keywords)

by Matt McNeil :: Rate this Message:

Reply to Author | View in Thread

Hi there,

How does one spec an invocation of a Ruby keyword, such as super in this case?

class User < ActiveResource::Base
  # faking the ActiveRecord before/after_save observers
  def save
    super
    UserMailer.deliver_activation(self) if recently_activated?
  end
end

Does the solution look anything like the following?

describe User do
  describe '#save' do
    it "should call save on the parent class" do
      # something.should_receive(:something)
      @user.save
    end
  end
end

Any thoughts?

Thanks much,
Matt

 « Return to Thread: spec'ing calls to super (or other Ruby keywords)