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

- old
+ new

@@ -1,60 +1,55 @@ require "spec_helper" include Rapidoc describe Rapidoc do - - context "when all is ok" do - before :all do - create_structure - load_config + context "when is installing rapidoc" do + before do + create_config_structure end - after :all do - remove_doc - end + it { File.directory?("#{::Rails.root}/config/rapidoc").should be_true } + it { File.directory?("#{::Rails.root}/config/rapidoc/examples").should be_true } + it { File.exists?(config_dir("rapidoc.yml")).should be_true } + end - context "when create estructure" do - it "should create config files" do - File.exists?( config_dir( "rapidoc.yml" ) ).should == true + context "when is generating the doc" do + context "with a default doc_routes" do + before do + create_doc_structure + generate_doc end - it "should create target dir" do - File.directory?( target_dir ).should == true + after :all do + remove_doc end - it "should create example dir" do - File.directory?( examples_dir ).should == true - end + it { File.directory?("#{::Rails.root}/public/docs").should be_true } + it { File.directory?("#{::Rails.root}/public/docs/actions").should be_true } + it { File.directory?("#{::Rails.root}/public/docs/assets").should be_true } + it { File.exists?("#{::Rails.root}/public/docs/index.html").should be_true } end - context "when executing genarate_doc function" do + context "with a diferent doc_route" do before do + File.open( config_file_path, 'w') { |file| file.write "doc_route: api/v1" } + load_config + create_doc_structure generate_doc end - it "should create new index.html file" do - File.exists?( ::Rails.root.to_s + "/rapidoc/index.html" ).should == true + after :all do + remove_doc end + + it { File.directory?("#{::Rails.root.to_s}/public/docs/api/v1").should be_true } + it { File.directory?("#{::Rails.root.to_s}/public/docs/api/v1/actions").should be_true } + it { File.directory?("#{::Rails.root.to_s}/public/docs/api/v1/assets").should be_true } + it { File.exists?("#{::Rails.root.to_s}/public/docs/api/v1/index.html").should be_true } end end - 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 return error" do - end + after :all do + remove_structure end end