File: auto-link.rb

package info (click to toggle)
ruby-bluefeather 0.41-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 676 kB
  • ctags: 169
  • sloc: ruby: 4,195; makefile: 8
file content (100 lines) | stat: -rw-r--r-- 1,568 bytes parent folder | download | duplicates (5)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
require 'pathname'
require(Pathname.new(__FILE__).parent + 'lib/common.rb')


describe 'Auto Link:' do
	before(:each) do
		@html = BlueFeather.parse(@src)
		@doc = Nokogiri(@html)
	end

	describe 'Valid URL:' do
		
		data = [
			'http://www.example.com/',
			'https://www.example.com/',
			'skype:example-id',
			'mailto:nobody@example.net',
		]
	
		data.each do |url|
			src = "<#{url}>"
			describe src do
				before(:all) do
					@src = src
				end
				
				specify 'p > a' do
					@doc.should have_elements(1, 'p')
					@doc.should have_elements(1, 'p a')
				end
			
				specify 'text' do
					@doc.at('a').inner_text.should == url
				end
				
				specify 'href' do
					@doc.at('a')['href'].should == url
				end

			end
		end
	end
	
	describe 'Invalid URL:' do
		
		data = [
			'http//www.example.com/',
		]
	
		data.each do |url|
			src = "<#{url}>"
			describe src do
				before(:all) do
					@src = src
				end
				
				specify 'no anchor' do
					@doc.should have_element('p')
					@doc.should_not have_element('p a')
				end

			end
		end


	end



	describe 'Valid Address:' do
		
		data = [
			'nobody.user@example.com',
			'nobody.user@example.com',
			'.nobody..user.@example.com',
		]
	
		data.each do |address|
			src = "<#{address}>"
			describe src do
				before(:all) do
					@src = src
				end
				
				specify 'overview' do
					@doc.should have_elements(1, 'p')
					@doc.should have_elements(1, 'p a')
				end
			

			end
		end

	end


	


end