Skip to content

Commit

Permalink
bugfix for Ruby 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alexch committed Jul 25, 2013
1 parent 8eedd9a commit 8253ccb
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Gemfile
@@ -1,4 +1,4 @@
source :rubygems
source 'https://rubygems.org'

gemspec

Expand Down
3 changes: 3 additions & 0 deletions HISTORY.md
@@ -1,3 +1,6 @@
# 0.5.1
* bugfix for Ruby 2.0

# 0.5.0
* bring deck.js up to date (https://github.com/imakewebthings/deck.js/commit/069f63294abe8c2bfd0e3c9b34d26090802c4f46)
* add --style and --transition options
Expand Down
2 changes: 1 addition & 1 deletion lib/deck/slide_deck.rb
Expand Up @@ -94,7 +94,7 @@ def scripts
end

# fire up deck.js
script "$(function(){$.deck('.slide');});"
script raw("$(function(){$.deck('.slide');});")

end

Expand Down
2 changes: 1 addition & 1 deletion lib/deck/version.rb
@@ -1,3 +1,3 @@
module Deck
VERSION = "0.5.0"
VERSION = "0.5.1"
end
34 changes: 19 additions & 15 deletions spec/slide_deck_spec.rb
Expand Up @@ -8,20 +8,25 @@ module Deck

include Files

def doc
@doc ||= begin
@html = deck_widget.to_html
noko_doc @html
end
end
let(:html) { deck_widget.to_html }
let(:doc) { noko_doc html }

def deck_widget options = {}
@deck_widget ||= SlideDeck.new options
end

def assert_html_like actual, expected
actual = actual.strip.gsub("\n\n", "\n")
expected = expected.strip.gsub("\n\n", "\n")
assert { actual == expected }
end

it "renders a basic deck.js HTML page" do
assert { doc }
assert { @html.include? '<link href="/deck.js/core/deck.core.css" rel="stylesheet" />' }
assert { html.include? '<link href="/deck.js/core/deck.core.css" rel="stylesheet" />' }
end

it "starts the deck script running" do
assert { html.include? "$.deck('.slide');" }
end

it "contains a single dummy slide" do
Expand All @@ -35,27 +40,26 @@ def deck_widget options = {}
assert { slides.size == 1 }
slide = slides.first
assert { slide["id"] == "hello" }
assert { noko_html(slide) == "<section class=\"slide\" id=\"hello\">" +
"<h1>hello</h1>\n" +
"</section>"
}

slide_html = noko_html(slide)
slide_html.gsub!("\n", "") # WTF Nokogiri inconsistently outputs newlines between Ruby 1.9 and 2.0
assert { slide_html == "<section class=\"slide\" id=\"hello\">" + "<h1>hello</h1>" + "</section>" }
end

it "includes a table of contents" do
deck_widget :slides => Slide.split("# Foo\n\n# Bar\n")
toc = doc.css('.slide_toc')
assert { toc.size == 1 }
assert { noko_html(toc.first) == "<div class=\"slide_toc\">" +
assert_html_like noko_html(toc.first), "<div class=\"slide_toc\">" +
"<div class=\"toggle\">[contents]</div>" +
"<div class=\"table\">" +
"<h2>deck.rb presentation</h2>" +
"<ul>" +
"<li><a href=\"#foo\">Foo</a></li>" +
"<li><a href=\"#bar\">Bar</a></li>" +
"</ul>" +
"</div>" +
"</div>"
"</div>"
}
end

describe "themes" do
Expand Down
19 changes: 13 additions & 6 deletions spec/slide_spec.rb
Expand Up @@ -6,6 +6,13 @@
module Deck
describe Slide do

def assert_html_like actual, expected
actual = actual.strip.gsub("\n\n", "\n")
expected = expected.strip.gsub("\n\n", "\n")
assert { actual == expected }
end


describe "classes" do
it "by default" do
assert {Slide.new.classes == ["slide"]}
Expand Down Expand Up @@ -246,7 +253,7 @@ def slide_from markdown_text
</ul>
</section>
HTML
assert { html == expected_html }
assert_html_like html, expected_html
end

it "with only a underline-style header, leaving a solo H1 as an H1" do
Expand All @@ -259,7 +266,7 @@ def slide_from markdown_text
<h1>foo</h1>
</section>
HTML
assert { html == expected_html }
assert_html_like html, expected_html
end

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

it "skips notes" do
Expand All @@ -291,7 +298,7 @@ def slide_from markdown_text
</section>
HTML

assert { slide_from(source).to_pretty == expected }
assert_html_like slide_from(source).to_pretty, expected
end

end
Expand All @@ -314,7 +321,7 @@ def slide_from markdown_text
</ul>
</section>
HTML
assert { html == expected_html }
assert_html_like html, expected_html
end
end

Expand All @@ -336,7 +343,7 @@ def slide_from markdown_text
</ul>
</section>
HTML
assert { html == expected_html }
assert_html_like html, expected_html
end
end

Expand Down

0 comments on commit 8253ccb

Please sign in to comment.