enumerate_it 1.7.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d4ae76c51d155d1805ae3f30687471dcde4354e7e28a0b5b4a67c1fec61833a
4
- data.tar.gz: b2ffcc7e088b1a77b8c8002c923ae8e6283557d179eb03e1ebe4cc183e6d9293
3
+ metadata.gz: ea808ecb79d456eee5cfc618c6ee340415023e369c3cd2e454dc757b113109bb
4
+ data.tar.gz: cd92b32d4dedb4b58fea015a789acec4f9a8283f61b89b18a0f871c738ff9446
5
5
  SHA512:
6
- metadata.gz: 3f78959342d203d10c9a21d00472292d08c291da985e1b37c8bf5fa91fb8d5b960d5c2bcea660e61bbae57ee1638070abcb63e1359311f07168caa753256a637
7
- data.tar.gz: b78fbe58f60eba4819056e81d49d7a31dc286051a6255e4b1a9bad9939be55aa13e98db2c19a8e59df93490e269ce86dbf6a5a9384aa0b1d13a8d680acd43681
6
+ metadata.gz: c4bf5dcd952944079438c35ac0ba80100b7283a003b6a80910965c3d9bc746645c06cf61547ebd5621a7bd4e5e295ee14d9bab8f7b63958f77abef1f11afc111
7
+ data.tar.gz: 11cea26f79cb273b9f77cf800d9759067a3731e83caaeb20ac5958a824cf3f3152a71c4d438337dc41a2f61e6be2157f9b709d72debcbcb4f1a6840c85a7b73a
data/.ci/prepare ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ RUBY_GEMS_VERSION = RUBY_VERSION >= '2.6.0' ? '' : '2.7.8'
4
+ BUNDLER_VERSION = RUBY_VERSION >= '2.6.0' ? '>= 2' : '> 2'
5
+
6
+ system("gem update --system '#{RUBY_GEMS_VERSION}'")
7
+ system("gem install bundler -v '#{BUNDLER_VERSION}'")
data/.rubocop.yml CHANGED
@@ -1,12 +1,13 @@
1
1
  require: rubocop-rspec
2
2
 
3
+ inherit_mode:
4
+ merge:
5
+ - Exclude
6
+
3
7
  AllCops:
8
+ TargetRubyVersion: 2.6
4
9
  DisplayCopNames: true
5
10
 
6
- Include:
7
- - '**/Appraisals'
8
- - '**/Gemfile'
9
- - '**/Rakefile'
10
11
  Exclude:
11
12
  - 'lib/generators/enumerate_it/enum/templates/**/*'
12
13
  - 'gemfiles/vendor/**/*'
@@ -14,7 +15,7 @@ AllCops:
14
15
  Gemspec/RequiredRubyVersion:
15
16
  Enabled: false
16
17
 
17
- Lint/EndAlignment:
18
+ Layout/EndAlignment:
18
19
  Enabled: false
19
20
 
20
21
  Metrics/LineLength:
@@ -25,6 +26,7 @@ Metrics/BlockLength:
25
26
  - 'spec/**/*'
26
27
 
27
28
  Layout/AlignHash:
29
+ EnforcedColonStyle: table
28
30
  EnforcedLastArgumentHashStyle: ignore_implicit
29
31
 
30
32
  Layout/ElseAlignment:
data/.travis.yml CHANGED
@@ -5,57 +5,43 @@ sudo: false
5
5
  cache: bundler
6
6
 
7
7
  before_install:
8
- - gem update --system
8
+ - ruby .ci/prepare
9
9
 
10
10
  script:
11
- - "ruby -e \"RUBY_VERSION == '2.5.0' ? system('bundle exec rubocop') : exit(0)\""
11
+ - "ruby -e \"RUBY_VERSION == '2.6.3' ? system('bundle exec rubocop') : exit(0)\""
12
12
  - bundle exec rake spec
13
13
 
14
14
  rvm:
15
- - 2.0.0
16
- - 2.1.10
17
- - 2.2.9
18
- - 2.3.6
19
- - 2.4.3
20
- - 2.5.0
15
+ - 2.2.10
16
+ - 2.3.8
17
+ - 2.4.6
18
+ - 2.5.5
19
+ - 2.6.3
21
20
 
22
21
  gemfile:
23
- - gemfiles/rails_3.0.gemfile
24
- - gemfiles/rails_3.1.gemfile
25
- - gemfiles/rails_3.2.gemfile
26
22
  - gemfiles/rails_4.0.gemfile
27
23
  - gemfiles/rails_4.1.gemfile
28
24
  - gemfiles/rails_4.2.gemfile
29
25
  - gemfiles/rails_5.0.gemfile
30
26
  - gemfiles/rails_5.1.gemfile
27
+ - gemfiles/rails_5.2.gemfile
31
28
 
32
29
  matrix:
33
30
  exclude:
34
- # Rails 5+ requires Ruby 2.2+
35
- - rvm: 2.0.0
36
- gemfile: gemfiles/rails_5.0.gemfile
37
- - rvm: 2.0.0
38
- gemfile: gemfiles/rails_5.1.gemfile
39
- - rvm: 2.1.10
40
- gemfile: gemfiles/rails_5.0.gemfile
41
- - rvm: 2.1.10
42
- gemfile: gemfiles/rails_5.1.gemfile
43
-
44
31
  # Rails 4.0 and 4.1 requires an old version of `json` gem, which isn't compatible with Ruby 2.4+
45
32
  # https://github.com/flori/json/issues/308
46
- - rvm: 2.4.3
33
+ - rvm: 2.4.6
47
34
  gemfile: gemfiles/rails_4.0.gemfile
48
- - rvm: 2.4.3
35
+ - rvm: 2.4.6
49
36
  gemfile: gemfiles/rails_4.1.gemfile
50
- - rvm: 2.5.0
37
+ - rvm: 2.5.5
51
38
  gemfile: gemfiles/rails_4.0.gemfile
52
- - rvm: 2.5.0
39
+ - rvm: 2.5.5
40
+ gemfile: gemfiles/rails_4.1.gemfile
41
+ - rvm: 2.6.3
42
+ gemfile: gemfiles/rails_4.0.gemfile
43
+ - rvm: 2.6.3
53
44
  gemfile: gemfiles/rails_4.1.gemfile
54
-
55
- # Rails 3.0 doesn't work with Ruby 2.5
56
- # (`undefined method `yaml_as' for BigDecimal:Class`)
57
- - rvm: 2.5.0
58
- gemfile: gemfiles/rails_3.0.gemfile
59
45
 
60
46
  addons:
61
47
  code_climate:
data/Appraisals CHANGED
@@ -4,14 +4,15 @@ require 'json'
4
4
  rails_versions = JSON.parse(Net::HTTP.get(URI('https://rubygems.org/api/v1/versions/rails.json')))
5
5
  .group_by { |version| version['number'] }.keys.reject { |key| key =~ /rc|racecar|beta|pre/ }
6
6
 
7
- %w[3.0 3.1 3.2 4.0 4.1 4.2 5.0 5.1].each do |version|
7
+ %w[4.0 4.1 4.2 5.0 5.1 5.2].each do |version|
8
8
  appraise "rails_#{version}" do
9
9
  current_version = rails_versions
10
10
  .select { |key| key.match(/\A#{version}/) }
11
- .sort { |a, b| Gem::Version.new(a) <=> Gem::Version.new(b) }
12
- .last
11
+ .max { |a, b| Gem::Version.new(a) <=> Gem::Version.new(b) }
13
12
 
14
13
  gem 'activesupport', "~> #{current_version}"
15
14
  gem 'activerecord', "~> #{current_version}"
15
+
16
+ gem 'sqlite3', Gem::Version.new(version) > Gem::Version.new(5.0) ? '~> 1.4.1' : '< 1.4'
16
17
  end
17
18
  end
data/Gemfile.lock CHANGED
@@ -1,15 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- enumerate_it (1.7.0)
5
- activesupport (>= 3.0.0)
4
+ enumerate_it (2.0.0)
5
+ activesupport (>= 4.0.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (5.1.5)
10
+ activesupport (5.2.3)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
- i18n (~> 0.7)
12
+ i18n (>= 0.7, < 2)
13
13
  minitest (~> 5.1)
14
14
  tzinfo (~> 1.1)
15
15
  appraisal (2.2.0)
@@ -18,49 +18,49 @@ GEM
18
18
  thor (>= 0.14.0)
19
19
  ast (2.4.0)
20
20
  coderay (1.1.2)
21
- concurrent-ruby (1.0.5)
21
+ concurrent-ruby (1.1.5)
22
22
  diff-lcs (1.3)
23
- i18n (0.9.5)
23
+ i18n (1.6.0)
24
24
  concurrent-ruby (~> 1.0)
25
- method_source (0.9.0)
25
+ jaro_winkler (1.5.2)
26
+ method_source (0.9.2)
26
27
  minitest (5.11.3)
27
- parallel (1.12.1)
28
- parser (2.5.0.3)
28
+ parallel (1.17.0)
29
+ parser (2.6.3.0)
29
30
  ast (~> 2.4.0)
30
- powerpack (0.1.1)
31
- pry (0.11.3)
31
+ pry (0.12.2)
32
32
  coderay (~> 1.1.0)
33
33
  method_source (~> 0.9.0)
34
34
  rainbow (3.0.0)
35
- rake (12.3.0)
36
- rspec (3.7.0)
37
- rspec-core (~> 3.7.0)
38
- rspec-expectations (~> 3.7.0)
39
- rspec-mocks (~> 3.7.0)
40
- rspec-core (3.7.1)
41
- rspec-support (~> 3.7.0)
42
- rspec-expectations (3.7.0)
35
+ rake (12.3.2)
36
+ rspec (3.8.0)
37
+ rspec-core (~> 3.8.0)
38
+ rspec-expectations (~> 3.8.0)
39
+ rspec-mocks (~> 3.8.0)
40
+ rspec-core (3.8.0)
41
+ rspec-support (~> 3.8.0)
42
+ rspec-expectations (3.8.3)
43
43
  diff-lcs (>= 1.2.0, < 2.0)
44
- rspec-support (~> 3.7.0)
45
- rspec-mocks (3.7.0)
44
+ rspec-support (~> 3.8.0)
45
+ rspec-mocks (3.8.0)
46
46
  diff-lcs (>= 1.2.0, < 2.0)
47
- rspec-support (~> 3.7.0)
48
- rspec-support (3.7.1)
49
- rubocop (0.53.0)
47
+ rspec-support (~> 3.8.0)
48
+ rspec-support (3.8.0)
49
+ rubocop (0.69.0)
50
+ jaro_winkler (~> 1.5.1)
50
51
  parallel (~> 1.10)
51
- parser (>= 2.5)
52
- powerpack (~> 0.1)
52
+ parser (>= 2.6)
53
53
  rainbow (>= 2.2.2, < 4.0)
54
54
  ruby-progressbar (~> 1.7)
55
- unicode-display_width (~> 1.0, >= 1.0.1)
56
- rubocop-rspec (1.24.0)
57
- rubocop (>= 0.53.0)
58
- ruby-progressbar (1.9.0)
59
- thor (0.20.0)
55
+ unicode-display_width (>= 1.4.0, < 1.7)
56
+ rubocop-rspec (1.33.0)
57
+ rubocop (>= 0.60.0)
58
+ ruby-progressbar (1.10.0)
59
+ thor (0.20.3)
60
60
  thread_safe (0.3.6)
61
61
  tzinfo (1.2.5)
62
62
  thread_safe (~> 0.1)
63
- unicode-display_width (1.3.0)
63
+ unicode-display_width (1.6.0)
64
64
  wwtd (1.3.0)
65
65
 
66
66
  PLATFORMS
@@ -78,4 +78,4 @@ DEPENDENCIES
78
78
  wwtd
79
79
 
80
80
  BUNDLED WITH
81
- 1.16.1
81
+ 2.0.1
data/LICENSE CHANGED
@@ -2,7 +2,7 @@ LICENSE
2
2
 
3
3
  The MIT License
4
4
 
5
- Copyright (c) 2010-2018 Cássio Marques and Lucas Caton
5
+ Copyright (c) 2010-2019 Cássio Marques and Lucas Caton
6
6
 
7
7
  Permission is hereby granted, free of charge, to any person obtaining
8
8
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -4,7 +4,6 @@ Enumerations for Ruby with some magic powers! 🎩
4
4
 
5
5
  [![Build Status](https://travis-ci.org/lucascaton/enumerate_it.svg?branch=master)](https://travis-ci.org/lucascaton/enumerate_it)
6
6
  [![Gem Version](https://badge.fury.io/rb/enumerate_it.svg)](https://rubygems.org/gems/enumerate_it)
7
- [![Dependency Status](https://gemnasium.com/badges/github.com/lucascaton/enumerate_it.svg)](https://gemnasium.com/github.com/lucascaton/enumerate_it)
8
7
  [![Code Climate](https://codeclimate.com/github/lucascaton/enumerate_it/badges/gpa.svg)](https://codeclimate.com/github/lucascaton/enumerate_it)
9
8
  [![Downloads](https://img.shields.io/gem/dt/enumerate_it.svg)](https://rubygems.org/gems/enumerate_it)
10
9
  [![Changelog](https://img.shields.io/badge/changelog--brightgreen.svg?style=flat)](https://github.com/lucascaton/enumerate_it/releases)
@@ -29,6 +28,7 @@ so you can **add behaviour** and also **reuse** them! 😀
29
28
  - [Using enumerations](#using-enumerations)
30
29
  - [FAQ](#faq)
31
30
  - [I18n](#i18n)
31
+ - [Translate a name-spaced enumeration](#translate-a-name-spaced-enumeration)
32
32
  - [Handling a legacy database](#handling-a-legacy-database)
33
33
  - [Changelog](#changelog)
34
34
 
@@ -42,13 +42,13 @@ gem install enumerate_it
42
42
 
43
43
  ## Using with Rails
44
44
 
45
- Add the gem to your Gemfile:
45
+ Add the gem to your `Gemfile`:
46
46
 
47
47
  ```ruby
48
48
  gem 'enumerate_it'
49
49
  ```
50
50
 
51
- You can use a Rails generator, which generates enumerations and their locale files:
51
+ You can use a Rails generator to create both an enumeration and its locale file:
52
52
 
53
53
  ```bash
54
54
  rails generate enumerate_it:enum --help
@@ -403,8 +403,8 @@ You sure can! 😄
403
403
 
404
404
  #### What versions of Ruby and Rails are supported?
405
405
 
406
- * **Ruby** from `2.0` to `2.4`
407
- * **Rails** from `3.0` to `5.1`
406
+ * **Ruby**: `2.0+`
407
+ * **Rails** `3.0+`
408
408
 
409
409
  All versions are tested via
410
410
  [Travis](https://github.com/lucascaton/enumerate_it/blob/master/.travis.yml).
@@ -452,6 +452,19 @@ RelationshipStatus.t(status)
452
452
  #=> 'Casado'
453
453
  ```
454
454
 
455
+ ### Translate a name-spaced enumeration
456
+
457
+ In order to translate an enumeration in a specific namespace (say `Design::Color`),
458
+ you can add the following:
459
+
460
+ ```yaml
461
+ pt-BR:
462
+ enumerations:
463
+ 'design/color':
464
+ blue: Azul
465
+ red: Vermelho
466
+ ```
467
+
455
468
  ## Handling a legacy database
456
469
 
457
470
  **EnumerateIt** can help you build a Rails application around a legacy database which was filled
@@ -515,11 +528,11 @@ Changes are maintained under [Releases page](https://github.com/lucascaton/enume
515
528
  * Fork the project.
516
529
  * Make your feature addition or bug fix.
517
530
  * Add tests for it. This is important so we don't break it in a future version unintentionally.
518
- * [Optional] Run the tests agaist a specific Gemfile: `$ bundle exec appraisal rails_5.1 rake spec`.
531
+ * [Optional] Run the tests agaist a specific Gemfile: `$ bundle exec appraisal rails_5.2 rake spec`.
519
532
  * Run the tests agaist all supported versions: `$ bundle exec rake` (or `$ bundle exec wwtd`)
520
533
  * Commit, but please do not mess with `Rakefile`, version, or history.
521
534
  * Send a Pull Request. Bonus points for topic branches.
522
535
 
523
536
  ## Copyright
524
537
 
525
- Copyright (c) 2010-2018 Cássio Marques and Lucas Caton. See `LICENSE` file for details.
538
+ Copyright (c) 2010-2019 Cássio Marques and Lucas Caton. See `LICENSE` file for details.
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'bundler/gem_tasks'
2
2
 
3
- if ENV['APPRAISAL_INITIALIZED'] || ENV['TRAVIS'] || RUBY_VERSION < '2.0.0'
3
+ if ENV['APPRAISAL_INITIALIZED'] || ENV['TRAVIS']
4
4
  require 'rspec/core/rake_task'
5
5
 
6
6
  Bundler::GemHelper.install_tasks
data/enumerate_it.gemspec CHANGED
@@ -12,19 +12,16 @@ Gem::Specification.new do |gem|
12
12
  gem.name = 'enumerate_it'
13
13
  gem.require_paths = ['lib']
14
14
  gem.version = EnumerateIt::VERSION
15
- gem.required_ruby_version = '>= 2.0.0'
15
+ gem.required_ruby_version = '>= 2.2.0'
16
16
 
17
- gem.add_dependency 'activesupport', '>= 3.0.0'
17
+ gem.add_dependency 'activesupport', '>= 4.0.0'
18
18
 
19
19
  gem.add_development_dependency 'appraisal'
20
20
  gem.add_development_dependency 'bundler'
21
21
  gem.add_development_dependency 'pry'
22
22
  gem.add_development_dependency 'rake'
23
23
  gem.add_development_dependency 'rspec'
24
+ gem.add_development_dependency 'rubocop'
25
+ gem.add_development_dependency 'rubocop-rspec'
24
26
  gem.add_development_dependency 'wwtd'
25
-
26
- if RUBY_VERSION >= '2.2.0'
27
- gem.add_development_dependency 'rubocop'
28
- gem.add_development_dependency 'rubocop-rspec'
29
- end
30
27
  end
@@ -4,5 +4,6 @@ source 'https://rubygems.org'
4
4
 
5
5
  gem 'activerecord', '~> 4.0.13'
6
6
  gem 'activesupport', '~> 4.0.13'
7
+ gem 'sqlite3', '< 1.4'
7
8
 
8
9
  gemspec path: '../'
@@ -4,5 +4,6 @@ source 'https://rubygems.org'
4
4
 
5
5
  gem 'activerecord', '~> 4.1.16'
6
6
  gem 'activesupport', '~> 4.1.16'
7
+ gem 'sqlite3', '< 1.4'
7
8
 
8
9
  gemspec path: '../'
@@ -2,7 +2,8 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- gem 'activerecord', '~> 4.2.10'
6
- gem 'activesupport', '~> 4.2.10'
5
+ gem 'activerecord', '~> 4.2.11.1'
6
+ gem 'activesupport', '~> 4.2.11.1'
7
+ gem 'sqlite3', '< 1.4'
7
8
 
8
9
  gemspec path: '../'
@@ -2,7 +2,8 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- gem 'activerecord', '~> 5.0.6'
6
- gem 'activesupport', '~> 5.0.6'
5
+ gem 'activerecord', '~> 5.0.7.2'
6
+ gem 'activesupport', '~> 5.0.7.2'
7
+ gem 'sqlite3', '< 1.4'
7
8
 
8
9
  gemspec path: '../'
@@ -2,7 +2,8 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- gem 'activerecord', '~> 5.1.5'
6
- gem 'activesupport', '~> 5.1.5'
5
+ gem 'activerecord', '~> 5.1.7'
6
+ gem 'activesupport', '~> 5.1.7'
7
+ gem 'sqlite3', '~> 1.4.1'
7
8
 
8
9
  gemspec path: '../'
@@ -2,7 +2,8 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- gem 'activerecord', '~> 3.0.20'
6
- gem 'activesupport', '~> 3.0.20'
5
+ gem 'activerecord', '~> 5.2.3'
6
+ gem 'activesupport', '~> 5.2.3'
7
+ gem 'sqlite3', '~> 1.4.1'
7
8
 
8
9
  gemspec path: '../'
@@ -45,8 +45,8 @@ module EnumerateIt
45
45
  list.each { |value| yield value }
46
46
  end
47
47
 
48
- def to_json
49
- sorted_map.map { |_k, v| { value: v[0], label: translate(v[1]) } }.to_json
48
+ def to_json(options = nil)
49
+ sorted_map.map { |_k, v| { value: v[0], label: translate(v[1]) } }.to_json(options)
50
50
  end
51
51
 
52
52
  def t(value)
@@ -66,6 +66,7 @@ module EnumerateIt
66
66
 
67
67
  def value_from_key(key)
68
68
  return if key.nil?
69
+
69
70
  (enumeration[key.to_sym] || []).first
70
71
  end
71
72
 
@@ -74,6 +74,7 @@ module EnumerateIt
74
74
 
75
75
  def create_polymorphic_methods(klass, attribute_name, helpers)
76
76
  return unless helpers.is_a?(Hash) && helpers[:polymorphic]
77
+
77
78
  options = helpers[:polymorphic]
78
79
  suffix = options.is_a?(Hash) && options[:suffix]
79
80
  suffix ||= '_object'
@@ -1,3 +1,3 @@
1
1
  module EnumerateIt
2
- VERSION = '1.7.0'.freeze
2
+ VERSION = '2.0.0'.freeze
3
3
  end
@@ -2,5 +2,5 @@
2
2
  enumerations:
3
3
  <%= singular_name %>:
4
4
  <%- locale_fields.each do |name| -%>
5
- <%= name %>: "<%= name.capitalize %>"
5
+ <%= name %>: '<%= name.capitalize %>'
6
6
  <%- end -%>
@@ -210,38 +210,38 @@ describe EnumerateIt::Base do
210
210
  end
211
211
 
212
212
  context 'not specifying a sort mode' do
213
- subject { create_enumeration_class_with_sort_mode(nil).to_a }
213
+ subject(:enumeration) { create_enumeration_class_with_sort_mode(nil) }
214
214
 
215
215
  it 'does not sort' do
216
- is_expected.to eq([%w[xyz 1], %w[fgh 2], %w[abc 3], %w[jkl 0]])
216
+ expect(enumeration.to_a).to eq([%w[xyz 1], %w[fgh 2], %w[abc 3], %w[jkl 0]])
217
217
  end
218
218
  end
219
219
 
220
220
  context 'specifying a sort mode' do
221
- subject { create_enumeration_class_with_sort_mode(sort_mode).to_a }
221
+ subject(:enumeration) { create_enumeration_class_with_sort_mode(sort_mode) }
222
222
 
223
223
  context 'by value' do
224
224
  let(:sort_mode) { :value }
225
225
 
226
- it { is_expected.to eq([%w[jkl 0], %w[xyz 1], %w[fgh 2], %w[abc 3]]) }
226
+ it { expect(enumeration.to_a).to eq([%w[jkl 0], %w[xyz 1], %w[fgh 2], %w[abc 3]]) }
227
227
  end
228
228
 
229
229
  context 'by name' do
230
230
  let(:sort_mode) { :name }
231
231
 
232
- it { is_expected.to eq([%w[fgh 2], %w[xyz 1], %w[abc 3], %w[jkl 0]]) }
232
+ it { expect(enumeration.to_a).to eq([%w[fgh 2], %w[xyz 1], %w[abc 3], %w[jkl 0]]) }
233
233
  end
234
234
 
235
235
  context 'by translation' do
236
236
  let(:sort_mode) { :translation }
237
237
 
238
- it { is_expected.to eq([%w[abc 3], %w[fgh 2], %w[jkl 0], %w[xyz 1]]) }
238
+ it { expect(enumeration.to_a).to eq([%w[abc 3], %w[fgh 2], %w[jkl 0], %w[xyz 1]]) }
239
239
  end
240
240
 
241
241
  context 'by nothing' do
242
242
  let(:sort_mode) { :none }
243
243
 
244
- it { is_expected.to eq([%w[xyz 1], %w[fgh 2], %w[abc 3], %w[jkl 0]]) }
244
+ it { expect(enumeration.to_a).to eq([%w[xyz 1], %w[fgh 2], %w[abc 3], %w[jkl 0]]) }
245
245
  end
246
246
  end
247
247
 
@@ -264,10 +264,12 @@ describe EnumerateIt do
264
264
  end
265
265
  end
266
266
 
267
- it 'when called, the scopes create the correct query' do
267
+ it 'when called, the scopes create the correct query', sqlite: true do
268
+ ActiveRecord::Schema.define { create_table :test_class_with_scopes }
269
+
268
270
  TestEnumeration.enumeration.each do |symbol, pair|
269
- expect(TestClassWithScope).to receive(:where).with(foobar: pair.first)
270
- TestClassWithScope.send(symbol)
271
+ expect(TestClassWithScope.public_send(symbol).to_sql)
272
+ .to match(/WHERE "test_class_with_scopes"."foobar" = \'#{pair.first}\'/)
271
273
  end
272
274
  end
273
275
  end
data/spec/spec_helper.rb CHANGED
@@ -11,6 +11,9 @@ I18n.config.enforce_available_locales = false
11
11
  I18n.load_path = Dir['spec/i18n/*.yml']
12
12
 
13
13
  RSpec.configure do |config|
14
- config.filter_run :focus
15
- config.run_all_when_everything_filtered = true
14
+ config.filter_run_when_matching :focus
15
+
16
+ config.before(:each, sqlite: true) do
17
+ ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
18
+ end
16
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enumerate_it
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cássio Marques
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-03-12 00:00:00.000000000 Z
12
+ date: 2019-05-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 3.0.0
20
+ version: 4.0.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 3.0.0
27
+ version: 4.0.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: appraisal
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -96,7 +96,7 @@ dependencies:
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
98
  - !ruby/object:Gem::Dependency
99
- name: wwtd
99
+ name: rubocop
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
102
  - - ">="
@@ -110,7 +110,7 @@ dependencies:
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
112
  - !ruby/object:Gem::Dependency
113
- name: rubocop
113
+ name: rubocop-rspec
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
116
  - - ">="
@@ -124,7 +124,7 @@ dependencies:
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  - !ruby/object:Gem::Dependency
127
- name: rubocop-rspec
127
+ name: wwtd
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
130
  - - ">="
@@ -143,6 +143,7 @@ executables: []
143
143
  extensions: []
144
144
  extra_rdoc_files: []
145
145
  files:
146
+ - ".ci/prepare"
146
147
  - ".gitignore"
147
148
  - ".rspec"
148
149
  - ".rubocop.yml"
@@ -155,14 +156,12 @@ files:
155
156
  - README.md
156
157
  - Rakefile
157
158
  - enumerate_it.gemspec
158
- - gemfiles/rails_3.0.gemfile
159
- - gemfiles/rails_3.1.gemfile
160
- - gemfiles/rails_3.2.gemfile
161
159
  - gemfiles/rails_4.0.gemfile
162
160
  - gemfiles/rails_4.1.gemfile
163
161
  - gemfiles/rails_4.2.gemfile
164
162
  - gemfiles/rails_5.0.gemfile
165
163
  - gemfiles/rails_5.1.gemfile
164
+ - gemfiles/rails_5.2.gemfile
166
165
  - lib/enumerate_it.rb
167
166
  - lib/enumerate_it/base.rb
168
167
  - lib/enumerate_it/class_methods.rb
@@ -189,15 +188,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
189
188
  requirements:
190
189
  - - ">="
191
190
  - !ruby/object:Gem::Version
192
- version: 2.0.0
191
+ version: 2.2.0
193
192
  required_rubygems_version: !ruby/object:Gem::Requirement
194
193
  requirements:
195
194
  - - ">="
196
195
  - !ruby/object:Gem::Version
197
196
  version: '0'
198
197
  requirements: []
199
- rubyforge_project:
200
- rubygems_version: 2.7.6
198
+ rubygems_version: 3.0.3
201
199
  signing_key:
202
200
  specification_version: 4
203
201
  summary: Ruby Enumerations
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source 'https://rubygems.org'
4
-
5
- gem 'activerecord', '~> 3.1.12'
6
- gem 'activesupport', '~> 3.1.12'
7
-
8
- gemspec path: '../'
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source 'https://rubygems.org'
4
-
5
- gem 'activerecord', '~> 3.2.22.5'
6
- gem 'activesupport', '~> 3.2.22.5'
7
-
8
- gemspec path: '../'