Class: Bogus::CreatesFakesWithStubbedMethods

Inherits:
Object
  • Object
show all
Extended by:
Takes
Defined in:
lib/bogus/fakes/creates_fakes_with_stubbed_methods.rb

Instance Method Summary collapse

Methods included from Takes

takes

Instance Method Details

#create(name = nil, methods = {}, &block) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/bogus/fakes/creates_fakes_with_stubbed_methods.rb', line 8

def create(name = nil, methods = {}, &block)
  if name.is_a?(Hash)
    methods = name
    name = nil
  end

  fake = responds_to_everything unless name

  fake_opts, methods = split_methods(methods)
  fake_definition = get_configuration(name, fake_opts, methods, block)

  fake ||= creates_fakes.create(fake_definition.name, fake_definition.opts,
                                &fake_definition.class_block)

  multi_stubber.stub_all(fake, fake_definition.stubs)
end