Skip to content

Commit

Permalink
Run tests only once, fix formatting for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
denvazh committed Aug 29, 2017
1 parent ffa3496 commit 56df912
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 30 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ rdoc
spec/reports
test/tmp
test/version_tmp
vendor/bundle
tmp

# Intellij IDEA
Expand Down
3 changes: 2 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ AllCops:
Exclude:
- spec/**/*
- exe/*
- vendor/bundle/**/*

#inherit_from: .rubocop_todo.yml

Style/FileName:
Enabled: false
Enabled: false
8 changes: 2 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ require 'rspec/core/rake_task'
require 'rubocop/rake_task'
require 'yard'

RSpec::Core::RakeTask.new
task test: :spec

# Testing with rspec
RSpec::Core::RakeTask.new(:spec) do |task|
task.rspec_opts = %w[--color --format documentation]
Expand All @@ -15,8 +12,7 @@ task test: :spec
# Use RuboCop to check for code/style offenses
desc 'Run RuboCop to validate/lint code'
RuboCop::RakeTask.new(:rubocop) do |task|
# don't abort rake on failure
task.fail_on_error = false
task.fail_on_error = false # don't abort rake on failure
end

# Documentation
Expand All @@ -28,4 +24,4 @@ end
task doc: :yard

# Default Rake task
task default: [:rubocop, :spec]
task default: %i[rubocop spec]
3 changes: 1 addition & 2 deletions faker_japanese.gemspec
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8

lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'faker_japanese/version'
Expand All @@ -11,7 +12,6 @@ Gem::Specification.new do |spec|
spec.description = 'Faker extension providing japanese names'
spec.summary = 'Faker extension for japanese names'
spec.license = 'MIT'

spec.bindir = 'exe'
spec.files = `git ls-files -z`.split("\x0").reject do |f|
f.match(%r{^(test|spec|features)/})
Expand All @@ -32,6 +32,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'fuubar'
spec.add_development_dependency 'coveralls'
spec.add_development_dependency 'rubocop'

spec.add_runtime_dependency 'faker'
end
2 changes: 1 addition & 1 deletion lib/faker_japanese.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class << self
# Use callback to store loaded data when subclass is created
# @param [Class] klass class name
def inherited(klass)
fail("#{klass} should be Class") unless klass.is_a? Class
raise("#{klass} should be Class") unless klass.is_a?(Class)
klass.class_variable_set '@@data', load_data(klass)
end

Expand Down
25 changes: 5 additions & 20 deletions spec/lib/faker_japanese_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@

describe Faker::Japanese do
context 'when locale is NOT set to :ja' do

before(:all) {
Faker::Config.locale = :en
}

after(:all) {
Faker::Config.locale = :en
}
before(:all) { Faker::Config.locale = :en }
after(:all) { Faker::Config.locale = :en }

it 'uses default locale' do
expect(Faker::Config.locale).to eq(:en)
Expand Down Expand Up @@ -44,14 +38,8 @@
end

context 'when locale is set to ja' do

before(:all) {
Faker::Config.locale = :ja
}

after(:all) {
Faker::Config.locale = :en
}
before(:all) { Faker::Config.locale = :ja }
after(:all) { Faker::Config.locale = :en }

it 'uses japanese locale :ja' do
expect(Faker::Config.locale).to eq(:ja)
Expand All @@ -64,9 +52,7 @@
expect(name).not_to be_nil
expect(name.ascii_only?).to be_falsey
expect(name.contains_cjk?).to be_truthy
[:yomi, :kana, :romaji].each do |method|
expect(name.respond_to?(method)).to be_truthy
end
%i[yomi kana romaji].each { |method| expect(name.respond_to?(method)).to be_truthy }
expect(name.yomi.contains_cjk?).to be_truthy
expect(name.kana.contains_cjk?).to be_truthy
expect(name.romaji.contains_cjk?).to be_falsey
Expand All @@ -85,7 +71,6 @@
expect(last_name.ascii_only?).to be_falsey
expect(last_name.contains_cjk?).to be_truthy
end

end
end
end

0 comments on commit 56df912

Please sign in to comment.