coverage for methods called via method_missing

11 views
Skip to first unread message

benth...@gmail.com

unread,
Dec 11, 2015, 12:29:22 PM12/11/15
to SimpleCov
This is going to seem like an odd question but I was wondering if anyone has come across something to do "coverage" over methods that have no code in an rb file but are handled by some method_missing method.

The reason I want something like this is I have a library we wrote for a REST framework. It has some client and then the actual methods get called via a method_missing on some base class. For example

class BaseService
def initialize
@client = FooRestFramework::Client.new
end

def method_missing(name, *args, &block)
@client.send(name, *args, &block)
end
end

class BarService < BaseService
end

then say there's some rspec or whatever

describe BarService do
describe '#do_rest_thing' do
it 'has the correct result or whatever' do
expect(subject.do_rest_thing).to eq 5
end
end
end

and that #do_rest_thing method actually is the #method_missing and eventually calls some HTTP method on some REST service somewhere

I can't think of a way with simplecov to know which methods I called since those methods don't really exist.

Any thoughts?

- Ben

Reply all
Reply to author
Forward
0 new messages