Sha256: 3dc9322e0b91e0783f8d54b4d85a239befea21c9fe28296566b8b585509c3c99
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 KB
Contents
require_relative "../test_helper" require "stig" setup { Stig } prepare { $test = nil } test "without a block" do |stig| assert_raise(ArgumentError) { stig.generator } end test "with a block" do |stig| generator = stig.generator { 1 } assert_equal generator.class, Proc assert_equal generator.call, 1 end test "with a block taking arguments" do |stig| arguments = [:a, :b, :c] generator = stig.generator(*arguments) { |*args| args } assert_equal generator.call, arguments end test "with an object without a #random" do |stig| assert_raise(ArgumentError) { stig.generator_for "no #random" } end test "with an object responding to #random" do |stig| object = Object.new object.define_singleton_method(:random) { 1 } generator = stig.generator_for(object) assert_equal generator.class, Proc assert_equal generator.call, 1 end test "with an object taking arguments" do |stig| object = Object.new object.define_singleton_method(:random) { |*args| args } arguments = [:a, :b, :c] generator = stig.generator_for(object, *arguments) assert_equal generator.call, arguments end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stig-0.1.0 | test/stig/generator.rb |