Antarr Byrd
Antarr Byrd

Reputation: 26071

How to stub method that doesn't belong to class in RSpec?

I'm working a project that uses a notify method that does does not belong to a method. I want to stub this method to help speed up my spec and keep my log clean. How can i do this?

lib/notify.rb

require 'json'
require 'rest-client'

def notify(*params)
  ...
end

Upvotes: 0

Views: 1046

Answers (1)

infused
infused

Reputation: 24337

Use a before block in your specs to stub the :notify method on subject:

before do
  allow(subject).to receive(:notify)
end

Upvotes: 1

Related Questions