Skip to content

Commit

Permalink
Merge pull request #41 from mataki/support_multibyte_description
Browse files Browse the repository at this point in the history
Support multibyte description
  • Loading branch information
oestrich committed Jul 11, 2012
2 parents ae36304 + c21408f commit 7fb5e93
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/rspec_api_documentation/html_writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def dirname

def filename
basename = description.downcase.gsub(/\s+/, '_').gsub(/[^a-z_]/, '')
basename = Digest::MD5.new.update(description).to_s if basename.blank?
"#{basename}.html"
end

Expand Down
23 changes: 23 additions & 0 deletions spec/html_writer_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
require 'spec_helper'

describe RspecApiDocumentation::HtmlWriter do
Expand Down Expand Up @@ -31,3 +32,25 @@
end
end
end

describe RspecApiDocumentation::HtmlExample do
let(:metadata) { {} }
let(:group) { RSpec::Core::ExampleGroup.describe("Orders", metadata) }
let(:example) { group.example("Ordering a cup of coffee") {} }
let(:configuration) { RspecApiDocumentation::Configuration.new }
let(:html_example) { described_class.new(example, configuration) }

it "should have downcased filename" do
html_example.filename.should == "ordering_a_cup_of_coffee.html"
end

describe "multi charctor example name" do
let(:label) { "コーヒーが順番で並んでいること" }
let(:example) { group.example(label) {} }

it "should have downcased filename" do
filename = Digest::MD5.new.update(label).to_s
html_example.filename.should == filename + ".html"
end
end
end

0 comments on commit 7fb5e93

Please sign in to comment.