Sha256: e44eb6690b092952994f52548be2a0784c711742ae5f7c8ec2232b26ea4f4c6e

Contents?: true

Size: 834 Bytes

Versions: 3

Compression:

Stored size: 834 Bytes

Contents

require "assert/factory"
require "much-stub/call"

module Factory
  extend Assert::Factory

  def self.value
    [Factory.integer, Factory.string, Object.new].sample
  end

  def self.hash_value(with_nested_hash = true)
    {
      value1: Factory.value,
      value2: with_nested_hash ? Factory.hash_value(false) : Factory.value
    }
  end

  def self.backtrace
    Factory.integer(3).times.map{ Factory.path }
  end

  def self.transaction_receiver
    FakeTransactionReceiver.new
  end

  class FakeTransactionReceiver
    attr_reader :last_transaction_call

    def transaction(&block)
      @rolled_back = false
      @last_transaction_call = MuchStub::Call.new(&block)
      block.call
    rescue => exception
      @rolled_back = true
      raise exception
    end

    def rolled_back?
      !!@rolled_back
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
much-result-0.1.2 test/support/factory.rb
much-result-0.1.1 test/support/factory.rb
much-result-0.1.0 test/support/factory.rb