glyph 0.5.2 → 0.5.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/AUTHORS.textile +1 -0
  3. data/CHANGELOG.textile +104 -59
  4. data/Gemfile.lock +46 -0
  5. data/LICENSE.textile +1 -1
  6. data/README.textile +106 -120
  7. data/book/lib/layouts/bookindex.glyph +6 -106
  8. data/book/lib/layouts/bookpage.glyph +8 -108
  9. data/book/lib/layouts/project.glyph +0 -1
  10. data/book/text/acknowledgements.glyph +1 -0
  11. data/book/text/changelog.glyph +7 -1
  12. data/glyph.gemspec +10 -10
  13. data/lib/glyph.rb +1 -1
  14. data/spec/files/test.scss +1 -1
  15. data/spec/lib/analyzer_spec.rb +60 -61
  16. data/spec/lib/bookmark_spec.rb +21 -21
  17. data/spec/lib/commands_spec.rb +53 -54
  18. data/spec/lib/config_spec.rb +16 -16
  19. data/spec/lib/document_spec.rb +35 -35
  20. data/spec/lib/glyph_spec.rb +32 -32
  21. data/spec/lib/interpreter_spec.rb +8 -8
  22. data/spec/lib/macro_spec.rb +51 -49
  23. data/spec/lib/macro_validators_spec.rb +14 -14
  24. data/spec/lib/node_spec.rb +25 -25
  25. data/spec/lib/parser_spec.rb +26 -26
  26. data/spec/lib/reporter_spec.rb +32 -32
  27. data/spec/lib/syntax_node_spec.rb +33 -33
  28. data/spec/macros/core_spec.rb +95 -95
  29. data/spec/macros/filters_spec.rb +9 -8
  30. data/spec/macros/html5_spec.rb +17 -17
  31. data/spec/macros/macros_spec.rb +33 -33
  32. data/spec/macros/textile_spec.rb +15 -15
  33. data/spec/macros/web5_spec.rb +3 -3
  34. data/spec/macros/web_spec.rb +19 -19
  35. data/spec/macros/xml_spec.rb +15 -15
  36. data/spec/tasks/generate_spec.rb +34 -34
  37. data/spec/tasks/load_spec.rb +15 -15
  38. data/spec/tasks/project_spec.rb +15 -15
  39. data/styles/coderay.css +2 -0
  40. data/styles/coderay.css.map +7 -0
  41. data/styles/default.css +9 -7
  42. data/styles/default.css.map +7 -0
  43. data/styles/pagination.css +18 -23
  44. data/styles/pagination.css.map +7 -0
  45. data/tasks/generate.rake +12 -5
  46. metadata +47 -68
  47. data/glyph-0.5.1.gem +0 -0
@@ -9,32 +9,32 @@ describe Node do
9
9
 
10
10
  it "should be a hash" do
11
11
  ht = Node.new
12
- ht.is_a?(Hash).should == true
13
- ht.children.should == []
12
+ expect(ht.is_a?(Hash)).to eq(true)
13
+ expect(ht.children).to eq([])
14
14
  end
15
15
 
16
16
  it "should be generated from a hash" do
17
17
  create_node
18
- @ht.respond_to?(:children).should == true
18
+ expect(@ht.respond_to?(:children)).to eq(true)
19
19
  end
20
20
 
21
21
  it "should support child elements" do
22
22
  create_node
23
- lambda { @ht << "wrong" }.should raise_error
24
- lambda { @ht << {:c => 3, :d => 4} }.should_not raise_error
25
- @ht.children[0][:c].should == 3
26
- lambda { @ht << {:e => 5, :f => 6}.to_node }.should_not raise_error
23
+ expect { @ht << "wrong" }.to raise_error
24
+ expect { @ht << {:c => 3, :d => 4} }.not_to raise_error
25
+ expect(@ht.children[0][:c]).to eq(3)
26
+ expect { @ht << {:e => 5, :f => 6}.to_node }.not_to raise_error
27
27
  @ht.child(1) << {:g => 7, :h => 8}
28
28
  @ht.child(1) << {:i => 9, :j => 10}
29
- ((@ht&1&1)[:j]).should == 10
29
+ expect((@ht&1&1)[:j]).to eq(10)
30
30
  l = (@ht&1).length
31
31
  orphan = @ht&1&0
32
- orphan.parent.should == @ht&1
33
- (@ht&1).children.include?(orphan).should == true
32
+ expect(orphan.parent).to eq(@ht&1)
33
+ expect((@ht&1).children.include?(orphan)).to eq(true)
34
34
  (@ht&1) >> orphan
35
- (@ht&1).children.length.should == l-1
36
- orphan.parent.should == nil
37
- (@ht&1).children.include?(orphan).should == false
35
+ expect((@ht&1).children.length).to eq(l-1)
36
+ expect(orphan.parent).to eq(nil)
37
+ expect((@ht&1).children.include?(orphan)).to eq(false)
38
38
  end
39
39
 
40
40
  it "should support iteration" do
@@ -46,15 +46,15 @@ describe Node do
46
46
  @ht.each_child do |c|
47
47
  c.values.each { |v| sum+=v}
48
48
  end
49
- sum.should == 18
49
+ expect(sum).to eq(18)
50
50
  level = 0
51
51
  str = ""
52
52
  @ht.descend do |c, l|
53
53
  level = l
54
54
  c.values.sort.each { |v| str+=v.to_s}
55
55
  end
56
- str.should == "12347856"
57
- level.should == 1
56
+ expect(str).to eq("12347856")
57
+ expect(level).to eq(1)
58
58
  end
59
59
 
60
60
  it "should store information about parent nodes" do
@@ -63,8 +63,8 @@ describe Node do
63
63
  @ht << {:e => 5, :f => 6}
64
64
  @ht.child(1) << {:g => 7, :h => 8}
65
65
  @ht.child(1).child(0) << {:i => 9, :j => 10}
66
- (@ht&1&0&0).parent.should == @ht&1&0
67
- (@ht&1&0&0).root.should == @ht
66
+ expect((@ht&1&0&0).parent).to eq(@ht&1&0)
67
+ expect((@ht&1&0&0).root).to eq(@ht)
68
68
  end
69
69
 
70
70
  it "should find child nodes" do
@@ -74,24 +74,24 @@ describe Node do
74
74
  result = @ht.find_child do |node|
75
75
  node[:d] == 4
76
76
  end
77
- result.to_hash.should == {:c => 3, :d => 4}
77
+ expect(result.to_hash).to eq({:c => 3, :d => 4})
78
78
  result2 = @ht.find_child do |node|
79
79
  node[:q] == 7
80
80
  end
81
- result2.should == nil
81
+ expect(result2).to eq(nil)
82
82
  end
83
83
 
84
84
  it "should expose a dedicated inspect method" do
85
85
  create_node
86
86
  @ht << {:c => 3, :d => 4}
87
87
  @ht << {:e => 5, :f => 6}
88
- @ht.inspect.should == "#{@ht.to_hash.inspect}\n #{(@ht&0).to_hash.inspect}\n #{(@ht&1).to_hash.inspect}"
88
+ expect(@ht.inspect).to eq("#{@ht.to_hash.inspect}\n #{(@ht&0).to_hash.inspect}\n #{(@ht&1).to_hash.inspect}")
89
89
  end
90
90
 
91
91
  it "should be convertable into a hash" do
92
92
  create_node
93
- @ht.to_hash.should == {:a => 1, :b => 2}
94
- lambda { @ht.to_hash.children }.should raise_error
93
+ expect(@ht.to_hash).to eq({:a => 1, :b => 2})
94
+ expect { @ht.to_hash.children }.to raise_error
95
95
  end
96
96
 
97
97
  it "should check equality of children as well" do
@@ -101,9 +101,9 @@ describe Node do
101
101
  @ht2 = {:a => 1, :b => 2}.to_node
102
102
  @ht2 << {:c => 3, :d => 4}
103
103
  @ht2 << {:e => 5, :f => 6}
104
- (@ht==@ht2).should == true
104
+ expect(@ht==@ht2).to eq(true)
105
105
  (@ht&1)[:c] = 47
106
- (@ht==@ht2).should == false
106
+ expect(@ht==@ht2).to eq(false)
107
107
  end
108
108
 
109
109
  end
@@ -42,7 +42,7 @@ Contents]
42
42
  header_1 << text_node("Another test")
43
43
  section_1 << text_node("\nContents")
44
44
  section_0 << text_node("\n")
45
- parse_text(text).should == tree
45
+ expect(parse_text(text)).to eq(tree)
46
46
  end
47
47
 
48
48
  it "should recognize escape sequences" do
@@ -57,12 +57,12 @@ Contents]
57
57
  macro_0 << escape_node("\\[")
58
58
  macro_0 << text_node(" ")
59
59
  (tree&0) << macro_0
60
- parse_text(text).should == tree
60
+ expect(parse_text(text)).to eq(tree)
61
61
  end
62
62
 
63
63
  it "should raise an error if a standard macro is not closed" do
64
64
  text = "test\nsection[test\\]\ntest"
65
- lambda { puts parse_text(text).inspect }.should raise_error(Glyph::SyntaxError, "-- [3, 4] Macro 'section' not closed")
65
+ expect { puts parse_text(text).inspect }.to raise_error(Glyph::SyntaxError, "-- [3, 4] Macro 'section' not closed")
66
66
  end
67
67
 
68
68
  it "should not parse macros within escaping macros" do
@@ -72,25 +72,25 @@ Contents]
72
72
  macro_0 = p_node(0)
73
73
  macro_0 << text_node(" abc test2[This macro is escaped]\n cde", :escaped => true)
74
74
  (tree&0) << macro_0
75
- parse_text(text).should == tree
75
+ expect(parse_text(text)).to eq(tree)
76
76
  end
77
77
 
78
78
  it "should raise an error if escaped contents are nested" do
79
79
  text = "test1[= abc test2[=This macro is escaped=]\n cde=]"
80
- lambda { puts parse_text(text).inspect }.should raise_error(Glyph::SyntaxError, "-- [1, 41] Cannot nest escaping macro 'test2' within escaping macro 'test1'")
80
+ expect { puts parse_text(text).inspect }.to raise_error(Glyph::SyntaxError, "-- [1, 41] Cannot nest escaping macro 'test2' within escaping macro 'test1'")
81
81
  end
82
82
 
83
83
  it "should raise an error if an escaping macro is not closed" do
84
84
  text = "test1[= abc test2[This macro is escaped]\n cde] test"
85
- lambda { puts parse_text(text).inspect }.should raise_error(Glyph::SyntaxError, "-- [2, 10] Escaping macro 'test1' not closed")
85
+ expect { puts parse_text(text).inspect }.to raise_error(Glyph::SyntaxError, "-- [2, 10] Escaping macro 'test1' not closed")
86
86
  end
87
87
 
88
88
  it "should raise errors if unescaped brackets are found" do
89
- lambda { puts parse_text(" ] test[...] dgdsg").inspect}.should raise_error(Glyph::SyntaxError, "-- [1, 2] Macro delimiter ']' not escaped")
90
- lambda { puts parse_text("[ test[...] dgdsg").inspect}.should raise_error(Glyph::SyntaxError, "-- [1, 1] Macro delimiter '[' not escaped")
91
- lambda { puts parse_text(" test[...] [dgdsg]").inspect}.should raise_error(Glyph::SyntaxError, "-- [1, 12] Macro delimiter '[' not escaped")
92
- lambda { puts parse_text(" test[...] dgdsg [").inspect}.should raise_error(Glyph::SyntaxError, "-- [1, 18] Macro delimiter '[' not escaped")
93
- lambda { puts parse_text(" test[[...]] dgdsg").inspect}.should raise_error(Glyph::SyntaxError, "-- [1, 7] Macro delimiter '[' not escaped")
89
+ expect { puts parse_text(" ] test[...] dgdsg").inspect}.to raise_error(Glyph::SyntaxError, "-- [1, 2] Macro delimiter ']' not escaped")
90
+ expect { puts parse_text("[ test[...] dgdsg").inspect}.to raise_error(Glyph::SyntaxError, "-- [1, 1] Macro delimiter '[' not escaped")
91
+ expect { puts parse_text(" test[...] [dgdsg]").inspect}.to raise_error(Glyph::SyntaxError, "-- [1, 12] Macro delimiter '[' not escaped")
92
+ expect { puts parse_text(" test[...] dgdsg [").inspect}.to raise_error(Glyph::SyntaxError, "-- [1, 18] Macro delimiter '[' not escaped")
93
+ expect { puts parse_text(" test[[...]] dgdsg").inspect}.to raise_error(Glyph::SyntaxError, "-- [1, 7] Macro delimiter '[' not escaped")
94
94
  end
95
95
 
96
96
  it "should parse positional parameters (parameters)" do
@@ -114,12 +114,12 @@ Contents]
114
114
  macro_011 << text_node("...")
115
115
  (macro_01_p1&0) << macro_011
116
116
  macro_0 << text_node(".")
117
- parse_text(text).should == tree
117
+ expect(parse_text(text)).to eq(tree)
118
118
  end
119
119
 
120
120
  it "should not allow parameters outside macros" do
121
121
  text = "... | test[...]"
122
- lambda { puts parse_text(text).inspect }.should raise_error(Glyph::SyntaxError, "-- [1, 5] Parameter delimiter '|' not allowed here")
122
+ expect { puts parse_text(text).inspect }.to raise_error(Glyph::SyntaxError, "-- [1, 5] Parameter delimiter '|' not allowed here")
123
123
  end
124
124
 
125
125
  it "should recognize escaped pipes" do
@@ -140,7 +140,7 @@ Contents]
140
140
  test_1 << text_node("a ", :escaped => true)
141
141
  test_1 << escape_node("\\|")
142
142
  test_1 << text_node("test", :escaped => true)
143
- parse_text(text).should == tree
143
+ expect(parse_text(text)).to eq(tree)
144
144
  end
145
145
 
146
146
  it "should parse named parameters (attributes)" do
@@ -157,12 +157,12 @@ Contents]
157
157
  (tree&0) << macro_0
158
158
  (tree&0) << first
159
159
  (tree&0) << second
160
- parse_text(text).should == tree
160
+ expect(parse_text(text)).to eq(tree)
161
161
  end
162
162
 
163
163
  it "should not parse parameters inside attributes" do
164
164
  text = "test[@attr[test|...]]"
165
- lambda { puts parse_text(text).inspect}.should raise_error(Glyph::SyntaxError, "-- [1, 16] Parameter delimiter '|' not allowed here")
165
+ expect { puts parse_text(text).inspect}.to raise_error(Glyph::SyntaxError, "-- [1, 16] Parameter delimiter '|' not allowed here")
166
166
  end
167
167
 
168
168
  it "should parse attributes inside parameters" do
@@ -178,12 +178,12 @@ Contents]
178
178
  par = tree.children.last&2
179
179
  par << text_node("...")
180
180
  test_1 << text_node(" test")
181
- parse_text(text).should == tree
181
+ expect(parse_text(text)).to eq(tree)
182
182
  end
183
183
 
184
184
  it "should not allow attribute nesting" do
185
185
  text = "... test[@par1[@par2[...]...]]"
186
- lambda { puts parse_text(text).inspect}.should raise_error(Glyph::SyntaxError, "-- [1, 22] Attributes cannot be nested")
186
+ expect { puts parse_text(text).inspect}.to raise_error(Glyph::SyntaxError, "-- [1, 22] Attributes cannot be nested")
187
187
  end
188
188
 
189
189
  it "should parse macros nested in attributes" do
@@ -199,7 +199,7 @@ Contents]
199
199
  c = a_node :c
200
200
  c << text_node('...')
201
201
  (a&0) << c
202
- parse_text(text).should == tree
202
+ expect(parse_text(text)).to eq(tree)
203
203
  end
204
204
 
205
205
  it "should parse parameters in nested macros" do
@@ -221,7 +221,7 @@ Contents]
221
221
  macro_0_p2 = p_node 2
222
222
  macro_0_p2 << text_node("...")
223
223
  (tree&0) << macro_0_p2
224
- parse_text(text).should == tree
224
+ expect(parse_text(text)).to eq(tree)
225
225
  end
226
226
 
227
227
  it "should handle escaped sequences before macro names" do
@@ -233,21 +233,21 @@ Contents]
233
233
  macro_0 = p_node(0)
234
234
  macro_0 << text_node("...")
235
235
  (tree&2) << macro_0
236
- parse_text(text).should == tree
236
+ expect(parse_text(text)).to eq(tree)
237
237
  end
238
238
 
239
239
  it "should ignore parameters for empty macros" do
240
240
  text = "toc[]"
241
241
  tree = document_node
242
242
  tree << macro_node(:toc)
243
- parse_text(text).should == tree
243
+ expect(parse_text(text)).to eq(tree)
244
244
  end
245
245
 
246
246
  it "should allow macro composition" do
247
- parse_text("test[...|a/b/c[...]]").should == parse_text("test[...|a[b[c[...]]]]")
248
- parse_text(" /test[...]").should == parse_text(" test[...]")
249
- parse_text(" test/[...]").should == parse_text(" test[...]")
250
- parse_text("a/b/c[=test[...]=]").should == parse_text("a[b[c[=test[...]=]]]")
247
+ expect(parse_text("test[...|a/b/c[...]]")).to eq(parse_text("test[...|a[b[c[...]]]]"))
248
+ expect(parse_text(" /test[...]")).to eq(parse_text(" test[...]"))
249
+ expect(parse_text(" test/[...]")).to eq(parse_text(" test[...]"))
250
+ expect(parse_text("a/b/c[=test[...]=]")).to eq(parse_text("a[b[c[=test[...]=]]]"))
251
251
  end
252
252
 
253
253
  end
@@ -30,104 +30,104 @@ describe Glyph::Reporter do
30
30
 
31
31
  it "should be initialized with stats" do
32
32
  stats :macros
33
- lambda { rep }.should_not raise_error
33
+ expect { rep }.not_to raise_error
34
34
  end
35
35
 
36
36
  it "should display macro stats" do
37
37
  stats :macros
38
38
  out = stdout_for { rep.display }
39
- out.should match "Total Macro Instances: 20"
40
- out.should match "-- Used Macro Definitions:"
39
+ expect(out).to match "Total Macro Instances: 20"
40
+ expect(out).to match "-- Used Macro Definitions:"
41
41
  @r.detailed = false
42
42
  out = stdout_for { @r.display }
43
- out.should_not match "-- Used Macro Definitions:"
43
+ expect(out).not_to match "-- Used Macro Definitions:"
44
44
  end
45
45
 
46
46
  it "should display stats for a single macro" do
47
47
  stats :macro, :section
48
48
  out = stdout_for { rep.display }
49
- out.should match "text/a/b/c/markdown.markdown \\(1\\)"
50
- out.should match "-- Total Instances: 4"
49
+ expect(out).to match "text/a/b/c/markdown.markdown \\(1\\)"
50
+ expect(out).to match "-- Total Instances: 4"
51
51
  @r.detailed = false
52
52
  out = stdout_for { @r.display }
53
- out.should_not match "text/a/b/c/markdown.markdown \\(1\\)"
53
+ expect(out).not_to match "text/a/b/c/markdown.markdown \\(1\\)"
54
54
  stats :macro, :"=>"
55
55
  out = stdout_for { rep.display }
56
- out.should match "alias for: link"
56
+ expect(out).to match "alias for: link"
57
57
  end
58
58
 
59
59
  it "should display bookmark stats" do
60
60
  stats :bookmarks
61
61
  out = stdout_for { rep.display }
62
- out.should match "-- Total Bookmarks: 6"
63
- out.should match "h_1 h_2 md refs toc"
64
- out.should match " - h_1 \\(1\\)"
62
+ expect(out).to match "-- Total Bookmarks: 6"
63
+ expect(out).to match "h_1 h_2 md refs toc"
64
+ expect(out).to match " - h_1 \\(1\\)"
65
65
  @r.detailed = false
66
66
  out = stdout_for { @r.display }
67
- out.should_not match "-- Occurrences:"
67
+ expect(out).not_to match "-- Occurrences:"
68
68
  end
69
69
 
70
70
  it "should display stats for a single bookmark" do
71
71
  stats :bookmark, 'refs'
72
72
  out = stdout_for { rep.display }
73
- out.should match "===== Bookmark 'refs' \\(header\\)"
74
- out.should match " - text/references.glyph \\(1\\)"
73
+ expect(out).to match "===== Bookmark 'refs' \\(header\\)"
74
+ expect(out).to match " - text/references.glyph \\(1\\)"
75
75
  @r.detailed = false
76
76
  out = stdout_for { @r.display }
77
- out.should_not match "-- Referenced in:"
77
+ expect(out).not_to match "-- Referenced in:"
78
78
  end
79
79
 
80
80
  it "should display snippet stats" do
81
81
  stats :snippets
82
82
  out = stdout_for { rep.display }
83
- out.should match "-- Total Snippets: 2"
83
+ expect(out).to match "-- Total Snippets: 2"
84
84
  end
85
85
 
86
86
  it "should display stats for a single snippet" do
87
87
  stats :snippets
88
88
  stats :snippet, :test
89
89
  out = stdout_for { rep.display }
90
- out.should match "-- Total Used Instances: 2"
91
- out.should match " - text/references.glyph \\(1\\)"
90
+ expect(out).to match "-- Total Used Instances: 2"
91
+ expect(out).to match " - text/references.glyph \\(1\\)"
92
92
  @r.detailed = false
93
93
  out = stdout_for { @r.display }
94
- out.should_not match "-- Usage Details:"
94
+ expect(out).not_to match "-- Usage Details:"
95
95
  end
96
96
 
97
97
  it "should display link stats" do
98
98
  stats :links
99
99
  out = stdout_for { rep.display }
100
- out.should match "http://www.h3rald.com"
101
- out.should match "-- Total Internal Links: 2"
100
+ expect(out).to match "http://www.h3rald.com"
101
+ expect(out).to match "-- Total Internal Links: 2"
102
102
  @r.detailed = false
103
103
  out = stdout_for { @r.display }
104
- out.should_not match " - text/references.glyph (1)"
104
+ expect(out).not_to match " - text/references.glyph (1)"
105
105
  end
106
106
 
107
107
  it "should display stats for a single link" do
108
108
  stats :link, 'h3'
109
109
  out = stdout_for { rep.display }
110
- out.should match "===== Links matching \\/h3\\/"
111
- out.should match " - http://www.h3rald.com \\(1\\)"
110
+ expect(out).to match "===== Links matching \\/h3\\/"
111
+ expect(out).to match " - http://www.h3rald.com \\(1\\)"
112
112
  @r.detailed = false
113
113
  out = stdout_for { @r.display }
114
- out.should_not match " - http://www.h3rald.com \\(1\\)"
114
+ expect(out).not_to match " - http://www.h3rald.com \\(1\\)"
115
115
  end
116
116
 
117
117
  it "should display files stats" do
118
118
  stats :files
119
119
  out = stdout_for { rep.display }
120
- out.should match "-- Total Files: 6"
121
- out.should match "-- /text -- 4"
120
+ expect(out).to match "-- Total Files: 6"
121
+ expect(out).to match "-- /text -- 4"
122
122
  end
123
123
 
124
124
  it "should display global stats" do
125
125
  stats :global
126
126
  out = stdout_for { rep.display }
127
- out.should match "-- Total Files: 6"
128
- out.should match " - http://www.h3rald.com"
129
- out.should match "Total Macro Instances: 20"
130
- out.should match "-- Total Snippets: 2"
131
- out.should match "h_1 h_2 md refs toc"
127
+ expect(out).to match "-- Total Files: 6"
128
+ expect(out).to match " - http://www.h3rald.com"
129
+ expect(out).to match "Total Macro Instances: 20"
130
+ expect(out).to match "-- Total Snippets: 2"
131
+ expect(out).to match "h_1 h_2 md refs toc"
132
132
  end
133
133
  end
@@ -6,18 +6,18 @@ describe Glyph::SyntaxNode do
6
6
  it "should evaluate" do
7
7
  t = text_node("test")
8
8
  t.evaluate({})
9
- t[:value].should == "test"
9
+ expect(t[:value]).to eq("test")
10
10
  e = escape_node("\\.")
11
11
  e.evaluate({})
12
- e[:value].should == "\\."
12
+ expect(e[:value]).to eq("\\.")
13
13
  p = p_node(0)
14
14
  a = a_node(:a)
15
15
  a << e
16
16
  p << t
17
17
  p.evaluate({}, :params => true)
18
- p[:value].should == "test"
18
+ expect(p[:value]).to eq("test")
19
19
  a.evaluate({}, :attrs => true)
20
- a[:value].should == "\\."
20
+ expect(a[:value]).to eq("\\.")
21
21
  Glyph.macro :test do
22
22
  attribute(:a)+param(0)
23
23
  end
@@ -25,41 +25,41 @@ describe Glyph::SyntaxNode do
25
25
  m << p
26
26
  m << a
27
27
  m.evaluate({})
28
- m[:value].should == "\\.test"
28
+ expect(m[:value]).to eq("\\.test")
29
29
  end
30
30
 
31
31
  it "should return its parent macro" do
32
32
  node = Glyph::Parser.new("test[@a[a].|test]").parse
33
- node.parent_macro.should == nil
34
- (node&0).parent_macro.should == nil
35
- (node&0&0).parent_macro.should == node&0
36
- (node&0&1).parent_macro.should == node&0
37
- (node&0&0&0).parent_macro.should == node&0
38
- (node&0&1&0).parent_macro.should == node&0
33
+ expect(node.parent_macro).to eq(nil)
34
+ expect((node&0).parent_macro).to eq(nil)
35
+ expect((node&0&0).parent_macro).to eq(node&0)
36
+ expect((node&0&1).parent_macro).to eq(node&0)
37
+ expect((node&0&0&0).parent_macro).to eq(node&0)
38
+ expect((node&0&1&0).parent_macro).to eq(node&0)
39
39
  end
40
40
 
41
41
  it "should convert to a string implicitly" do
42
- "#{text_node("test")}".should == "test"
43
- "#{escape_node("\\.")}".should == "\\."
44
- "#{document_node}".should == ""
42
+ expect("#{text_node("test")}").to eq("test")
43
+ expect("#{escape_node("\\.")}").to eq("\\.")
44
+ expect("#{document_node}").to eq("")
45
45
  p0 = p_node(0)
46
46
  p0 << text_node("p0")
47
47
  p1 = p_node(1)
48
48
  p1 << text_node("p1")
49
- "#{p0}".should == "p0"
50
- "#{p1}".should == "p1"
49
+ expect("#{p0}").to eq("p0")
50
+ expect("#{p1}").to eq("p1")
51
51
  a = a_node(:a)
52
52
  a << text_node("a")
53
53
  b = a_node(:b)
54
54
  b << text_node("b")
55
- "#{a}".should == "@a[a]"
56
- "#{b}".should == "@b[b]"
55
+ expect("#{a}").to eq("@a[a]")
56
+ expect("#{b}").to eq("@b[b]")
57
57
  m = macro_node(:test, :escape => true)
58
58
  m << a
59
59
  m << b
60
60
  m << p0
61
61
  m << p1
62
- "#{m}".should == "test[=@a[a]@b[b]p0|p1=]"
62
+ expect("#{m}").to eq("test[=@a[a]@b[b]p0|p1=]")
63
63
  end
64
64
 
65
65
  end
@@ -80,34 +80,34 @@ describe Glyph::MacroNode do
80
80
  end
81
81
 
82
82
  it "should expand the corresponding macro" do
83
- @n.expand({}).should == "--test:test--"
83
+ expect(@n.expand({})).to eq("--test:test--")
84
84
  end
85
85
 
86
86
  it "should retrieve parameter nodes easily" do
87
- @n.parameter(0).should == @p
88
- @n.parameters.should == [@p]
87
+ expect(@n.parameter(0)).to eq(@p)
88
+ expect(@n.parameters).to eq([@p])
89
89
  end
90
90
 
91
91
  it "should retrieve attribute nodes easily" do
92
- @n.attribute(:a).should == @a
93
- @n.attributes.should == [@a]
92
+ expect(@n.attribute(:a)).to eq(@a)
93
+ expect(@n.attributes).to eq([@a])
94
94
  end
95
95
 
96
96
  it "should convert escaping attributes and parameters to strings properly" do
97
97
  @a[:escape] = true
98
- @a.to_s.should == "@a[=test=]"
99
- @a.contents.should == ".[=test=]"
98
+ expect(@a.to_s).to eq("@a[=test=]")
99
+ expect(@a.contents).to eq(".[=test=]")
100
100
  @p.parent[:escape] = true
101
- @p.to_s.should == "test"
102
- @p.contents.should == ".[=test=]"
101
+ expect(@p.to_s).to eq("test")
102
+ expect(@p.contents).to eq(".[=test=]")
103
103
  ###
104
104
  n = macro_node(:test)
105
105
  a = a_node(:a)
106
106
  a[:escape] = true
107
107
  a << text_node("alias[test\\|test1]")
108
108
  n << a
109
- a.to_s.should == "@a[=alias[test\\|test1]=]"
110
- a.contents.should == ".[=alias[test\\|test1]=]"
109
+ expect(a.to_s).to eq("@a[=alias[test\\|test1]=]")
110
+ expect(a.contents).to eq(".[=alias[test\\|test1]=]")
111
111
  end
112
112
 
113
113
  it "should perform macro dispatching" do
@@ -124,7 +124,7 @@ describe Glyph::MacroNode do
124
124
  m = macro_node :test_macro
125
125
  p << m
126
126
  d << p
127
- m.expand({}).should == "dispatched: test_macro"
127
+ expect(m.expand({})).to eq("dispatched: test_macro")
128
128
  # Parent dispatcher via attribute
129
129
  d = macro_node :dispatcher
130
130
  d[:dispatch] = dispatch_proc
@@ -132,14 +132,14 @@ describe Glyph::MacroNode do
132
132
  m = macro_node :test_macro
133
133
  a << m
134
134
  d << a
135
- m.expand({}).should == "dispatched: test_macro"
135
+ expect(m.expand({})).to eq("dispatched: test_macro")
136
136
  # No dispatcher
137
137
  d = macro_node :no_dispatcher
138
138
  a = a_node :attr1
139
139
  m = macro_node :test_macro
140
140
  a << m
141
141
  d << a
142
- m.expand({}).should == "--test macro--"
142
+ expect(m.expand({})).to eq("--test macro--")
143
143
  end
144
144
 
145
145
  end