Sha256: 726a014c0d20c29b948e9e9c94daab4631709729b42aec48d1597173dec0c5a9
Contents?: true
Size: 1.43 KB
Versions: 3
Compression:
Stored size: 1.43 KB
Contents
#! /usr/bin/ruby #encoding: utf-8 require 'minitest/autorun' require_relative '../../lib/y_support/misc/null_object' describe "y_support/null_object" do describe Object do it "should have #null_object? (alias #null?)" do assert ( class Koko < NullObject; self end ).new.null_object? assert ( class Koko < NullObject; self end ).new.null? assert_equal [ false, false ], [ nil.null_object?, nil.null? ] assert NullObject.new( :koko ).null?( :koko ) assert ! NullObject.new( :koko ).null?( :pipi ) end it "should have #Maybe() constructor for something / NullObject" do assert_equal NullObject, Maybe(nil).class assert_equal 42, Maybe(42) end it "should have #Null() constructor always returning NullObject" do assert_equal NullObject, Null().class end end # context Object describe "NullObject" do it "should NullObject exist and comply" do n = NullObject.new [n.to_a, n.to_s, n.to_f, n.to_i].must_equal [ [], "#<NullObject>", 0.0, 0 ] assert_equal [false, true], [n.present?, n.empty?] NullObject.new.must_have_attr_reader( :recorded_messages ) assert_respond_to NullObject.new, :arbitrary_message n = NullObject.new :x n.arbitrary_message( :a, :b ) { "hello" } assert_equal :x, n.null_object_signature assert_equal "#<NullObject kokotina>", NullObject.new( :kokotina ).inspect end end # context NullObject end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
y_support-2.5.3 | test/misc/null_object_test.rb |
y_support-2.5.2 | test/misc/null_object_test.rb |
y_support-2.5.1 | test/misc/null_object_test.rb |