Sha256: fe52d20a6b1213fcb08da9f99ec1e9f01db804d3de8ca1a1c38789d262625819

Contents?: true

Size: 1.64 KB

Versions: 3

Compression:

Stored size: 1.64 KB

Contents

module Bogus
  module PublicMethods
    def record_calls_for(name, klass = nil)
      inject.adds_recording.add(name, klass)
    end

    def verify_contract!(fake_name)
      inject.verifies_contracts.verify(fake_name)
    end

    def configure(&block)
      config.tap(&block)
    end

    def config
      inject.configuration
    end

    def reset!
      clear
      @injector = Bogus::Injector.new
    end

    def create_stub(*args)
      inject.create_stub(*args)
    end

    def create_mock(*args)
      inject.create_mock(*args)
    end

    def make_duck(*args)
      inject.makes_ducks.make(*args)
    end

    def have_received(*args)
      inject.have_received_matcher.build(*args)
    end

    def fake_for(*args, &block)
      inject.creates_fakes_with_stubbed_methods.create(*args, &block)
    end

    def fake_class(*args)
      inject.fakes_classes.fake(*args)
    end

    def after_each_test
      ensure_all_expectations_satisfied!
    ensure
      clear
    end

    def clear
      reset_stubbed_methods
      clear_expectations
      reset_overwritten_classes
    end

    def ensure_all_expectations_satisfied!
      doubles = inject.double_tracker.doubles
      inject.ensures_all_interactions_satisfied.ensure_satisfied!(doubles)
    end

    def clear_expectations
      inject.clear_tracked_doubles
    end

    def reset_stubbed_methods
      inject.resets_stubbed_methods.reset_all_doubles
    end

    def reset_overwritten_classes
      inject.resets_overwritten_classes.reset
    end

    def fakes(&block)
      inject.fake_configuration.evaluate(&block)
    end

    def inject
      @injector ||= Bogus::Injector.new
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bogus-0.1.3 lib/bogus/public_methods.rb
bogus-0.1.2 lib/bogus/public_methods.rb
bogus-0.1.1 lib/bogus/public_methods.rb