~singpolyma/sgx-jmp

ref: 6665370def4be4097eda0de37d29c288954936ed sgx-jmp/test/test_oob.rb -rw-r--r-- 1.1 KiB
6665370dStephen Paul Weber No low balance if not registered 1 year, 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# frozen_string_literal: true

require "oob"

class OOBTest < Minitest::Test
	def test_new
		oob = OOB.new
		assert_kind_of OOB, oob
		assert_nil oob.url
		assert_nil oob.desc
	end

	def test_new_with_node
		assert_kind_of OOB, OOB.new(Blather::XMPPNode.new)
	end

	property(:new_with_attrs) { [string(:alnum), string] }
	def new_with_attrs(url, description)
		oob = OOB.new(url, desc: description)
		assert_kind_of OOB, oob
		assert_equal url, oob.url
		assert_equal description, oob.desc
	end

	def test_find_or_create_not_found
		assert_kind_of OOB, OOB.find_or_create(Blather::XMPPNode.new)
	end

	def test_find_or_create_found
		parent = Blather::XMPPNode.new
		parent << OOB.new("http://example.com")
		assert_kind_of OOB, OOB.find_or_create(parent)
		assert_equal "http://example.com", OOB.find_or_create(parent).url
	end

	property(:url) { string(:alnum) }
	def url(a_url)
		oob = OOB.new
		oob.url = a_url
		assert_equal a_url, oob.url
	end

	property(:desc) { string }
	def desc(description)
		oob = OOB.new
		oob.desc = description
		assert_equal description, oob.desc
	end
end