enumerize 2.7.0 → 2.8.1

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: a2c0c71e8e7b38b6ec3eb0e0f53429a21465bd1dcea61ea87761a497fa9f55ab
4
- data.tar.gz: b2803acb5138d2a471ddf84cbcc8b5b3fde56507e8f6db7135ea7ea6f50f5f98
3
+ metadata.gz: 7e8451ec4f75c5a22b6a9c6e337bece407942da5cb12f504b689582e56e1db55
4
+ data.tar.gz: cfd3f27f2fe811d1c23cf47e875da412b76efd0bae55d18f44d551eb56447507
5
5
  SHA512:
6
- metadata.gz: 3cb1506ba0eed847bf0e8f09df719ad06f88034b3f58988046bad0f36ecbcabf8e43f8b31f2e38160f15cf0d7886667fbc36a59b91b73f85a6b09efd6d925877
7
- data.tar.gz: 4e927b95541a1cd89584d65c7abc5bd1ab7b0fdcda8abaa7e9c53c7b0b4c0e928c5a2055e0c160ffd0e1b295f276d534909f0411c0c6ea35342ee10f2dca9380
6
+ metadata.gz: ccc0ed4ca53517171dcac492ae9fd618c17fb08b9b39f4f42b6d951cdc46defb3acc92f66ce345fbe13cb0a654db8d7800b4dc72c19cb0c4e3c4ab1c3088780c
7
+ data.tar.gz: bd8521f6e55b9af3283073e36197ea5fc5107d4114f297713b6a27ac221bcd98f2376a4803351eeb8c1a7b518c032b6bcc5d16a6c7750294753d0f64f76a4352
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
@@ -23,7 +23,7 @@ jobs:
23
23
  - 5432:5432
24
24
  options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
25
25
  mysql:
26
- image: mysql:5.6
26
+ image: mysql:5.7
27
27
  env:
28
28
  MYSQL_ROOT_PASSWORD: mysql
29
29
  ports:
@@ -32,13 +32,12 @@ jobs:
32
32
  strategy:
33
33
  fail-fast: false
34
34
  matrix:
35
- ruby-version: ['2.7', '3.0', '3.1']
35
+ ruby-version: ['3.0', '3.1', '3.2', '3.3']
36
36
  test: ['minitest', 'rspec']
37
37
  gemfile:
38
- - Gemfile
39
- - Gemfile.rails60
40
38
  - Gemfile.rails61
41
39
  - Gemfile.rails70
40
+ - Gemfile.rails71
42
41
  - Gemfile.railsmaster
43
42
  - Gemfile.mongo_mapper
44
43
  db:
@@ -48,20 +47,18 @@ jobs:
48
47
  exclude:
49
48
  - gemfile: Gemfile.mongo_mapper
50
49
  db: postgresql
51
- - ruby-version: '3.0'
52
- gemfile: Gemfile
53
- - ruby-version: '3.1'
54
- gemfile: Gemfile
55
50
  - ruby-version: '3.0'
56
51
  gemfile: Gemfile.mongo_mapper
57
52
  - ruby-version: '3.1'
58
53
  gemfile: Gemfile.mongo_mapper
54
+ - ruby-version: '3.0'
55
+ gemfile: Gemfile.railsmaster
59
56
  env:
60
57
  BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
61
58
  DB: "${{ matrix.db }}"
62
59
  TEST_FRAMEWORK: "${{ matrix.test }}"
63
60
  steps:
64
- - uses: actions/checkout@v2
61
+ - uses: actions/checkout@v4
65
62
  - name: Set up Ruby
66
63
  uses: ruby/setup-ruby@v1
67
64
  with:
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 2.7.8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## 2.8.1 (March 25, 2024)
2
+
3
+ ### bug fix
4
+
5
+ * Support enumerization of the same attribute in child classes. (by [@nashby](https://github.com/nashby))
6
+
7
+ ## 2.8.0 (March 17, 2024)
8
+
9
+ ### bug fix
10
+
11
+ * Fix a bug where the value of a false boolean attribute was not properly serialized because it was
12
+ treated as ruby's false in condition and that condition was never met. (by [@nashby](https://github.com/nashby))
13
+ * Make `Enumerize::Value#as_json` return a string, not an instance of `Enumerize::Value` (by [@nashby](https://github.com/nashby))
14
+ * Fix attribute type casting when Rails master is used (by [@nashby](https://github.com/nashby))
15
+ * Fix bug with `ActiveRecord#reload` when enumerized attribute is an instance of `ActiveRecord::Store` and it's nil. (by [@4ndypanda](https://github.com/4ndypanda))
16
+ * Fix attribute type casting when `ActiveRecord#dup` is used (by [@mihyaeru21](https://github.com/mihyaeru21))
17
+
18
+ ### enchancements
19
+
20
+ * Support only Ruby 3+ and Rails 6.1+. (by [@nashby](https://github.com/nashby))
21
+ * Allows the original options specified in enumerize to be retrieved from Enumerize::Attribute. (by [@okoshi-f](https://github.com/okoshi-f))
22
+
1
23
  ## 2.7.0 (July 7, 2023)
2
24
 
3
25
  ### bug fix
@@ -5,7 +27,7 @@
5
27
  * Warn about already defined predicate methods only when we generate predicate methods with `predicate: true` (by [@nashby](https://github.com/nashby))
6
28
  * Define `Type#cast` instead of deserialize to fix serialization issue. (by [@nashby](https://github.com/nashby))
7
29
  * Fix `Undefined method 'enumerize' for RSpec::ExampleGroups` (by [@softwaregravy](https://github.com/softwaregravy))
8
-
30
+
9
31
  ### enchancements
10
32
 
11
33
  * Add support for procs as `i18n_scope` option value. (by [@nashby](https://github.com/nashby))
data/Gemfile.global CHANGED
@@ -8,7 +8,7 @@ if ENV['TEST_FRAMEWORK'] == 'rspec'
8
8
  gem 'rspec', :require => false
9
9
  end
10
10
 
11
- gem 'pg', '~> 1.2.3', :platform => [:ruby, :mswin, :mingw]
11
+ gem 'pg', '~> 1.5.3', :platform => [:ruby, :mswin, :mingw]
12
12
  gem 'sequel'
13
13
  gem 'simple_form'
14
14
  gem 'formtastic'
data/Gemfile.mongo_mapper CHANGED
@@ -1,6 +1,6 @@
1
1
  eval_gemfile('Gemfile.global')
2
2
 
3
3
  gem 'minitest', '~> 5.8'
4
- gem 'rails', '~> 5.2.4', :require => false
4
+ gem 'rails', github: 'rails/rails', branch: '7-0-stable', require: false
5
5
  gem 'mongo_mapper'
6
- gem 'sqlite3', '~> 1.3.6', :platform => [:ruby, :mswin, :mingw]
6
+ gem 'sqlite3', :platform => [:ruby, :mswin, :mingw]
data/Gemfile.rails70 CHANGED
@@ -3,7 +3,6 @@ eval_gemfile('Gemfile.global')
3
3
  gem 'minitest', '~> 5.8'
4
4
  gem 'rails', github: 'rails/rails', branch: '7-0-stable', require: false
5
5
 
6
- # TODO: Mongoid doesn't support Rails 7 yet. Uncomment when it's fixed https://jira.mongodb.org/browse/MONGOID-5193
7
- # gem 'mongoid', github: 'mongodb/mongoid'
6
+ gem 'mongoid', github: 'mongodb/mongoid'
8
7
 
9
8
  gem 'sqlite3', :platform => [:ruby, :mswin, :mingw]
@@ -1,6 +1,8 @@
1
1
  eval_gemfile('Gemfile.global')
2
2
 
3
3
  gem 'minitest', '~> 5.8'
4
- gem 'rails', '~> 6.0.0', require: false
4
+ gem 'rails', github: 'rails/rails', branch: '7-1-stable', require: false
5
+
5
6
  gem 'mongoid', github: 'mongodb/mongoid'
7
+
6
8
  gem 'sqlite3', :platform => [:ruby, :mswin, :mingw]
data/README.md CHANGED
@@ -46,8 +46,8 @@ Or install it yourself as:
46
46
 
47
47
  ## Supported Versions
48
48
 
49
- - Ruby 2.7+
50
- - Rails 5.2+
49
+ - Ruby 3.0+
50
+ - Rails 6.1+
51
51
 
52
52
  ## Usage
53
53
 
@@ -21,7 +21,13 @@ module Enumerize
21
21
  require 'enumerize/hooks/uniqueness'
22
22
 
23
23
  unless options[:multiple]
24
- if ::ActiveRecord.version >= ::Gem::Version.new("7.0.0.alpha")
24
+ if ::ActiveRecord.version >= ::Gem::Version.new("7.2.0.alpha")
25
+ attribute(name)
26
+
27
+ decorate_attributes([name]) do |_, subtype|
28
+ Type.new(enumerized_attributes[name], subtype)
29
+ end
30
+ elsif ::ActiveRecord.version >= ::Gem::Version.new("7.0.0.alpha")
25
31
  attribute(name) do |subtype|
26
32
  Type.new(enumerized_attributes[name], subtype)
27
33
  end
@@ -74,7 +80,9 @@ module Enumerize
74
80
  end
75
81
 
76
82
  if store_attr.present?
77
- reloaded.send("#{attr.name}=", reloaded.send(store_attr).with_indifferent_access[attr.name])
83
+ unless reloaded.send(store_attr).nil?
84
+ reloaded.send("#{attr.name}=", reloaded.send(store_attr).with_indifferent_access[attr.name])
85
+ end
78
86
  else
79
87
  reloaded.send("#{attr.name}=", reloaded[attr.name])
80
88
  end
@@ -110,16 +118,20 @@ module Enumerize
110
118
 
111
119
  def serialize(value)
112
120
  v = @attr.find_value(value)
113
- (v && v.value) || value
114
- end
121
+ return value unless v
115
122
 
116
- alias type_cast_for_database serialize
123
+ v.value
124
+ end
117
125
 
118
126
  def cast(value)
119
- @attr.find_value(value)
120
- end
127
+ return value if @subtype.is_a?(Type)
121
128
 
122
- alias type_cast_from_database cast
129
+ if value.is_a?(::Enumerize::Value)
130
+ value
131
+ else
132
+ @attr.find_value(@subtype.cast(value))
133
+ end
134
+ end
123
135
 
124
136
  def as_json(options = nil)
125
137
  {attr: @attr.name}.as_json(options)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Enumerize
4
4
  class Attribute
5
- attr_reader :klass, :name, :values, :default_value, :i18n_scope, :skip_validations_value
5
+ attr_reader :klass, :name, :values, :default_value, :i18n_scope, :skip_validations_value, :arguments
6
6
 
7
7
  def initialize(klass, name, options={})
8
8
  raise ArgumentError, ':in option is required' unless options[:in]
@@ -13,6 +13,7 @@ module Enumerize
13
13
  @klass = klass
14
14
  @name = name.to_sym
15
15
  @i18n_scope = options[:i18n_scope]
16
+ @arguments = options
16
17
 
17
18
  value_class = options.fetch(:value_class, Value)
18
19
  @values = Array(options[:in]).map { |v| value_class.new(self, *v).freeze }
@@ -38,6 +38,10 @@ module Enumerize
38
38
  coder.represent_object(self.class.superclass, @value)
39
39
  end
40
40
 
41
+ def as_json(*)
42
+ to_s
43
+ end
44
+
41
45
  private
42
46
 
43
47
  def predicate_call(value)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Enumerize
4
- VERSION = '2.7.0'
4
+ VERSION = '2.8.1'
5
5
  end
@@ -4,7 +4,7 @@ require 'test_helper'
4
4
 
5
5
  if defined?(::ActiveModel::Attributes)
6
6
 
7
- class ActiveModelTest < MiniTest::Spec
7
+ class ActiveModelTest < Minitest::Spec
8
8
  class ActiveModelUser
9
9
  include ActiveModel::Model
10
10
  include ActiveModel::Attributes
@@ -3,7 +3,6 @@
3
3
  require 'test_helper'
4
4
  require 'active_record'
5
5
  require 'logger'
6
-
7
6
  db = (ENV['DB'] || 'sqlite3').to_sym
8
7
 
9
8
  silence_warnings do
@@ -60,6 +59,9 @@ silence_warnings do
60
59
  end
61
60
 
62
61
  ActiveRecord::Base.connection.instance_eval do
62
+ ActiveRecord::Migration.drop_table :users, if_exists: true
63
+ ActiveRecord::Migration.drop_table :documents, if_exists: true
64
+
63
65
  create_table :users do |t|
64
66
  t.string :sex
65
67
  t.string :role
@@ -71,6 +73,8 @@ ActiveRecord::Base.connection.instance_eval do
71
73
  t.integer :skill
72
74
  t.string :account_type, :default => :basic
73
75
  t.string :foo
76
+ t.boolean :newsletter_subscribed, default: true
77
+ t.json :store_accessor_store_with_no_defaults
74
78
  end
75
79
 
76
80
  create_table :documents do |t|
@@ -109,7 +113,7 @@ class User < ActiveRecord::Base
109
113
  enumerize :sex, :in => [:male, :female], scope: :shallow
110
114
  enumerize :language, :in => [:en, :jp]
111
115
 
112
- serialize :interests, Array
116
+ serialize :interests, type: Array
113
117
  enumerize :interests, :in => [:music, :sports, :dancing, :programming], :multiple => true
114
118
 
115
119
  enumerize :status, :in => { active: 1, blocked: 2 }, scope: true
@@ -117,6 +121,10 @@ class User < ActiveRecord::Base
117
121
  enumerize :skill, :in => { noob: 0, casual: 1, pro: 2 }, scope: :shallow
118
122
 
119
123
  enumerize :account_type, :in => [:basic, :premium]
124
+ enumerize :newsletter_subscribed, in: { subscribed: true, unsubscribed: false }
125
+
126
+ store_accessor :store_accessor_store_with_no_defaults, [:origin]
127
+ enumerize :origin, in: [:browser, :app]
120
128
 
121
129
  # There is no column for relationship enumeration for testing purposes: model
122
130
  # should not be broken even if the associated column does not exist yet.
@@ -139,7 +147,7 @@ class SkipValidationsUser < ActiveRecord::Base
139
147
  include SkipValidationsEnum
140
148
  end
141
149
 
142
- class DoNotSkipValidationsUser < ActiveRecord::Base
150
+ class DoNotSkipValidationsUser < ActiveRecord::Base
143
151
  self.table_name = "users"
144
152
  include DoNotSkipValidationsEnum
145
153
  end
@@ -154,7 +162,7 @@ class SkipValidationsLambdaWithParamUser < ActiveRecord::Base
154
162
  include SkipValidationsLambdaWithParamEnum
155
163
  end
156
164
 
157
- class ActiveRecordTest < MiniTest::Spec
165
+ class ActiveRecordTest < Minitest::Spec
158
166
  it 'sets nil if invalid value is passed' do
159
167
  user = User.new
160
168
  user.sex = :invalid
@@ -194,6 +202,15 @@ class ActiveRecordTest < MiniTest::Spec
194
202
  expect(user.language).must_equal 'en'
195
203
  end
196
204
 
205
+ it 'returns nil if store column is nil, uses .store_accessor, and has no default values for store\'s attributes' do
206
+ User.delete_all
207
+ user = User.create!
208
+ user.update_column(:store_accessor_store_with_no_defaults, nil)
209
+ user.reload
210
+ expect(user.store_accessor_store_with_no_defaults).must_be_nil
211
+ expect(user.origin).must_be_nil
212
+ end
213
+
197
214
  it 'has default value' do
198
215
  expect(User.new.role).must_equal 'user'
199
216
  expect(User.new.attributes['role']).must_equal 'user'
@@ -654,6 +671,37 @@ class ActiveRecordTest < MiniTest::Spec
654
671
  expect(sql).must_include 'LIKE \'%foo%\''
655
672
  end
656
673
 
674
+ it 'supports boolean column as enumerized field' do
675
+ User.delete_all
676
+
677
+ User.create!(newsletter_subscribed: true)
678
+ expect(User.find_by(newsletter_subscribed: true).newsletter_subscribed).must_equal 'subscribed'
679
+
680
+ User.create!(newsletter_subscribed: false)
681
+ expect(User.find_by(newsletter_subscribed: false).newsletter_subscribed).must_equal 'unsubscribed'
682
+ end
683
+
684
+ it 'has same value with original object when created by #dup' do
685
+ user1 = User.new(skill: :casual)
686
+ user2 = user1.dup
687
+ expect(user2.skill).must_equal 'casual'
688
+ end
689
+
690
+ it 'has same value with original object when created by #clone' do
691
+ user1 = User.new(skill: :casual)
692
+ user2 = user1.clone
693
+ expect(user2.skill).must_equal 'casual'
694
+ end
695
+
696
+ it 'works when child class calls enumerize second time' do
697
+ class AdminUser < User
698
+ enumerize :account_type, in: [:basic, :premium, :pro]
699
+ end
700
+
701
+ admin = AdminUser.create(account_type: 'pro')
702
+ expect(admin.account_type).must_equal 'pro'
703
+ end
704
+
657
705
  if Rails::VERSION::MAJOR >= 6
658
706
  it 'supports AR#insert_all' do
659
707
  User.delete_all
@@ -3,7 +3,7 @@
3
3
  require 'test_helper'
4
4
 
5
5
  module Enumerize
6
- class AttributeMapTest < MiniTest::Spec
6
+ class AttributeMapTest < Minitest::Spec
7
7
  subject { AttributeMap.new }
8
8
 
9
9
  def make_attr(name)
@@ -52,7 +52,7 @@ module Enumerize
52
52
 
53
53
  it 'updates dependants' do
54
54
  attr = make_attr(:a)
55
- dependant = MiniTest::Mock.new
55
+ dependant = Minitest::Mock.new
56
56
  dependant.expect(:<<, nil, [attr])
57
57
  subject.add_dependant dependant
58
58
  subject << attr
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'test_helper'
4
4
 
5
- class AttributeTest < MiniTest::Spec
5
+ class AttributeTest < Minitest::Spec
6
6
  def attr
7
7
  @attr ||= nil
8
8
  end
@@ -39,6 +39,13 @@ class AttributeTest < MiniTest::Spec
39
39
  end
40
40
  end
41
41
 
42
+ describe 'arguments' do
43
+ it 'returns arguments' do
44
+ build_attr nil, :foo, :in => [:a, :b], :scope => true
45
+ expect(attr.arguments).must_equal({:in => [:a, :b], :scope => true})
46
+ end
47
+ end
48
+
42
49
  describe 'options for select' do
43
50
  it 'returns all options for select' do
44
51
  store_translations(:en, :enumerize => {:foo => {:a => 'a text', :b => 'b text'}}) do
data/test/base_test.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'test_helper'
4
4
 
5
- class BaseTest < MiniTest::Spec
5
+ class BaseTest < Minitest::Spec
6
6
  let(:kklass) do
7
7
  Class.new do
8
8
  extend Enumerize
@@ -5,7 +5,7 @@ require 'test_helper'
5
5
  Formtastic::FormBuilder.action_class_finder = Formtastic::ActionClassFinder
6
6
  Formtastic::FormBuilder.input_class_finder = Formtastic::InputClassFinder
7
7
 
8
- class FormtasticSpec < MiniTest::Spec
8
+ class FormtasticSpec < Minitest::Spec
9
9
  include ViewTestHelper
10
10
  include Formtastic::Helpers::FormHelper
11
11
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'test_helper'
4
4
 
5
- class ModuleAttributesSpec < MiniTest::Spec
5
+ class ModuleAttributesSpec < Minitest::Spec
6
6
  it 'inherits attribute from the module' do
7
7
  mod = Module.new do
8
8
  extend Enumerize
@@ -10,7 +10,7 @@ end
10
10
 
11
11
  MongoMapper.connection = Mongo::Client.new(['localhost:27017'], database: 'enumerize-test-suite-of-mongomapper')
12
12
 
13
- class MongoMapperTest < MiniTest::Spec
13
+ class MongoMapperTest < Minitest::Spec
14
14
  class MongoMapperUser
15
15
  include MongoMapper::Document
16
16
  extend Enumerize
data/test/mongoid_test.rb CHANGED
@@ -13,7 +13,7 @@ Mongoid.configure do |config|
13
13
  config.options = { use_utc: true, include_root_in_json: true }
14
14
  end
15
15
 
16
- class MongoidTest < MiniTest::Spec
16
+ class MongoidTest < Minitest::Spec
17
17
  class MongoidUser
18
18
  include Mongoid::Document
19
19
  extend Enumerize
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'test_helper'
4
4
 
5
- class MultipleTest < MiniTest::Spec
5
+ class MultipleTest < Minitest::Spec
6
6
  let(:kklass) do
7
7
  Class.new do
8
8
  extend Enumerize
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'test_helper'
4
4
 
5
- class PredicatesTest < MiniTest::Spec
5
+ class PredicatesTest < Minitest::Spec
6
6
  let(:kklass) do
7
7
  Class.new do
8
8
  extend Enumerize
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'test_helper'
4
4
 
5
- class RailsAdminSpec < MiniTest::Spec
5
+ class RailsAdminSpec < Minitest::Spec
6
6
  let(:kklass) do
7
7
  Class.new do
8
8
  extend Enumerize
data/test/sequel_test.rb CHANGED
@@ -5,7 +5,7 @@ require 'sequel'
5
5
  require 'logger'
6
6
  require 'jdbc/sqlite3' if RUBY_PLATFORM == 'java'
7
7
 
8
- class SequelTest < MiniTest::Spec
8
+ class SequelTest < Minitest::Spec
9
9
  silence_warnings do
10
10
  DB = if RUBY_PLATFORM == 'java'
11
11
  Sequel.connect('jdbc:sqlite::memory:')
data/test/set_test.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  require 'test_helper'
4
4
  require 'yaml'
5
5
 
6
- class SetTest < MiniTest::Spec
6
+ class SetTest < Minitest::Spec
7
7
  let(:kklass) do
8
8
  Class.new do
9
9
  extend Enumerize
@@ -3,7 +3,7 @@
3
3
  require 'test_helper'
4
4
  require 'simple_form/version'
5
5
 
6
- class SimpleFormSpec < MiniTest::Spec
6
+ class SimpleFormSpec < Minitest::Spec
7
7
  include ViewTestHelper
8
8
  include SimpleForm::ActionViewExtensions::FormHelper
9
9
 
data/test/test_helper.rb CHANGED
@@ -4,6 +4,7 @@ require 'minitest/autorun'
4
4
  require 'minitest/spec'
5
5
  require 'active_support/core_ext/kernel/reporting'
6
6
  require 'active_model'
7
+ require 'active_job'
7
8
  require 'rails'
8
9
  begin
9
10
  require 'mongoid'
@@ -56,6 +57,6 @@ module MiscHelpers
56
57
  end
57
58
  end
58
59
 
59
- class MiniTest::Spec
60
+ class Minitest::Spec
60
61
  include MiscHelpers
61
62
  end
data/test/value_test.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  require 'test_helper'
4
4
  require 'yaml'
5
5
 
6
- class ValueTest < MiniTest::Spec
6
+ class ValueTest < Minitest::Spec
7
7
  class Model
8
8
  end
9
9
 
@@ -162,4 +162,11 @@ class ValueTest < MiniTest::Spec
162
162
  assert_silent() { Enumerize::Value.new(attr, 'test_value') }
163
163
  end
164
164
  end
165
+
166
+ describe '#as_json' do
167
+ it 'returns String object, not Value object' do
168
+ expect(val.as_json.class).must_equal String
169
+ expect(val.as_json).must_equal 'test_value'
170
+ end
171
+ end
165
172
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enumerize
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0
4
+ version: 2.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Nartimov
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-07 00:00:00.000000000 Z
11
+ date: 2024-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -31,16 +31,17 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
+ - ".github/dependabot.yml"
34
35
  - ".github/workflows/ruby.yml"
35
36
  - ".gitignore"
36
37
  - ".rspec"
38
+ - ".tool-versions"
37
39
  - CHANGELOG.md
38
- - Gemfile
39
40
  - Gemfile.global
40
41
  - Gemfile.mongo_mapper
41
- - Gemfile.rails60
42
42
  - Gemfile.rails61
43
43
  - Gemfile.rails70
44
+ - Gemfile.rails71
44
45
  - Gemfile.railsmaster
45
46
  - MIT-LICENSE
46
47
  - README.md
@@ -99,7 +100,7 @@ homepage: https://github.com/brainspec/enumerize
99
100
  licenses:
100
101
  - MIT
101
102
  metadata: {}
102
- post_install_message:
103
+ post_install_message:
103
104
  rdoc_options: []
104
105
  require_paths:
105
106
  - lib
@@ -114,8 +115,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
115
  - !ruby/object:Gem::Version
115
116
  version: '0'
116
117
  requirements: []
117
- rubygems_version: 3.1.6
118
- signing_key:
118
+ rubygems_version: 3.5.3
119
+ signing_key:
119
120
  specification_version: 4
120
121
  summary: Enumerated attributes with I18n and ActiveRecord/Mongoid/MongoMapper support
121
122
  test_files:
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- eval_gemfile('Gemfile.global')
2
-
3
- gem 'minitest', '~> 5.8'
4
- gem 'rails', '~> 5.2.4', require: false
5
- gem 'mongoid'
6
- gem 'sqlite3', '~> 1.5', :platform => [:ruby, :mswin, :mingw]