mirror of
https://github.com/thoughtbot/shoulda-matchers.git
synced 2022-11-09 12:01:38 -05:00
35 lines
710 B
Ruby
35 lines
710 B
Ruby
module Shoulda
|
|
module Matchers
|
|
module Doublespeak
|
|
# @private
|
|
class StubImplementation
|
|
DoubleImplementationRegistry.register(self, :stub)
|
|
|
|
def self.create
|
|
new
|
|
end
|
|
|
|
def initialize
|
|
@implementation = proc { nil }
|
|
end
|
|
|
|
def returns(value = nil, &block)
|
|
if block
|
|
@implementation = block
|
|
else
|
|
@implementation = proc { value }
|
|
end
|
|
end
|
|
|
|
def call(double, object, args, block)
|
|
double.record_call(args, block)
|
|
implementation.call(object, args, block)
|
|
end
|
|
|
|
protected
|
|
|
|
attr_reader :implementation
|
|
end
|
|
end
|
|
end
|
|
end
|