Skip to content

Commit

Permalink
add multi yaml test
Browse files Browse the repository at this point in the history
  • Loading branch information
onigra committed Dec 16, 2015
1 parent 6509424 commit 127fa7c
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions spec/planaria/generator/builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,82 @@
end

context "en.yml, ja.yml" do
let(:project_name) { "i18n" }
let(:en_name) { "en" }
let(:ja_name) { "ja" }

let(:en_html) do
<<-EOS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>#{en_name}</title>
<link rel="stylesheet" type="text/css" media="screen" href="css/#{project_name}.css" >
<script type="text/javascript" src="js/#{project_name}.js" ></script>
</head>
<body>
<h1>FIXME</h1>
</body>
<footer>
</footer>
</html>
EOS
end

let(:ja_html) do
<<-EOS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>#{ja_name}</title>
<link rel="stylesheet" type="text/css" media="screen" href="css/#{project_name}.css" >
<script type="text/javascript" src="js/#{project_name}.js" ></script>
</head>
<body>
<h1>FIXME</h1>
</body>
<footer>
</footer>
</html>
EOS
end

before do
Planaria::Generator::Initializer.new(project_name).run
FileUtils.rm("#{APP_ROOT}/#{project_name}/yamls/base.yml")

File.open "#{APP_ROOT}/#{project_name}/yamls/en.yml", "w" do |file|
file.write "title: #{en_name}"
end

File.open "#{APP_ROOT}/#{project_name}/yamls/ja.yml", "w" do |file|
file.write "title: #{ja_name}"
end

Planaria::Generator::Builder.new(project_name).run
end

after { FileUtils.remove_dir "#{APP_ROOT}/#{project_name}", force: true }

it "exists two files" do
aggregate_failures do
expect(File.exist?("#{APP_ROOT}/#{project_name}/en.html")).to be_truthy
expect(File.exist?("#{APP_ROOT}/#{project_name}/ja.html")).to be_truthy
end
end

it "title is different" do
aggregate_failures do
expect(File.read "#{APP_ROOT}/#{project_name}/ja.html").to eq ja_html
expect(File.read "#{APP_ROOT}/#{project_name}/en.html").to eq en_html
end
end
end
end
end

0 comments on commit 127fa7c

Please sign in to comment.