Sha256: a49facdb08a2b725da0b91165df797a571ac20d8ba715fd47f70a9b68da7767b

Contents?: true

Size: 603 Bytes

Versions: 12

Compression:

Stored size: 603 Bytes

Contents

module Bogus
  class FakesClasses
    extend Takes

    takes :creates_fakes_with_stubbed_methods, :overwrites_classes, :overwritten_classes

    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

    private

    def underscore(str)
      str.gsub(/[A-Z]/) { |s| "_" + s.downcase }.gsub(/^_/, '')
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
bogus-0.1.7 lib/bogus/fakes/fakes_classes.rb
bogus-0.1.6 lib/bogus/fakes/fakes_classes.rb
bogus-0.1.5 lib/bogus/fakes/fakes_classes.rb
bogus-0.1.4 lib/bogus/fakes/fakes_classes.rb
bogus-0.1.3 lib/bogus/fakes_classes.rb
bogus-0.1.2 lib/bogus/fakes_classes.rb
bogus-0.1.1 lib/bogus/fakes_classes.rb
bogus-0.1.0 lib/bogus/fakes_classes.rb
bogus-0.0.4 lib/bogus/fakes_classes.rb
bogus-0.0.3 lib/bogus/fakes_classes.rb
bogus-0.0.3.rc.2 lib/bogus/fakes_classes.rb
bogus-0.0.3.rc.1 lib/bogus/fakes_classes.rb