Skip to content

Commit

Permalink
Integrate RuboCop and RuboCop RSpec
Browse files Browse the repository at this point in the history
* add `rubocop` and `rubocop-rspec` dependencies to gemspec file.
* add `.rubocop.yml` config file
* fix all offenses reported
  • Loading branch information
avdv committed Aug 9, 2018
1 parent ca01a61 commit bbff802
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 20 deletions.
11 changes: 11 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require: rubocop-rspec

Metrics/LineLength:
Max: 100

Style/BlockComments:
Exclude:
- 'spec/spec_helper.rb'

Layout/EndOfLine:
EnforcedStyle: lf # enforce LF line endings on all platforms
5 changes: 4 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Gem::Tasks.new
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new

require 'rubocop/rake_task'
RuboCop::RakeTask.new

Rake::ExtensionTask.new 'clocale' do |ext|
ext.lib_dir = 'lib/clocale'
end
Expand All @@ -17,4 +20,4 @@ task test: %w[compile] do
end

task spec: :compile
task default: :spec
task default: %i[spec rubocop]
6 changes: 4 additions & 2 deletions clocale.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@ Gem::Specification.new do |spec|
spec.version = '0.0.3'
spec.authors = ['Claudio Bley']
spec.email = ['claudio.bley@gmail.com']
spec.summary = "A Ruby gem that wraps C locale functions."
spec.summary = 'A Ruby gem that wraps C locale functions.'
spec.homepage = 'https://github.com/avdv/clocale'
spec.license = 'MIT'

spec.extensions = %w[ext/clocale/extconf.rb]

spec.files = `git ls-files -z`.split("\x0").reject do |f|
f.match(%r{^.gitignore})
f.match(/^.gitignore/)
end

spec.add_development_dependency 'codecov', '~> 0.1.10'
spec.add_development_dependency 'rake', '~> 12.3'
spec.add_development_dependency 'rake-compiler', '~> 1.0'
spec.add_development_dependency 'rspec', '~> 3.7'
spec.add_development_dependency 'rubocop', '~> 0.58'
spec.add_development_dependency 'rubocop-rspec', '~> 1.27'
spec.add_development_dependency 'rubygems-tasks', '~> 0.2'
end
2 changes: 1 addition & 1 deletion ext/clocale/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

def check_functions
%w[setlocale strcoll strxfrm].each do |func|
abort "missing function `#{ func }``" unless have_func func
abort "missing function `#{func}``" unless have_func func
end
end

Expand Down
1 change: 0 additions & 1 deletion lib/clocale.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

require 'clocale/clocale'
17 changes: 17 additions & 0 deletions spec/c_locale_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'clocale'

RSpec.describe CLocale do
%i[LC_ALL LC_COLLATE LC_CTYPE LC_MONETARY LC_NUMERIC LC_TIME].each do |const|
it "has #{const} constant" do
is_expected.to(satisfy { |m| m.const_defined? const })
end
end

it 'can call setlocale' do
expect { described_class.setlocale(CLocale::LC_ALL, '') }.not_to raise_error
end

it 'raises an error with invalid locales' do
expect { described_class.setlocale(CLocale::LC_COLLATE, 'FOOBAR') }.to raise_error(RuntimeError)
end
end
15 changes: 0 additions & 15 deletions spec/clocale_spec.rb

This file was deleted.

0 comments on commit bbff802

Please # to comment.