spec/lib/rapidoc_spec.rb in rapidoc-0.0.5 vs spec/lib/rapidoc_spec.rb in rapidoc-0.0.6

- old
+ new

@@ -2,38 +2,59 @@ include Rapidoc describe Rapidoc do - before :all do - create_structure - load_config - end + context "when all is ok" do + before :all do + create_structure + load_config + end - after :all do - remove_doc - end - - context "when create estructure" do - it "should create config files" do - File.exists?( config_dir( "rapidoc.yml" ) ).should == true + after :all do + remove_doc end - it "should create target dir" do - File.directory?( target_dir ).should == true + context "when create estructure" do + it "should create config files" do + File.exists?( config_dir( "rapidoc.yml" ) ).should == true + end + + it "should create target dir" do + File.directory?( target_dir ).should == true + end + + it "should create example dir" do + File.directory?( examples_dir ).should == true + end end - it "should create example dir" do - File.directory?( examples_dir ).should == true + context "when executing genarate_doc function" do + before do + generate_doc + end + + it "should create new index.html file" do + File.exists?( ::Rails.root.to_s + "/rapidoc/index.html" ).should == true + end end end - context "when executing genarate_doc function" do - before do + context "when there is an error" do + before :all do + create_structure + + File.open( config_file_path, 'w') { |file| file.write "controllers_route: \"public\"" } + load_config + + controller = controller_dir 'users_controller.yml' + File.open( controller, 'w' ) { |file| + file.write "# =begin action\nhttp_status:\n - 201\n #params:\n - name: 'name'\n# =end\n" + } + generate_doc end - it "should create new index.html file" do - File.exists?( ::Rails.root.to_s + "/rapidoc/index.html" ).should == true + it "should return error" do end end end