Sha256: 5d667f77893a9bf14030a00c7804b3389f08200505ab9773e0605a8748205a5d

Contents?: true

Size: 725 Bytes

Versions: 1

Compression:

Stored size: 725 Bytes

Contents

require_relative "../test_helper"
require "stig"
require "stig/generators/hash"

include Stig

setup { Stig::Generators::Hash }

test "takes a generator" do |mod|
  keys      = generator { rand }
  values    = generator { 1 }
  generator = generator_for(mod, values)

  property(generator, keys) do |hash, key|
    assert_equal hash[key], 1

    true
  end
end

test "takes a generator and a list of keys" do |mod|
  keys      = [:a, :b, :c]
  values    = generator { 1 }
  generator = generator_for(mod, values, *keys)

  property(generator) do |hash|
    assert_equal hash, :a => 1, :b => 1, :c => 1

    true
  end
end

test "doesn't take an invalid generator" do |mod|
  assert_raise(ArgumentError) { mod.random(1) }
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stig-0.1.0 test/stig/hash_generator.rb