spec/lib/action_doc_spec.rb in rapidoc-0.0.6 vs spec/lib/action_doc_spec.rb in rapidoc-0.0.7
- old
+ new
@@ -4,19 +4,20 @@
describe ActionDoc do
before :all do
@json_info = { "user" => { "name" => "Check", "apellido" => "Me" } }
- response_file = examples_dir "users_create_response.json"
- answer_file = examples_dir "users_create_request.json"
+ response_file = examples_dir "users/create_response.json"
+ answer_file = examples_dir "users/create_request.json"
reset_structure
+ create_folders_for_files([response_file, answer_file])
File.open( response_file, 'w') { |file| file.write @json_info.to_json }
File.open( answer_file, 'w') { |file| file.write @json_info.to_json }
- @info = {
- :resource=>"users",
+ @info = {
+ :resource=>"users",
:action=>"create",
:method=>"POST",
:urls=>["/users(.:format)"]
}
@@ -24,10 +25,11 @@
@controller_info = extractor.get_action_info( 'create' )
end
after :all do
remove_examples
+ remove_structure
end
context "when initialize ActionDoc" do
before :all do
@action_doc = ActionDoc.new( @info, @controller_info, examples_dir )
@@ -61,11 +63,11 @@
it "set correct requires authentication" do
@action_doc.authentication.should == false
end
it "set correct file" do
- @action_doc.file.should == @info[:resource].to_s + "_" + @info[:action].to_s
+ @action_doc.file.should == @info[:resource].to_s + "/" + @info[:action].to_s
end
it "set correct example_req" do
@action_doc.example_res.should == JSON.pretty_generate( @json_info )
end
@@ -173,10 +175,10 @@
end
end
context "when use config messages and descriptions" do
before :all do
- File.open( config_file_path, 'w') do |file|
+ File.open( config_file_path, 'w') do |file|
file.write "default_errors: true\n"
file.write "errors:\n"
file.write " required:\n message: \"m1\"\n description: \"d1\"\n"
file.write " inclusion:\n message: \"m2\"\n description: \"d2\"\n"
end