forked from indirect/rails-footnotes
/
abstract_note_spec.rb
80 lines (66 loc) · 2.36 KB
/
abstract_note_spec.rb
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
require "spec_helper"
describe Footnotes::Notes::AbstractNote do
before do
@note = Footnotes::Notes::AbstractNote.new
Footnotes::Filter.notes = [:abstract]
end
it {described_class.should respond_to :start!}
it {described_class.should respond_to :close!}
it {described_class.should respond_to :title}
it {should respond_to :to_sym}
its(:to_sym) {should eql :abstract}
it { described_class.should be_included }
specify do
Footnotes::Filter.notes = []
described_class.should_not be_included
end
it { should respond_to :row }
it { should respond_to :legend }
it { should respond_to :link }
it { should respond_to :onclick }
it { should respond_to :stylesheet }
it { should respond_to :javascript }
it { should respond_to :valid? }
it { should be_valid }
it { should respond_to :has_fieldset? }
it { should_not have_fieldset }
specify { Footnotes::Filter.prefix = ''; should_not be_prefix }
specify do
Footnotes::Filter.prefix = 'txmt://open?url=file://%s&line=%d&column=%d'
should be_prefix
end
#TODO should be moved to builder
#helpers
specify { subject.escape('<').should eql '<' }
specify { subject.escape('&').should eql '&' }
specify { subject.escape('>').should eql '>' }
specify { subject.mount_table([]).should be_blank }
specify { subject.mount_table([['h1', 'h2', 'h3']], :class => 'table').should be_blank }
specify {
tab = <<-TABLE
<table class="table" >
<thead><tr><th>H1</th></tr></thead>
<tbody><tr><td>r1c1</td></tr></tbody>
</table>
TABLE
subject.mount_table([['h1'],['r1c1']], :class => 'table').should eql tab
}
specify {
tab = <<-TABLE
<table >
<thead><tr><th>H1</th><th>H2</th><th>H3</th></tr></thead>
<tbody><tr><td>r1c1</td><td>r1c2</td><td>r1c3</td></tr></tbody>
</table>
TABLE
subject.mount_table([['h1', 'h2', 'h3'],['r1c1', 'r1c2', 'r1c3']]).should eql tab
}
specify {
tab = <<-TABLE
<table >
<thead><tr><th>H1</th><th>H2</th><th>H3</th></tr></thead>
<tbody><tr><td>r1c1</td><td>r1c2</td><td>r1c3</td></tr><tr><td>r2c1</td><td>r2c2</td><td>r2c3</td></tr></tbody>
</table>
TABLE
subject.mount_table([['h1', 'h2', 'h3'], ['r1c1', 'r1c2', 'r1c3'], ['r2c1', 'r2c2', 'r2c3']])
}
end