Skip to content

Commit

Permalink
Rake task for specs, capturing output of all tasks to make tests pretty
Browse files Browse the repository at this point in the history
  • Loading branch information
Davis W. Frank committed May 3, 2011
1 parent 46bcbd2 commit c3ec636
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 23 deletions.
7 changes: 7 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
require 'bundler'
Bundler::GemHelper.install_tasks

desc "Run all specs"
task :spec do
system("rspec spec")
end

task :default => :spec
3 changes: 0 additions & 3 deletions spec/spec.opts

This file was deleted.

8 changes: 5 additions & 3 deletions spec/tasks/generate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
FileUtils.rm_r @tmp_dir if File.exists?(@tmp_dir)
FileUtils.mkdir_p @tmp_dir

@thor = Thor.new
@thor = Thor.new
end

describe "generate command" do
before :each do
Dir.chdir @tmp_dir do
@thor.invoke Keydown::Tasks, "generate", "sample"
capture_output do
Dir.chdir @tmp_dir do
@thor.invoke Keydown::Tasks, "generate", "sample"
end
end
end

Expand Down
44 changes: 27 additions & 17 deletions spec/tasks/slides_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
FileUtils.rm_r @tmp_dir if File.exists?(@tmp_dir)
FileUtils.mkdir_p @tmp_dir

@thor = Thor.new
@thor = Thor.new
end

describe "when file cannot be found" do
Expand Down Expand Up @@ -61,10 +61,12 @@

describe "should generate an html file that" do
before(:each) do
Dir.chdir @tmp_dir do
@thor.invoke Keydown::Tasks, "slides", "with_title.md"
@file = File.new('with_title.html')
@doc = Nokogiri(@file)
capture_output do
Dir.chdir @tmp_dir do
@thor.invoke Keydown::Tasks, "slides", "with_title.md"
@file = File.new('with_title.html')
@doc = Nokogiri(@file)
end
end
end

Expand All @@ -88,10 +90,12 @@

describe "should add an .md extention if one isn't specified" do
before(:each) do
Dir.chdir @tmp_dir do
@thor.invoke Keydown::Tasks, "slides", "with_title"
@file = File.new('with_title.html')
@doc = Nokogiri(@file)
capture_output do
Dir.chdir @tmp_dir do
@thor.invoke Keydown::Tasks, "slides", "with_title"
@file = File.new('with_title.html')
@doc = Nokogiri(@file)
end
end
end

Expand All @@ -102,6 +106,8 @@

describe "with directory tree with custom CSS & JS" do
before(:each) do
capture_output do

Dir.chdir @tmp_dir do
@thor.invoke Keydown::Tasks, "generate", "test"

Expand All @@ -113,9 +119,10 @@
@thor.invoke Keydown::Tasks, "slides", "with_title.md"

@file = File.new('with_title.html')
@doc = Nokogiri(@file)
@doc = Nokogiri(@file)
end
end
end
end

it_should_behave_like "generating a presentation file"
Expand All @@ -133,16 +140,19 @@

describe "for a presentation that has background images" do
before(:each) do
Dir.chdir @tmp_dir do
@thor.invoke Keydown::Tasks, "generate", "test"
capture_output do

Dir.chdir "test" do
system "cp #{Keydown::Tasks.source_root}/spec/fixtures/with_backgrounds.md #{@tmp_dir}/test/with_backgrounds.md"
Dir.chdir @tmp_dir do
@thor.invoke Keydown::Tasks, "generate", "test"

Dir.chdir "test" do
system "cp #{Keydown::Tasks.source_root}/spec/fixtures/with_backgrounds.md #{@tmp_dir}/test/with_backgrounds.md"

@thor.invoke Keydown::Tasks, "slides", "with_backgrounds.md"
@thor.invoke Keydown::Tasks, "slides", "with_backgrounds.md"

@file = File.new('with_backgrounds.html')
@doc = Nokogiri(@file)
@file = File.new('with_backgrounds.html')
@doc = Nokogiri(@file)
end
end
end
end
Expand Down

0 comments on commit c3ec636

Please sign in to comment.