Skip to content

Commit 8253ccb

Browse files
committed
bugfix for Ruby 2.0
1 parent 8eedd9a commit 8253ccb

File tree

6 files changed

+38
-24
lines changed

6 files changed

+38
-24
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
source :rubygems
1+
source 'https://rubygems.org'
22

33
gemspec
44

HISTORY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 0.5.1
2+
* bugfix for Ruby 2.0
3+
14
# 0.5.0
25
* bring deck.js up to date (https://github.com/imakewebthings/deck.js/commit/069f63294abe8c2bfd0e3c9b34d26090802c4f46)
36
* add --style and --transition options

lib/deck/slide_deck.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def scripts
9494
end
9595

9696
# fire up deck.js
97-
script "$(function(){$.deck('.slide');});"
97+
script raw("$(function(){$.deck('.slide');});")
9898

9999
end
100100

lib/deck/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Deck
2-
VERSION = "0.5.0"
2+
VERSION = "0.5.1"
33
end

spec/slide_deck_spec.rb

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,25 @@ module Deck
88

99
include Files
1010

11-
def doc
12-
@doc ||= begin
13-
@html = deck_widget.to_html
14-
noko_doc @html
15-
end
16-
end
11+
let(:html) { deck_widget.to_html }
12+
let(:doc) { noko_doc html }
1713

1814
def deck_widget options = {}
1915
@deck_widget ||= SlideDeck.new options
2016
end
2117

18+
def assert_html_like actual, expected
19+
actual = actual.strip.gsub("\n\n", "\n")
20+
expected = expected.strip.gsub("\n\n", "\n")
21+
assert { actual == expected }
22+
end
23+
2224
it "renders a basic deck.js HTML page" do
23-
assert { doc }
24-
assert { @html.include? '<link href="/deck.js/core/deck.core.css" rel="stylesheet" />' }
25+
assert { html.include? '<link href="/deck.js/core/deck.core.css" rel="stylesheet" />' }
26+
end
27+
28+
it "starts the deck script running" do
29+
assert { html.include? "$.deck('.slide');" }
2530
end
2631

2732
it "contains a single dummy slide" do
@@ -35,27 +40,26 @@ def deck_widget options = {}
3540
assert { slides.size == 1 }
3641
slide = slides.first
3742
assert { slide["id"] == "hello" }
38-
assert { noko_html(slide) == "<section class=\"slide\" id=\"hello\">" +
39-
"<h1>hello</h1>\n" +
40-
"</section>"
41-
}
43+
44+
slide_html = noko_html(slide)
45+
slide_html.gsub!("\n", "") # WTF Nokogiri inconsistently outputs newlines between Ruby 1.9 and 2.0
46+
assert { slide_html == "<section class=\"slide\" id=\"hello\">" + "<h1>hello</h1>" + "</section>" }
4247
end
4348

4449
it "includes a table of contents" do
4550
deck_widget :slides => Slide.split("# Foo\n\n# Bar\n")
4651
toc = doc.css('.slide_toc')
4752
assert { toc.size == 1 }
48-
assert { noko_html(toc.first) == "<div class=\"slide_toc\">" +
53+
assert_html_like noko_html(toc.first), "<div class=\"slide_toc\">" +
4954
"<div class=\"toggle\">[contents]</div>" +
5055
"<div class=\"table\">" +
5156
"<h2>deck.rb presentation</h2>" +
5257
"<ul>" +
5358
"<li><a href=\"#foo\">Foo</a></li>" +
5459
"<li><a href=\"#bar\">Bar</a></li>" +
5560
"</ul>" +
61+
"</div>" +
5662
"</div>"
57-
"</div>"
58-
}
5963
end
6064

6165
describe "themes" do

spec/slide_spec.rb

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
module Deck
77
describe Slide do
88

9+
def assert_html_like actual, expected
10+
actual = actual.strip.gsub("\n\n", "\n")
11+
expected = expected.strip.gsub("\n\n", "\n")
12+
assert { actual == expected }
13+
end
14+
15+
916
describe "classes" do
1017
it "by default" do
1118
assert {Slide.new.classes == ["slide"]}
@@ -246,7 +253,7 @@ def slide_from markdown_text
246253
</ul>
247254
</section>
248255
HTML
249-
assert { html == expected_html }
256+
assert_html_like html, expected_html
250257
end
251258

252259
it "with only a underline-style header, leaving a solo H1 as an H1" do
@@ -259,7 +266,7 @@ def slide_from markdown_text
259266
<h1>foo</h1>
260267
</section>
261268
HTML
262-
assert { html == expected_html }
269+
assert_html_like html, expected_html
263270
end
264271

265272
it "converts a non-solo underline-style H1 into an H2 for deck.js style compatibility)" do
@@ -279,7 +286,7 @@ def slide_from markdown_text
279286
</ul>
280287
</section>
281288
HTML
282-
assert { html == expected_html }
289+
assert_html_like html, expected_html
283290
end
284291

285292
it "skips notes" do
@@ -291,7 +298,7 @@ def slide_from markdown_text
291298
</section>
292299
HTML
293300

294-
assert { slide_from(source).to_pretty == expected }
301+
assert_html_like slide_from(source).to_pretty, expected
295302
end
296303

297304
end
@@ -314,7 +321,7 @@ def slide_from markdown_text
314321
</ul>
315322
</section>
316323
HTML
317-
assert { html == expected_html }
324+
assert_html_like html, expected_html
318325
end
319326
end
320327

@@ -336,7 +343,7 @@ def slide_from markdown_text
336343
</ul>
337344
</section>
338345
HTML
339-
assert { html == expected_html }
346+
assert_html_like html, expected_html
340347
end
341348
end
342349

0 commit comments

Comments
 (0)