Skip to content
This repository was archived by the owner on Apr 6, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions keydown.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Gem::Specification.new do |s|
s.add_dependency 'sass'
s.add_dependency 'compass'
s.add_dependency 'github-markdown'
s.add_dependency 'launchy'

s.add_development_dependency "rake"
s.add_development_dependency "rspec"
Expand Down
1 change: 1 addition & 0 deletions lib/keydown.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'ostruct'
require 'digest/sha1'
require 'tilt'
require 'launchy'

require 'version'
require 'keydown/html_helpers'
Expand Down
7 changes: 4 additions & 3 deletions lib/keydown/tasks/slides.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class Tasks < Thor
desc "slides FILE", "Convert a Keydown FILE into an HTML presentation"

def slides(file)

file += '.md' unless file.match(/\.md$/)

unless File.exist?(file)
Expand Down Expand Up @@ -36,9 +35,11 @@ def slides(file)

presentation = file.gsub('md', 'html')

create_file presentation, :force => true do
output = create_file presentation, :force => true do
slide_deck.to_html
end

Launchy.open File.join(Dir.pwd, presentation)
end
end
end
end
6 changes: 6 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ def capture_output
ensure
$stdout = STDOUT
end

RSpec.configure do |config|
config.before(:each) do
Launchy.stub(:open)
end
end
12 changes: 11 additions & 1 deletion spec/tasks/slides_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
end

let :tmp_dir do
"#{Dir.tmpdir}/keydown_test"
"#{File.realdirpath(Dir.tmpdir)}/keydown_test"
end

let :project_dir do
Expand Down Expand Up @@ -64,6 +64,16 @@
system "cp -r spec/fixtures/with_title.md #{project_dir}"
end

it "should open resulting html file in the browser" do
Launchy.should_receive(:open).with("#{project_dir}/with_title.html")

capture_output do
Dir.chdir project_dir do
@thor.invoke Keydown::Tasks, ["slides", "with_title.md"]
end
end
end

describe "should generate an html file that" do
before(:each) do
capture_output do
Expand Down