spec/lib/rake_spec.rb in rapidoc-0.0.6 vs spec/lib/rake_spec.rb in rapidoc-0.0.7

- old
+ new

@@ -11,29 +11,90 @@ end fake.string end describe Rake do - context 'rapidoc:generate' do + before :all do + Rake.application.rake_require "tasks/rapidoc" + Rake::Task.define_task(:environment) + end + + let :install_task do + Rake::Task["rapidoc:install"].reenable + Rake.application.invoke_task "rapidoc:install" + end + + let :generate_task do + Rake::Task["rapidoc:generate"].reenable + Rake.application.invoke_task "rapidoc:generate" + end + + let :clean_task do + Rake::Task["rapidoc:clean"].reenable + Rake.application.invoke_task "rapidoc:clean" + end + + context "rapidoc:install" do before do - Rake.application.rake_require "tasks/rapidoc" - Rake::Task.define_task(:environment) + install_task end - after do - remove_doc + after :all do + remove_structure end - let :run_rake_task do - Rake::Task["rapidoc:generate"].reenable - Rake.application.invoke_task "rapidoc:generate" + it "create directory and files" do + File.directory?("#{::Rails.root}/config/rapidoc").should be_true + File.directory?("#{::Rails.root}/config/rapidoc/examples").should be_true + File.exists?( "#{::Rails.root}/config/rapidoc/rapidoc.yml" ).should be_true end + end - it "should create documentation" do - output = capture_stdout { run_rake_task } - output.should be_include( 'Generating API documentation...' ) - output.should be_include( 'Completed API documentation generation' ) + context 'rapidoc:generate' do + context "when rapidoc is installed" do + before do + install_task + end - File.exists?( ::Rails.root.to_s + "/rapidoc/index.html" ).should == true + after :all do + remove_structure + end + + it "create documentation" do + output = capture_stdout { generate_task } + output.should be_include( 'Generating API documentation...' ) + output.should be_include( 'Completed API documentation generation' ) + File.exists?( "#{::Rails.root}/public/docs/index.html" ).should be_true + end + end + + context "when rapidoc is not installed" do + after :all do + remove_structure + end + + it "show a message with information" do + output = capture_stdout { generate_task } + output.should be_include( 'Need install rapidoc for run it, for install run rapidoc:install task' ) + File.exists?( "#{::Rails.root}/public/docs/index.html" ).should be_false + end + end + end + + context "rapidoc:clean" do + before do + install_task + capture_stdout { generate_task } + clean_task + end + + after :all do + remove_structure + end + + it "remove docs files" do + File.directory?("#{::Rails.root}/public/docs").should be_false + File.directory?("#{::Rails.root}/config/rapidoc").should be_true + File.exists?( "#{::Rails.root}/config/rapidoc/rapidoc.yml" ).should be_true end end end