Class: Bogus::FakesClasses

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

Instance Method Summary collapse

Methods included from Takes

takes

Instance Method Details

#fake(klass, opts = {}) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/bogus/fakes/fakes_classes.rb', line 7

def fake(klass, opts = {})
  opts = opts.merge(as: :class)
  name = opts.delete(:fake_name) || underscore(klass.name.split('::').last).to_sym
  fake = creates_fakes_with_stubbed_methods.create(name, opts) { klass }
  overwrites_classes.overwrite(klass.name, fake)
  overwritten_classes.add(klass.name, klass)
end