test_ibr.rb

 1# frozen_string_literal: true
 2
 3require "test_helper"
 4require "ibr"
 5
 6class IBRTest < Minitest::Test
 7	property(:registered) { boolean }
 8	def registered(val)
 9		ibr = IBR.new
10		ibr.registered = val
11		assert_equal val, ibr.registered?
12	end
13
14	{
15		instructions: :string,
16		username: :string,
17		nick: :string,
18		password: :string,
19		name: :string,
20		first: :string,
21		last: :string,
22		email: :string,
23		address: :string,
24		city: :string,
25		state: :string,
26		zip: :string,
27		phone: [:string, :digit],
28		url: :string,
29		date: ->(*) { Time.at(range(0, 4294967295)).iso8601 }
30	}.each do |prop, type|
31		property("prop_#{prop}") { call(type) }
32		define_method("prop_#{prop}") do |val|
33			ibr = IBR.new
34			ibr.public_send("#{prop}=", val)
35			assert_equal val, ibr.public_send(prop)
36		end
37	end
38end