I have updated rspec from 2.9 to 3.5. After the update test cases are 
failing where I stub the some method and expect presence on another method.

*User.rb*
class User
include Mongoid::Document
field :name, type: String

class << self
def test_method
rv = validate_something("test")
return rv if rv[:error]

user = User.new
user.name = "test#{rand(1..1000000)}"
user.save!
user.invoke_additional_tasks('test_method')

return { success: true, user: user }
end
end

def invoke_additional_tasks(test)
{ success: true }
end

private

class << self
def validate_something(params)
{ success: true }
end
end
end

*user_spec.rb*
require 'rails_helper'

RSpec.describe User, type: :model do
describe 'test_method' do
context 'when validate_something returns success' do
before(:each) do
allow(User).to receive(:validate_something).and_return(success: true)
end

it 'should invoke_additional_tasks on user' do
expect_any_instance_of(User).to 
receive(:invoke_additional_tasks).with('test_method')
User.test_method
end
end
end
end


I am getting the following error
Failure/Error: expect_any_instance_of(User).to 
receive(:invoke_additional_tasks).with('test_method')
       User does not implement: invoke_additional_tasks

Am I doing anything wrong here or it's a bug in rspec?

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rspec+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/80adafc2-cbc0-4399-833a-0911325ca0cen%40googlegroups.com.

Reply via email to