Skip to content

Commit

Permalink
Merge pull request #6 from astratto/fix_filename
Browse files Browse the repository at this point in the history
Fix filename for partial HTML
  • Loading branch information
punkle committed Jan 25, 2016
2 parents 9d16917 + ee6a934 commit f5b06f8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/doc_my_routes/doc/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def initialize

@destination_dir = File.join(Dir.pwd, 'doc', 'api')
@format = :html
@partial = false

default_static_path = File.join(File.dirname(__FILE__), '..', '..',
'..', 'etc')
Expand All @@ -45,6 +46,7 @@ def format=(format = :html)
fail UnsupportedFormat,
"The output format must be :html or :partial_format. It is #{@format}" \
unless %i(html partial_html).include?(@format)
@partial = true
end

# Calculate the relative path of the CSS used
Expand All @@ -54,7 +56,8 @@ def destination_css
end

def index_file
File.join(@destination_dir, 'index.html')
filename = @partial ? 'index_partial.html' : 'index.html'
File.join(@destination_dir, filename)
end
end
end
Expand Down
6 changes: 5 additions & 1 deletion spec/system/output_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,21 @@ def doc_route
context 'when I run the generation' do
subject do
DocMyRoutes::Documentation.generate
Nokogiri::XML(File.open("#{tmp_dir}/index.html"))
Nokogiri::XML(File.open("#{tmp_dir}/#{output_file}.html"))
end

context 'using the default formatter' do
let(:output_file) { 'index' }

it 'generates a valid HTML file' do
expect(subject.children.size).to eq 2
expect(subject.children[1].name).to eq('html')
end
end

context 'using the :partial_html formatter' do
let(:output_file) { 'index_partial' }

before do
DocMyRoutes.configure do |c|
c.format = :partial_html
Expand Down

0 comments on commit f5b06f8

Please sign in to comment.