Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that all locale files have been imported before prepare #3

Merged
merged 1 commit into from
Sep 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/semmy/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ def version
VersionFile.parse_version(File.read(version_file))
end

def has_not_yet_imported_locales?
Dir.glob('config/locales/new/**/*.yml').any?
end

private

def version_file
Expand Down
11 changes: 10 additions & 1 deletion lib/semmy/tasks/lint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Semmy
module Tasks
class Lint < Base
def define
task 'lint' => ['lint:install']
task 'lint' => ['lint:install', 'lint:locales']

namespace 'lint' do
task 'install' do
Expand All @@ -15,6 +15,15 @@ def define
exit(1)
end
end

task 'locales' do
Shell.info('Checking for not yet imported locales.')

if Project.has_not_yet_imported_locales?
Shell.error('There are still files in config/locales/new.')
exit(1)
end
end
end
end
end
Expand Down
22 changes: 22 additions & 0 deletions spec/semmy/project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,27 @@ module Semmy
expect(result).to eq('2.1.0.alpha')
end
end

describe '.has_not_yet_imported_locales?' do
it 'returns false if no config/locales/new/ direcotry is present' do
result = Project.has_not_yet_imported_locales?

expect(result).to eq(false)
end

it 'returns true if config/locales/new/ files are present' do
Fixtures.file('config/locales/new/some.yml')
result = Project.has_not_yet_imported_locales?

expect(result).to eq(true)
end

it 'returns false if only a .gitkeep is present' do
Fixtures.file('config/locales/new/.gitkeep')
result = Project.has_not_yet_imported_locales?

expect(result).to eq(false)
end
end
end
end
20 changes: 20 additions & 0 deletions spec/semmy/tasks/lint_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@ module Tasks
}.to raise_error(SystemExit)
end
end

describe 'locales task' do
it 'returns false if no config/locales/new/ direcotry is present' do
Lint.new

expect {
Rake.application['lint:locales'].invoke
}.not_to raise_error
end

it 'returns true if config/locales/new/ files are present' do
Fixtures.file('config/locales/new/some.yml')

Lint.new

expect {
Rake.application['lint:locales'].invoke
}.to raise_error(SystemExit)
end
end
end
end
end