rapidoc 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,6 +7,10 @@ describe Rapidoc::Config do
7
7
  reset_structure
8
8
  end
9
9
 
10
+ after :all do
11
+ remove_structure
12
+ end
13
+
10
14
  it "config_dir returns correct dir" do
11
15
  config_dir().should eql( ::Rails.root.to_s + '/config/rapidoc' )
12
16
  end
@@ -50,7 +54,7 @@ describe Rapidoc::Config do
50
54
  it "controller_dir returns correct dir" do
51
55
  File.open( config_file_path, 'w') { |file| file.write "controllers_route: \"vim\"" }
52
56
  load_config
53
- controller_dir().should eql( ::Rails.root.to_s + '/vim' )
57
+ controller_dir().should eq("#{::Rails.root}/vim" )
54
58
  end
55
59
  end
56
60
  end
@@ -63,7 +67,7 @@ describe Rapidoc::Config do
63
67
  end
64
68
 
65
69
  it "returns correct route" do
66
- target_dir.should == ::Rails.root.to_s + "/vim"
70
+ target_dir.should eq("#{::Rails.root.to_s}/public/docs/vim")
67
71
  end
68
72
  end
69
73
 
@@ -74,7 +78,7 @@ describe Rapidoc::Config do
74
78
  end
75
79
 
76
80
  it "returns default route" do
77
- target_dir.should == ::Rails.root.to_s + "/rapidoc"
81
+ target_dir.should eq("#{::Rails.root}/public/docs")
78
82
  end
79
83
  end
80
84
 
@@ -128,7 +132,7 @@ describe Rapidoc::Config do
128
132
  end
129
133
 
130
134
  it "returns correct route" do
131
- actions_dir.should == ::Rails.root.to_s + "/vim/actions"
135
+ actions_dir.should eq("#{::Rails.root}/public/docs/vim/actions")
132
136
  end
133
137
  end
134
138
 
@@ -139,7 +143,7 @@ describe Rapidoc::Config do
139
143
  end
140
144
 
141
145
  it "returns default route" do
142
- actions_dir.should == ::Rails.root.to_s + "/rapidoc/actions"
146
+ actions_dir.should eq("#{::Rails.root.to_s}/public/docs/actions")
143
147
  end
144
148
  end
145
149
 
@@ -166,7 +170,7 @@ describe Rapidoc::Config do
166
170
  end
167
171
  context "when config file hasn't an example dir" do
168
172
  before do
169
- File.open("#{config_dir}/rapidoc.yml", 'w') { |file| file.write "" }
173
+ File.open("#{config_dir}/rapidoc.yml", 'w') { |file| file.write "" }
170
174
  load_config
171
175
  end
172
176
 
@@ -189,7 +193,7 @@ describe Rapidoc::Config do
189
193
 
190
194
  context "when config file has not resources_black_list" do
191
195
  it "returns empty array" do
192
- File.open("#{config_dir}/rapidoc.yml", 'w') { |file| file.write "" }
196
+ File.open("#{config_dir}/rapidoc.yml", 'w') { |file| file.write "" }
193
197
  load_config
194
198
  resources_black_list.should == []
195
199
  end
@@ -9,7 +9,9 @@ describe ControllerExtractor do
9
9
  @extractor = ControllerExtractor.new "users_controller.rb"
10
10
  end
11
11
 
12
- context
12
+ after :all do
13
+ remove_structure
14
+ end
13
15
 
14
16
  context "when call get_actions_info function" do
15
17
  before :all do
@@ -85,6 +87,7 @@ describe ControllerExtractor do
85
87
 
86
88
  context "when use custom controllers route" do
87
89
  it "use .yml extension for controllers files" do
90
+ create_config_structure
88
91
  File.open( config_file_path, 'w') { |file| file.write "controllers_route: \"vim\"" }
89
92
  load_config
90
93
 
@@ -25,7 +25,7 @@ describe "When check HttpResponse class" do
25
25
  context "when check get_description function" do
26
26
  before do
27
27
  @codes = [ 200, 201, 401, 404, 422, 403, 409 ]
28
- @descriptions = [ 'OK', 'Created', 'Unauthorized', 'Not found',
28
+ @descriptions = [ 'OK', 'Created', 'Access Denied', 'Not found',
29
29
  'Unprocessable Entity', 'Forbidden', '' ]
30
30
  end
31
31
 
@@ -31,6 +31,7 @@ describe ParamErrors do
31
31
 
32
32
  context "when use config messaes and descriptions" do
33
33
  before :all do
34
+ create_config_structure
34
35
 
35
36
  File.open( config_file_path, 'w') do |file|
36
37
  file.write "default_errors: true\n"
@@ -42,6 +43,10 @@ describe ParamErrors do
42
43
  load_config
43
44
  end
44
45
 
46
+ after :all do
47
+ remove_config
48
+ end
49
+
45
50
  context "when call get_required_error_info" do
46
51
  it "return correct error info" do
47
52
  info = get_required_error_info( 'name' )
@@ -13,27 +13,88 @@ def capture_stdout(&block)
13
13
  end
14
14
 
15
15
  describe Rake do
16
- context 'rapidoc:generate' do
16
+ before :all do
17
+ Rake.application.rake_require "tasks/rapidoc"
18
+ Rake::Task.define_task(:environment)
19
+ end
20
+
21
+ let :install_task do
22
+ Rake::Task["rapidoc:install"].reenable
23
+ Rake.application.invoke_task "rapidoc:install"
24
+ end
25
+
26
+ let :generate_task do
27
+ Rake::Task["rapidoc:generate"].reenable
28
+ Rake.application.invoke_task "rapidoc:generate"
29
+ end
30
+
31
+ let :clean_task do
32
+ Rake::Task["rapidoc:clean"].reenable
33
+ Rake.application.invoke_task "rapidoc:clean"
34
+ end
35
+
36
+ context "rapidoc:install" do
17
37
  before do
18
- Rake.application.rake_require "tasks/rapidoc"
19
- Rake::Task.define_task(:environment)
38
+ install_task
20
39
  end
21
40
 
22
- after do
23
- remove_doc
41
+ after :all do
42
+ remove_structure
24
43
  end
25
44
 
26
- let :run_rake_task do
27
- Rake::Task["rapidoc:generate"].reenable
28
- Rake.application.invoke_task "rapidoc:generate"
45
+ it "create directory and files" do
46
+ File.directory?("#{::Rails.root}/config/rapidoc").should be_true
47
+ File.directory?("#{::Rails.root}/config/rapidoc/examples").should be_true
48
+ File.exists?( "#{::Rails.root}/config/rapidoc/rapidoc.yml" ).should be_true
29
49
  end
50
+ end
51
+
52
+ context 'rapidoc:generate' do
53
+ context "when rapidoc is installed" do
54
+ before do
55
+ install_task
56
+ end
30
57
 
31
- it "should create documentation" do
32
- output = capture_stdout { run_rake_task }
33
- output.should be_include( 'Generating API documentation...' )
34
- output.should be_include( 'Completed API documentation generation' )
58
+ after :all do
59
+ remove_structure
60
+ end
61
+
62
+ it "create documentation" do
63
+ output = capture_stdout { generate_task }
64
+ output.should be_include( 'Generating API documentation...' )
65
+ output.should be_include( 'Completed API documentation generation' )
66
+ File.exists?( "#{::Rails.root}/public/docs/index.html" ).should be_true
67
+ end
68
+ end
69
+
70
+ context "when rapidoc is not installed" do
71
+ after :all do
72
+ remove_structure
73
+ end
74
+
75
+ it "show a message with information" do
76
+ output = capture_stdout { generate_task }
77
+ output.should be_include( 'Need install rapidoc for run it, for install run rapidoc:install task' )
78
+ File.exists?( "#{::Rails.root}/public/docs/index.html" ).should be_false
79
+ end
80
+ end
81
+ end
82
+
83
+ context "rapidoc:clean" do
84
+ before do
85
+ install_task
86
+ capture_stdout { generate_task }
87
+ clean_task
88
+ end
89
+
90
+ after :all do
91
+ remove_structure
92
+ end
35
93
 
36
- File.exists?( ::Rails.root.to_s + "/rapidoc/index.html" ).should == true
94
+ it "remove docs files" do
95
+ File.directory?("#{::Rails.root}/public/docs").should be_false
96
+ File.directory?("#{::Rails.root}/config/rapidoc").should be_true
97
+ File.exists?( "#{::Rails.root}/config/rapidoc/rapidoc.yml" ).should be_true
37
98
  end
38
99
  end
39
100
  end
@@ -3,58 +3,53 @@ require "spec_helper"
3
3
  include Rapidoc
4
4
 
5
5
  describe Rapidoc do
6
-
7
- context "when all is ok" do
8
- before :all do
9
- create_structure
10
- load_config
6
+ context "when is installing rapidoc" do
7
+ before do
8
+ create_config_structure
11
9
  end
12
10
 
13
- after :all do
14
- remove_doc
15
- end
11
+ it { File.directory?("#{::Rails.root}/config/rapidoc").should be_true }
12
+ it { File.directory?("#{::Rails.root}/config/rapidoc/examples").should be_true }
13
+ it { File.exists?(config_dir("rapidoc.yml")).should be_true }
14
+ end
16
15
 
17
- context "when create estructure" do
18
- it "should create config files" do
19
- File.exists?( config_dir( "rapidoc.yml" ) ).should == true
16
+ context "when is generating the doc" do
17
+ context "with a default doc_routes" do
18
+ before do
19
+ create_doc_structure
20
+ generate_doc
20
21
  end
21
22
 
22
- it "should create target dir" do
23
- File.directory?( target_dir ).should == true
23
+ after :all do
24
+ remove_doc
24
25
  end
25
26
 
26
- it "should create example dir" do
27
- File.directory?( examples_dir ).should == true
28
- end
27
+ it { File.directory?("#{::Rails.root}/public/docs").should be_true }
28
+ it { File.directory?("#{::Rails.root}/public/docs/actions").should be_true }
29
+ it { File.directory?("#{::Rails.root}/public/docs/assets").should be_true }
30
+ it { File.exists?("#{::Rails.root}/public/docs/index.html").should be_true }
29
31
  end
30
32
 
31
- context "when executing genarate_doc function" do
33
+ context "with a diferent doc_route" do
32
34
  before do
35
+ File.open( config_file_path, 'w') { |file| file.write "doc_route: api/v1" }
36
+ load_config
37
+ create_doc_structure
33
38
  generate_doc
34
39
  end
35
40
 
36
- it "should create new index.html file" do
37
- File.exists?( ::Rails.root.to_s + "/rapidoc/index.html" ).should == true
41
+ after :all do
42
+ remove_doc
38
43
  end
39
- end
40
- end
41
-
42
- context "when there is an error" do
43
- before :all do
44
- create_structure
45
-
46
- File.open( config_file_path, 'w') { |file| file.write "controllers_route: \"public\"" }
47
- load_config
48
44
 
49
- controller = controller_dir 'users_controller.yml'
50
- File.open( controller, 'w' ) { |file|
51
- file.write "# =begin action\nhttp_status:\n - 201\n #params:\n - name: 'name'\n# =end\n"
52
- }
53
-
54
- generate_doc
45
+ it { File.directory?("#{::Rails.root.to_s}/public/docs/api/v1").should be_true }
46
+ it { File.directory?("#{::Rails.root.to_s}/public/docs/api/v1/actions").should be_true }
47
+ it { File.directory?("#{::Rails.root.to_s}/public/docs/api/v1/assets").should be_true }
48
+ it { File.exists?("#{::Rails.root.to_s}/public/docs/api/v1/index.html").should be_true }
55
49
  end
50
+ end
56
51
 
57
- it "should return error" do
58
- end
52
+ after :all do
53
+ remove_structure
59
54
  end
60
55
  end
@@ -10,6 +10,10 @@ describe ResourceDoc do
10
10
  @routes_actions_info = get_routes_doc.get_actions_route_info( :users )
11
11
  end
12
12
 
13
+ after :all do
14
+ remove_structure
15
+ end
16
+
13
17
  context "when create new valid instance only with resource name" do
14
18
  before do
15
19
  @resource_name = "users"
@@ -29,7 +33,7 @@ describe ResourceDoc do
29
33
  end
30
34
 
31
35
  it "returns name without '/'" do
32
- @rdoc.simple_name.should == "OneTwo"
36
+ @rdoc.simple_name.should == "Two"
33
37
  end
34
38
  end
35
39
 
@@ -87,6 +87,8 @@ describe Rapidoc::ResourcesExtractor do
87
87
 
88
88
  context "when config has resources_black_list" do
89
89
  before do
90
+ create_config_structure
91
+
90
92
  File.open("#{config_dir}/rapidoc.yml", 'w') do |file|
91
93
  file.write "resources_black_list: images, albums"
92
94
  end
@@ -94,6 +96,10 @@ describe Rapidoc::ResourcesExtractor do
94
96
  load_config
95
97
  end
96
98
 
99
+ after :all do
100
+ remove_config
101
+ end
102
+
97
103
  it "returns correct resources names" do
98
104
  names = get_resources.map(&:name)
99
105
  names.should_not be_include( "images" )
@@ -10,7 +10,7 @@ describe TemplatesGenerator do
10
10
  end
11
11
 
12
12
  after do
13
- #remove_doc
13
+ remove_structure
14
14
  end
15
15
 
16
16
  context "when call generate_index_template" do
@@ -37,7 +37,7 @@ describe TemplatesGenerator do
37
37
  @resources.each do |resource|
38
38
  resource.actions_doc.each do |action_doc|
39
39
  if action_doc.has_controller_info
40
- route = actions_dir + "/#{resource.name}_#{action_doc.action}.html"
40
+ route = actions_dir + "/#{resource.name}/#{action_doc.action}.html"
41
41
  File.exists?( route ).should == true
42
42
  end
43
43
  end
@@ -53,14 +53,15 @@ describe TemplatesGenerator do
53
53
  info = resource_info.group_by{ |entrie| entrie[:action] }['create'].first
54
54
  controller_info = extractor.get_action_info( 'create' )
55
55
  @action_doc = ActionDoc.new( info, controller_info, examples_dir )
56
-
56
+
57
57
  create_action_template( get_action_template, @action_doc )
58
58
  end
59
59
 
60
60
  it "should create new action html file" do
61
- route = actions_dir + "/#{@action_doc.resource}_#{@action_doc.action}.html"
61
+ route = actions_dir + "/#{@action_doc.resource}/#{@action_doc.action}.html"
62
62
  File.exists?( route ).should == true
63
63
  end
64
+
64
65
  end
65
66
 
66
67
  context "when call get_action_template function" do
metadata CHANGED
@@ -1,68 +1,60 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rapidoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
5
- prerelease:
4
+ version: 0.0.7
6
5
  platform: ruby
7
6
  authors:
8
- - Rafael Jurado
7
+ - Rafael Jurado, Harold Rangel, Luis Rodriguez
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-06 00:00:00.000000000 Z
11
+ date: 2014-03-05 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
- version: 3.2.0
19
+ version: '3.2'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
- version: 3.2.0
26
+ version: '3.2'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: handlebars
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: 0.4.0
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: 0.4.0
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec-rails
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: sqlite3
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ~>
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ~>
76
67
  - !ruby/object:Gem::Version
@@ -78,43 +69,40 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: capybara
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: rack
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - '>='
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - '>='
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  description: Generates REST API documentation.
111
98
  email:
112
- - rjurado@nosolosoftware.biz
99
+ - rjurado@openmailbox.org, aarold.rangel@koombea.com, luis.rodriguez@koombea.com
113
100
  executables: []
114
101
  extensions: []
115
102
  extra_rdoc_files: []
116
103
  files:
117
104
  - .gitignore
105
+ - .rspec
118
106
  - Gemfile
119
107
  - LICENSE.txt
120
108
  - README.rdoc
@@ -210,35 +198,29 @@ files:
210
198
  - spec/lib/templates_generator_spec.rb
211
199
  - spec/lib/yaml_parser_spec.rb
212
200
  - spec/spec_helper.rb
213
- homepage: https://github.com/drinor/rapidoc.git
214
- licenses: []
201
+ homepage: https://github.com/drinor/rapidoc
202
+ licenses:
203
+ - MIT
204
+ metadata: {}
215
205
  post_install_message:
216
206
  rdoc_options: []
217
207
  require_paths:
218
208
  - lib
219
209
  required_ruby_version: !ruby/object:Gem::Requirement
220
- none: false
221
210
  requirements:
222
- - - ! '>='
211
+ - - '>='
223
212
  - !ruby/object:Gem::Version
224
213
  version: '0'
225
- segments:
226
- - 0
227
- hash: -3398396139760812886
228
214
  required_rubygems_version: !ruby/object:Gem::Requirement
229
- none: false
230
215
  requirements:
231
- - - ! '>='
216
+ - - '>='
232
217
  - !ruby/object:Gem::Version
233
218
  version: '0'
234
- segments:
235
- - 0
236
- hash: -3398396139760812886
237
219
  requirements: []
238
220
  rubyforge_project:
239
- rubygems_version: 1.8.25
221
+ rubygems_version: 2.2.2
240
222
  signing_key:
241
- specification_version: 3
223
+ specification_version: 4
242
224
  summary: Generates REST API documentation.
243
225
  test_files:
244
226
  - spec/dummy/.gitignore